The Zerynth Lamp tutorial is a popular project on Hackster with over 8, 000 views and a lot of comments. Everyone wanted to make their own Python programmable ambient light.
Well, now it got an update, and it’s compatible with the latest version of Zerynth (www.zerynth.com).
In this tutorial we'll see how to control a NeoPixel LED strip via mobile using the Zerynth App, that shows a color picker and a menu for the selection of various pre-configured animations.Thanks to the Neopixel module, the module is fully supported by Zerynth for developer through a set of APIs that makes handling this device much easier.
IoT allows devices around us to be connected together through the Internet. Simply, these devices are connected to a server. As a result, you can use your smartphone to connect it the various devices, This enables you to have real-time communication between the devices and the smartphones.
Zerynth, is the middleware for IoT and Industry 4.0, Zerynth speeds up IoT development.
With Zerynth you can program in Python or hybrid C/Python language the most popular 32-bit microcontrollers, and connect them to the top Cloud infrastructures.
The Zerynth App is a mobile application for Android and iOS that allows fast prototyping of device graphical interfaces for monitoring and control. It is a generic app, it only provides a mechanism to retrieve and access the connected devices, while the graphical interface definition is left to the programmer.
- The LED strip uses only one pin to control the whole chain of LEDs. Each LED is addressable through the driver chip inside the LED.
- Connect the VCC pin to a 5V source, The GND to the GND of the microcontroller. Connect the DIN pin to D23 (changeable in the code)
- Connect and Virtualize your board.Have a look at this documentation for the installation guide.
- Create a new project in Zerynth (already explained here). Attention: you need to create 3 (+1) files: main.py, animation.py, template.html (and project.md is created by default).
- Copy the code posted.
- We are going to integrate and use the smartphone to control the micro controller board using the Zerynth Advanced Device manager.On the Left Panel, by clicking the ADM icon, the list of connected devices is retrieved and displayed. New device can be created from the dropdown menu next to the panel title.
As shown in the above image, a newly created connected device is assigned a uid and a security token. A new token can be requested by clicking on the old one.
The circle to the left of the device name is gray, indicating the offline status of the device; it turns to green when the device connects to the ADM. The eye icon to the right of the name, opens the associated template of the device on a system browser tab in order to allow template testing.
Now we have to create a “connected device” and link the Zerynth App instance to it. Below you can see some screenshots with the necessary steps. Take a look at this doc for more technical details.
The device credentials (UID and TOKEN) can be copied and pasted directly from Zerynth Studio (ADM panel).
Templates can be added by clicking the respective “plus” icon.
Then upload the template from the dedicated folder. Note that the file where the template is defined is called “index.html” and you can edit it how you want. In this case, you can leave it as it is.
Remember that “DEVICE UID”, “DEVICE TOKEN”, “SSID” and “PASSWORD” have to be edited to fit with your own parameters.
you have just to open the Zerynth App, log-in and select the specific device to see your LED strip control dashboard.
Hope this tutorial was useful. For any questions, feel free to leave them in the comments.
Until next time, happy coding!