Generic IOT platform for Home Automation based on the ESP8266/ESP32.
After a few times of implementing IOT devices for home automation, i have recognized that each new one looks better and better, but this is always copy-paste approach... And not so easilly to back to previous implementation and merge innovation. For instance after implementing simple IOT for Relay switching I have did another project to control RGB strip (WS2811/2812 ) and finally get to sketches which I have to support... Instead of that i decided to develop universal sketch to support code once, but with possibility to upload to different IOT controllers for my Home Automation. Main targets are :
- Support ESP32 and ESP8266 with the same code
- The same skecth should support different devices, the difference must be outside in the configuration file. Like Lego bricks...
- Updatable via the web (OTA), some times not easilly to physically access device, when it's altready installed
- Nice web interface to controll devices as well to setup them
- RAW file browser to upload/change configuration files or HTML for the WEB
- MQTT integration to be able control devices via Home Kit
- Native support of Apple Home Kit integration (only for ESP32)
- On board automation scripts/triggers.. Some times is not easy to setup this one via Home Kit or Home Kit doesn't exists
- Configuration portal after firts start (captive portal)
- Suports of RF 433 Mhz control by any existing transmitters
- More and more
Ok, let's describe basic thing how it works Major element of this solution is service, like in windows unix , android etc. Each service are responsible to control one device wired to ESP. Hovewer it's possible to run 2 instances of the same service to control similar devices. List if services is configurable by json file with their properties Second and maybe last major element is trigger . It define interaction between services and fulfill automation. The list of of triggers as well configurabel
Few examples:
- You need device to control only one Relay (for any reason: light, heater,...) Just define configuration services.json with one service RelayController, define pin, where relay is physically wired, that's all ! You will get a device ready and able to controll your lights via Web or Home Kit (Home Kit integration possibilities will be explained later)
- Additionally to previos you want to control your Relay by Light sensor . Yo need to add LDRController to listen wired LDR. Web and Home will automatically detect this and you can see your lumens over the or Home Kit). But you can configure LDR to Realy trigger with barier values, and than when LDR is higher that barier trigger will send command to Relay to switch off or vice verse..
- More and more examples and combination within services and triggers...will come
This project uses libraries and code by different authors:
-
WiFiManager by tzapu (tested with version 0.12.0)
-
WS2812FX by kitesurfer1404 (tested with version downloaded 2017-02-05)
-
Adafruit NeoPixel by adafruit (tested with 1.1.2)
-rc-switch small changes are done to works with ESP32 as well
-ESPHap this is library for native Apple Home Kit integration
Parts of the code were taken or inspired by the following sources:
-
SPIFFS Webserver by Hristo Gochkov This part is adapted fo the following following staff:
- Supports ESP32 file system
- Enhanced filebrowse.html
- "Prefly" request and headers for cross domain areas
- overwritten within new code when skecth is uses AsyncWebServer
Thank you to all the authors for distributing their software that way. I hope I didn't miss any sources and mentioned every author. In case I forgot someone please let me know and I will fix it.
Goals are reached :
- Adapted ESP8266HTTPUpdateServer , now it's supports ESP32. Have a look of ESP32HTTPUpdateServer.h/cpp implementatation with traditional WebServer;
- Adapted ESP8266HTTPUpdateServer for working withis ESPAsyncWebServer. Have a look of ESPAsyncUpdateServer.h/cpp
- Second core of ESP32 can be used with proper service configuration. Now a few services can run on second core of ESP32;
- Built-in web site implemented on React js, and browser content is very fast, compatible with native mobile application, Thanks to React developers;
- Sketch can be compiled within VS 2017, by using Arduino IDE for Visual Studio
- Adapt WS2812FX library to perfectly works on ESP32, see details here
WebSite
ESPHomeController has own web site. Ready sources located in the data directory. You just need to upload them into your spiff. This Web site is builded on ReactJS, therefore to change anything you need to use sources
For technical infomation see Wiki
Please have a look https://github.com/Yurik72/esphapcontroller , there is a clone of code base adapted for esp-idf and NATIVE support of Apple Home, this is version based on ESP-IDF
Projects using this firmware
fireplace lamp with tem sensors Bed Room Lamp Ws2812 Weather station
P.S. !! This is starting project not all parts already comitted. Will come soon after testing. If you are interested feel free to contact me