Now we get serious. We start with an extensive project, we want to realize a SmartHome control center with the ArduiTouch, which can manage up to 32 remote devices based on ESP8266. Each of these devices can use up to 8 channels for communication. To show you where the journey is going, I decided to create a rudimentary but fully functional prototype and make it available for download.
This will be followed by blog posts with detailed explanations of the protocols and programs used. Since the whole project consists of a large number of files, I will not publish the code in this post but make it available for download on GitHub. The repository TouchEvent contains a library I developed for convenient management of TouchScreen events, the repository ATMessageBuffer contains libraries for a message buffer for data transmission and finally the repository ATSmartHome it contains a database as a base for this project as well as sample programs for the smart home control center and for a simple client for temperature measurement.
To build the prototype you need an ArduiTouch with ESP32 processor for the control center and a D1Mini or another ESP8266 module and one or two DS18B20 temperature sensors for the remote temperature sensor. For the temperature sensor the following circuit is used:
You should also refer to the Arduitouch in this Blog post note.
Next you should get the three downloads mentioned above from GitHub. Simply copy the unzipped folders into the Arduino libraries directory.
In the examples for ATSmartHome-master you will find a sketch ATSmartHome for the control center and an ESP8266Device for the sensor.
The sketch for the control panel should be compiled with the board "ESP32 Dev Module" and the one for the sensor with the board "NodeMCU 1.0 (ESP-12F Module)". After both sketches are compiled and uploaded to the respective module we should see the following picture on the ArduiTouch.
Maybe the lower blue bar is without text at first, but this should change as soon as the temperature sensor has sent its values. When the Smart Home panel receives data from an unknown device, the id of the unknown device is displayed in the lower blue bar.
If you tap twice in quick succession on the lower blue bar (double click), the registration page should be displayed. Attention, if the bridge for the program download is still closed, the touch screen does not work!!!
If you double-click on the "Register" button, the new device will be registered and its measured values can be displayed. If you double click on the "Back" button, the main page is displayed again without registering the device.
If the device was registered, this information is also permanently stored in the SPI file system of the ESP32. As soon as the control panel has received data from the temperature sensor again, you should see the following picture.
Whenever new readings are received from the temperature sensor, the display is updated. Since the registration has been saved permanently, the ArduiTouch can also be disconnected from the power supply without forgetting the registered devices.
Additional devices can be registered in the same way as described. In this prototype version the registration data in the SPI file system can only be deleted by formatting. To do this, double-click on the upper blue bar. The system setup page should be displayed.
A double click on "Format FS" formats the file system and deletes all files. After formatting is complete, the main page is displayed again. If the temperature sensor continues to send data, it is recognized as an unrecognized device and its Id is displayed in the lower blue bar.
The sketch for the temperature sensor is set to send readings every 10 seconds. This is very convenient for testing. For a real application, this time should be increased to five minutes or more to minimize power consumption.
As you can see, we have a very simple smart home control panel that can register external sensors and display their readings.
Finally, a few features that will be implemented in future versions.
- Customizable display of measurement results
- Multiple pages for displaying measurement results
- Sending data from the control panel to remote devices (switching, dimming)
- Connection of the Smart Home control panel to the Internet and time display
- Operation via web pages
- Connection to external services such as Cayenne
- Extension of the hardware. Using the SD card reader on the touch screen to log data
- Definition of trigger values to trigger actions depending on measured values
- and many other nice things. There are almost no limits to your imagination.
If you want to learn more about how this prototype works, you should read my upcoming blog posts. If you have any questions or problems, just add a comment. I will check in regularly and try to answer questions as soon as possible.
Here it goes on: