With this project you can create a controller for IoT devices!
Since I have so many Arduino/Arduino-like IoT devices in my home, I needed a simple and effective way to control them all according to my needs: my choice fell on AZ-Touch kit by AZ-Delivery, which already comes with an almost pre-welded PCB, a TFT display with SD card reader and a case to contain everything. I just added one of the supported boards, a bunch of code, and that's it!
The code I wrote is compatible with both ESP32 Dev Kit C and Wemos D1 Mini; pay attention that Wemos D1 Mini does not support the full set of colors.
You'll also need an MQTT client capable of returning the list of your devices and their commands: I used a Python script (as you can see in the doc folder of the repository), but you can choose according to your knowledge and needs.
The complete code for the sketch is available in the GitHub repository, as well as complete instructions and an installation example, and is constantly updated as I make new developments; so here let's see briefly how it works!
How it worksIn the home screen, the controller shows the different types of devices that have been configured (e.g. Relays, Curtains, Air Conditioners, LED Strips, Environmental Sensors, Batteries); when one of these is touched, the controller publishes a message on its previously defined topic.
Another MQTT client (in my case, as I said, a Python script, but it can be anything: choose according to your needs); it is subscribed to that topic, so it can receive it and process a list of available devices of that type (for example all the smart sockets in the network); in my case this is done with the help of a MySQL table, so the Python script queries the right table, reads the devices, and returns this list as a json array on a new topic.
When the controller receives this list (remember: no matter how it is generated, it must be returned on the right topic as a valid json array), it goes to the second level page, which shows the list of all the devices present in the array; by touching any of these devices, another publication is made on another configured topic.
The listening client should in this case return a list of all the commands that can be sent to that particular device (that is, for example, if device is a smart socket, it can be "on" or "off"), as well as the related topics to send them, and also publish this list as a json array on a new topic.
When the controller receives this list it goes to the third level page, which shows a list of the commands present in the array; by selecting one of these commands, a publication on the associated topic is immediately carried out, so that the corresponding device can be controlled; the controller shows a confirmation page for a few seconds, and then returns to the initial screen, ready for a new cycle.
Comments