ESP32 & ESP8266
uploads→ temp, humidity,batt voltage.
uploads→ temp, humidity, smoke level, onboard temp & batt voltage. TGS-2600 probe needs 5 volt supply to operate unlike 3.3 volts for the others like DHT-22 or DS1307 sensors. However, it’s output is 3.3Volt compatible for the ESP32 input pins. The 3 pin regulator – 7805 reduces input 9V – 12V to 5Volt level. The 3.3 volt is made by the ESP32 onboard regulator.
For timekeeping I’ve used two ways – One RTC (DS1307) connected on the ESP32 and the other ESP8266 to connect to the NTP server to get time periodically. Both ways it works but I prefer the RTC way because it comes for almost naught ($0.5 – $1 a piece from aliexpress.com ) and you are on your own!
The software is divided into two parts – The PHP scripts & the Arduino sketches.
- PHP scripts: There are two PHP scripts – c1z1.php for cloud-1, zone-1 data and c1z2.php for cloud-1 zone-2 data. The c1z1.php uploads 5 data which are handled by the ESP32 while the c1z2.php uploads 3 data which are handled by the ESP8266. These scripts are to reside in the document directory of Apache server so that it can be a browser ready page which is called periodically by the ESPs for uploading data. The server preferably has to have access from the Internet so that the nodes can directly send data there.
- Arduino sketches: These are two Arduino sketches – esp8266_mysql_2.ino for the ESP8266 and esp32_mysql_2.ino for ESP32.
Upload these sketches to the respective boards. Keep the server ready and then see that the data gets dumped into the MySQL tables every now and then. The RTC may need to reset the time when it is started the first time. Uncomment the line to make it ready for setting time then upload the sketch to set time first time. Next, comment out that line and then upload the sketch again. The RTC will keep on supplying time henceforth uninterruptedly because it has a small onboard battery back up.
Output on ChartDirector
I have my output designed on PHP type ChartDirector. First, download ChartDirector on your chosen language and then see the code part in your favorite language and you can build a beautiful online trend curve just in no time. However, most of the curves of ChartDirector are a static type, to make them live just insert the PHP refresh code somewhere towards the bottom of the code.
# Output the chart
header(“Refresh:240”); // This is for online refresh ;once in 240 seconds
//end of code
The sample chart can be seen here
Cost / BOM:
ESP8266 = $3.5
ESP32 = $7.5
DS01307 RTC = $0.7
The typical use of this system can vary from simple upload to conditional complex uploads into MySQL tables. Door open/close, AC Hall temp & humidity, VAT – empty/full, Hall light on / off , airspeed, air direction, ambient temperature, drain overflow, Hopper empty / full , smell in the toilet , overhead tank level , Boiler roof / Penthouse temperature, Dust SPM at chimney top, Battery voltage, Current, CT Cell temperature , Chlorine gas leakage at PT Plant etc. are the type of data where one can expect automated logging without much interference.
The same feats can be achieved using single board computers like Raspberry Pi, Beagle bone, Orange Pi, Banana Pi others. While the cost of those runs in $50 – $ 100, the cost of these systems is hardly $3.5 for ESP8266 and $7.5 for ESP32. The single board computer takes minimum 2-watt power to run beside may hang or slow down at times but this system once burnt into the memory will never hang.
Download source folder