Simplest DIY low power, low cost, standalone or web connected IOT sensors network framework using ESP32 or ESP8266 (no third party service required).
This is the main goal of this project. Proberequest protocol is used for data transfer to conserve power.
No over engeeniering. Use analog sensors as much as possible for simplicity in hardware and code with lower hardware cost. Use ESP-CAM hardware for low cost video survailance or motion tracking.
In most use cases no need to buy expensive commercial products except ESP32 barebone modules and NTC thermistors for temperature sensor, photoresistors or phototransistors for light sensor, some low cost sensor modules, LDO and/or battery charging IC, coin cell battery and/or small solar panels based on use cases.
There is no need to use overwhelming and heavy software like home assistance. Easily customise look and feel of front end in javascript or remote sensors code in C++ as you wish.
Whole network can be monitored and controlled using any android or ios MQTT front end dashboard client app like MQTT Dash thereby making it very simple to implement.There is also very simple but powerful dashbord to monitor sensor data from whole network using awsome uPlot graphing library and built in webserver. Sensor data of whole network is stored on ESP32 gateway device using SPIFFS file system. The web interface is simple one page but powerful enough to monitor and control whole network of devices. Web interface could be customised any way you want live by changing html, css or javascript code using built in SPIFFSEditor library without recompiling or reuploading files. Changing data format in SPIFFS also possible live from web interface using SPIFFSEditor.
No need to charge small 100 mAh LIR2450 coin cell battery or any chargable battery manually for life of battery or solar cell. Small 53mmx30mm or even smaller 3V to 5V solar cell can be used.
Average sensor node could be made for $2 to $5 (less than $2 using CH582F microcontroller) each including battery and/or small solar panel for charging. Use of IR transmitters recommended as much as possible for in room automation. Average home can be automated with more than 10 remote sensors for below $100 total cost.
Built in whole house intruder motion detector, presence and location detector for family members all implemented in software saving cost for any motion or presence detector hardware sensors.
Simply storing single standard .bin file for all remote devices to ESP32 Gateway SPIFFS file system and publishing MQTT command from MQTT client app or by issuing command from web interface each sensor device on the network can be updated with latest firmware. Again there is no need to physically access hard to reach remote devices.
This code can create small standalone network (maximum of 100) of battery powered WiFi devices connecting to one ESP32 gateway device in star network topology. Each device can be controlled simply by MQTT app like MQTT Dash or built in web interface over local network or over internet if used with DynDNS service like DuckDNS. There is no need for other home automation software locally or on cloud.
My testing shows data communication is achieved within 80 milliseconds total uptime for remote device out of which only 45 milliseconds of time used for more power hungry WiFi receive & transmit on average thereby saving significant battery power. I think this is better than ESPNow protocol.
commands are issued via MQTT payload with topic name "command/" or using dropdown menu at built-in web interface. At least first three commands are necessary.
- Device ID must be 2 or 3 digits and ending with 2,6,A or E to avoid conflict with other devices.
- See https://serverfault.com/questions/40712/what-range-of-mac-addresses-can-i-safely-use-for-my-virtual-machines.
- Any of following for device ID is valid.
- 06,16,26,36,46,56,66,76,86,96,106,116,126,136,146,156,166,176,186,196,206,216,226,236,246.
- value 101 to 121 is reserved for following commands:
- 101 = Digital Write.
- Example command payload 36/101/<01 to 05 or 12 to 39>/<00 0r 01>/ for digitalWrite.
- 102 = Analog Write.
- Example command payload 36/102/<01 to 05 or 12 to 39>/<1 to 256>/ for analogWrite(pwm).
- 103 = Digital Read.
- Example command payload 36/103/<01 to 05 or 12 to 39>/
- 104 = Analog Read.
- Example command payload 36/104/<01 to 05 or 12 to 39>/
- 105 = Neopixel.
- Example command payload 36/105/<00 to 256>/<00 to 256>/<00 to 256>/<00 to 256>/
- 106 = Set target values.
It is posiible to send and store 4 target values to remote device for further automation locally in remote device.
- Example command payload 36/106/<00 to 256>/<00 to 256>/<00 to 256>/<00 to 256>/
- 107 = Set WiFi Channel.
- Example command payload 36/107/<00 to 14>/
- 108 = Set device mode - device mode 0 = normal mode and device mode 1 = OTA update.
Mainly used for OTA update but can be used to run any alternative Code block.
- Example command payload 36/108/<00 to 105>/
- 109 = Set sleep time in minutes.
- Example command payload 36/109/<00 or 255>/
- 110 = Set device ID.
- Example command payload 36/110/<00 or 255 if number ends with 2, 6, A, or E>/
- 111 to 120 reserved for future expansion.
- 121 = Set sensor types for each device.
- Example command payload 36/121/<00 to 256>/<00 to 256>/<00 to 256>/<00 to 256>/
- pinNumber in case of command type 101 to 105 above.
- Value1 in case of command type 106,107,108,109 & 110 commandtype.
This project was possible thanks to creators of following libraries used for this project: