In this article you can see how to control 220/110V appliances via web browser or via a mobile app with a few lines of Python, HTML and Javascript!
In particular you’ll see how to remotely turn on and off two high-voltage bulbs using the relays of 4zerobox, an industrial board based on ESP32, programmed in Python using Zerynth, a recommended SDK for ESP32. You can find more info about Zerynth and its support for 4zerobox, in its Kickstarter campaign page: https://bit.ly/get-4zerobox
Required MaterialsYou need:
- A 4zerobox. You can pre-order it on Kickstarter: https://bit.ly/get-4zerobox In alternative you can use one of the ESP32-based boards supported by Zerynth.
- 2 standard relays, NO/NC, 10A @ 250V AC. In this case we’ve used the relays integrated on 4zerobox, but if you want to build the project with another board you can connect it to a standard NO/NC relay module like this one in the following figure.
- Zerynth Studio, a powerful IDE for embedded programming in Python that enables the IoT. You can download it here.
- Zerynth App, a mobile application that allows fast prototyping of graphical interfaces for your IoT projects using HTML, CSS and JavaScript. You can download it here.
At the following link you can find how to get started and run your first basic Python script on 4zerobox (based on ESP32) using Zerynth: https://www.hackster.io/TOI-things-on-internet/python-on-esp32-for-industrial-iot-applications-d8bbc4
Take a look at this step-by-step tutorial to see how to get started with the Zerynth App: https://www.zerynth.com/blog/getting-started-with-the-zerynth-app-how-to-build-an-iot-thermometer/
Here are two projects where you can find more info about how the Zerynth App works and get inspired:
- Control Neopixels using Python and JQWidgets: https://www.zerynth.com/blog/control-neopixels-using-python-and-jqwidgets/
- Using Python to control Servo Motors for Internet of Things projects: https://www.zerynth.com/blog/using-python-to-control-servo-motors-for-internet-of-things-projects/
With the Zerynth App you can manage and control the connected devices programmed with Zerynth Studio, enabling a bidirectional communication channel between them and your mobile.
Zerynth App interfaces are based on HTML5 templates that can be updated directly in the Zerynth Studio and transferred to the remote backend via the Zerynth ADM.
All the logic of interaction between the Zerynth object and the Zerynth App is written in Python (see the attached file "main.py"), while the UI is specified in HTML and Javascript (see the attached file "index.htm"l).
Any data collected or generated by Zerynth powered devices (i.e. room temperature, room light and sound level, etc.) can be shown on mobile by sending an event (and event push notifications!) from Python to the App.
The communication also happens the other way round with the App sending events to the Python script which in turn can execute functions. Therefore the App can also work as a remote controller, by specifying in the Python script which event triggers a specific callback (e.g. a switch button in the App can turn a led, or a relay as in this case, on and off).
A unique feature of the Zerynth Stack is the integration of Web 2.0 technologies with connected devices. By linking a device to a template (that can be as simple as a single static web page or as complex as a responsive website), the device can be monitored and controlled remotely both on the Zerynth App or on a desktop computer via a web browser clicking the eye icon to the right of the device name, as you can see here and in the video.
Find out more on the Zerynth App documentation page https://docs.zerynth.com/latest/official/core.zerynth.docs/zapp/docs/index.html#
4zerobox - Remote Controlled Relays TestHere is the video of the project. You can replicate it using the attached code and following the step-by-step guides mentioned above.
NOTE: this video shows the v0 prototype of 4zerobox, that uses an ESP32 mounted on an ESP32-DevKitC. The final version will include an ESP32-wroom module directly on-board.
This is a very basic example of the capabilities of 4zerobox. Take a look at the campaign page for more video examples about Web Server Connection, RS232 and RS485 communications, LoRa, AWS and Google Cloud IoT connections!
Comments
Please log in or sign up to comment.