Monday, March 28, 2022

The principle of operation of the smart home system

The diagram is shown in the picture. This is how the entire system is managed: the message sent to the bot is processed by the MYEWWT device. If additional devices are added to the system - smart sockets, relays, etc., the command from the bot is first processed by the MYEWWT device, then transmitted to the devices connected to the system using ESP-NOW technology.


More about firmware

I started the code in the Arduino IDE using the Espressif SDK for the ESP-12F microcontroller, then developed it in the VS Code environment using the PlatformIO toolkit.


Most of the project's code is commented and broken into convenient parts in the form of several files:

  • the main one, with a common loop and the declaration of global variables and some functions,
  • for functions called when sending and receiving messages via ESP-NOW,
  • functions used to operate the addressable LEDs,
  • block with functions for server operation (captive portal),
  • message handler function from the Telegram bot,
  • block with other system functions: timing, firmware update, time synchronization, etc.


My smart home system uses two types of connections:

  • From the Telegram server to the MYEWWT gateway.
  • From the MYEWWT gateway to other devices in the system (sockets, relays, switches, etc.).

Building a smart home bot

Enable MYWWT. All segments will light up with an iridescent rainbow. You need to connect from your phone, tablet or computer to the MYEWWT Wi-Fi network with the password iloveyou.


Go to the browser at http://10.10.10.10 and enter the access point of your home Wi-Fi, password and token of the created bot in the proposed form.


After all the procedures, within a few seconds, MYEWWT will connect to the network, the time will be synchronized via the NTP server, and all the functionality of MYEWWT will become available.


The board is powered by 5 V from the USB cable. Since the ESP-12F microcontroller requires a 3.3 V power supply, a voltage stabilization unit is provided - the AMS1117-3.3 stabilizer itself, as well as input and output smoothing capacitors to ensure the stability of the board.


The WS2812b LEDs, unlike the ESP-12f, require 5 V to work correctly, so the board provides a logic level converter based on an N-channel MOSFET transistor.


Also, the DHT-22 module is connected to the circuit, which exchanges temperature and humidity readings with the ESP-12f module via the SDA line.


To ensure the adaptive brightness of the LEDs, a photoresistor is included in the circuit, connected to the ADC pin of the microcontroller using resistors that provide the operating range at the analog input of the microcontroller.

The principle of operation of the smart home system

The diagram is shown in the picture. This is how the entire system is managed: the message sent to the bot is processed by the MYEWWT device...