In this article, we will learn how to make a pool thermometer that can transmit readings remotely. Those. this thermometer connects to the smart home system based on Apple HomeKit and Alexa.
Tools and materials: -ESP32;
-Temperature sensor DS18B20;
-Solar panel (6 V/65 mA/0.4 W);
-LiPo battery 3.7 V/~ 800 mAh; -Charger module TP4056; -Voltage regulator (MCP1700-3302E);
-Electrolytic capacitor 100 uF;
-Ceramic capacitor 100 nF; -Resistor 4.7 kOhm; -Mounting plate; -Jumpers; -Nivea Care moisturizer (need a box of cream); – PVC rod 20 mm x 100 mm;
-O-O-ring ( 75 mm x 2.5 mm);
-O-ring (20 mm x 3.5 mm);
-Soldering accessories; -Drilling machine; -Drill; -Glue gun;
Step one: about the thermometer
For the thermometer to operate on a solar panel, energy consumption must be kept to a minimum. In addition, the small size of the solar panel should be taken into account.
The wizard decided to install the HTTPWebHooks * plugin on the Homebridge ** and add a thermometer as a temperature sensor.
The advantage of this software is that the current pool temperature is stored in Homebride and not in the ESP memory. Hence, the ESP only needed to make an HTTP request to the HTTPWebHooks plugin and go into deep sleep for 10 minutes before it boots up again and reads/sends the current temperature to Homebridge.
* HTTPWebHooks – a mechanism for sending notifications when an event occurs in the system.
** Homebridge is a NodeJS server that acts as a bridge, thanks to which you can add unsupported devices to the Home application.
Step two: code
Thermometer code pretty simple:
Setting up a Wi-Fi connection
Turning off Bluetooth to reduce power consumption
Reading the temperature from the sensor
HTTP request to Homebridge transmitting the current temperature of the sensor.
Disconnect from Wi-Fi and enter deep sleep for the next 10 minutes.
After 10 minutes, the whole process starts over.
Download the code below.
#include & lt; WiFi.h & gt; #include & lt; HTTPClient.h & gt; #include & lt; ESPAsyncWebServer.h & gt; #include & lt; esp_bt.h & gt; #include & lt; esp_wifi.h & gt; #include & lt; esp_sleep.h & gt; #include & lt; OneWire.h & gt; #include & lt; DallasTemperature.h & gt; #define ONE_WIRE_BUS 4 OneWire oneWire (ONE_WIRE_BUS); DallasTemperature sensors (& amp; oneWire); const char * ssid = & # 34; YOUR_WIFI_NAME & # 34 ;; const char * password = & # 34; YOUR_WIFI_PASS & # 34 ;; HTTPClient sender; #define uS_TO_S_FACTOR 1000000ULL/* Conversion factor for micro seconds to seconds */#define TIME_TO_SLEEP 600/* Time ESP32 will go to sleep (in seconds) */float temperature; void push () & # 123; if (sender.begin (& # 34; http & # 58; //IP_OF_YOUR_HOMEBRIDGE & # 58; 51828 /? accessoryId = esp32 & amp; value = & # 34; + String (temperature))) & # 123; int httpCode = sender.GET (); if (httpCode & gt; 0) & # 123; if (httpCode == HTTP_CODE_OK) & # 123; String payload = sender.getString (); Serial.println (payload); }} else & # 123; Serial.printf (& # 34; HTTP-Error & # 58; & # 34 ;, sender.errorToString (httpCode) .c_str ()); } sender.end (); } else & # 123; Serial.printf (& # 34; Error establishing HTTP connection! & # 34;); }} void setup () & # 123; Serial.begin (115200); WiFi.disconnect (true); delay (1000); WiFi.mode (WIFI_STA); delay (1000); WiFi.begin (ssid, password); btStop (); esp_bt_controller_disable (); while (WiFi.status ()! = WL_CONNECTED) & # 123; delay (200); Serial.print (& # 34;. & # 34;); } Serial.println (& # 34; Connected! & # 34;); sensors.begin (); esp_sleep_enable_timer_wakeup (TIME_TO_SLEEP * uS_TO_S_FACTOR); sensors.requestTemperatures (); Serial.print (sensors.getTempCByIndex (0)); Serial.println (& # 34; ° C & # 34;); temperature = sensors.getTempCByIndex (0); push (); WiFi.mode (WIFI_OFF); esp_deep_sleep_start (); } void loop () & # 123; }
Step Three: Wiring
The device diagram is simple, and the basic assembly steps will be explained in the following steps.
Step four: voltage regulator
First, what needs to be done is to install a voltage regulation board.
The wizard recommends using a 3×6 board. This way there will be enough room for components and wires without having to bend any of the component leads.
Electrolytic capacitors have polarity. The leg on the side of the white-gray strip is negative and should be connected to the left leg GND. The second leg is soldered to the right side of the board.
Ceramic capacitors have no polarity. Therefore, it does not matter how to solder it, the main legs are soldered to the outer tracks.
Finally, you will need to connect a voltage regulator to the board. The important thing here is how the electrolytic capacitor was connected. If the white/gray strip of the capacitor is on the left, the round side of the voltage regulator should face the capacitor. If the bar is to the right, then the flat side of the regulator should face the capacitor.
Step five: sensor installation
Next you need prepare parts for installing the temperature sensor.
We drill a hole with a diameter of 4 mm for the entire length of the rod. Another hole needs to be drilled in the center of the bottom of the can of cream (the diameter depends on the size of the rod).
You also need to cut a thread at one end of the rod and put on an O-ring.
Now you need to push the end of the temperature sensor wire through the rod and the bottom cans and screw the nut onto the rod.
The connection point must be sealed with silicone. To check the tightness, you need to install a second O-ring, screw the lid on the can and place it in the inlet for a couple of hours.
Now you need to connect the sensor to the ESP.
Black wire connects to GND pin of ESP.
Orange/yellow wire connects to 4.7K resistor and pin 4 of ESP.
Red wire connects to other end of resistor.
Step six: final assembly
Now you need connect the charging regulator to the battery, ESP and voltage regulation board.
The wizard starts with the voltage regulation board. The minus must be connected to one of the GND ESP pins and the OUT output of the charger.
The Out + pin of the charging regulator is connected to the center pin of the voltage regulation board.
Next, we connect the regulator to the 3.3 ESP pins, and the power wire going from the temperature sensor.
Now all that remains is to connect the battery to the charger.
By this time, the thermometer should already be working. All joints are sealed with hot melt glue.
The last thing to do is to drill two holes in the cover and stretch the wires from the solar panel through them. The wires are connected according to the diagram, and the panel is glued to the cover with hot melt glue.