diff --git a/README.md b/README.md index faf22e66..561c41b5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # ESPurna -ESPurna ("spark" in Catalan) is a custom C firmware for ESP8266 based smart switches. It was originally developed with the **[ITead Sonoff][1]** in mind. +ESPurna ("spark" in Catalan) is a custom C firmware for ESP8266 based smart switches. +It was originally developed with the **[ITead Sonoff][1]** in mind but now it supports a growing number of ESP8266-based boards. ## Features @@ -9,13 +10,15 @@ ESPurna ("spark" in Catalan) is a custom C firmware for ESP8266 based smart swit * **Flashing firmware Over-The-Air** (OTA) * Up to **3 configurable WIFI networks**, connects to the strongest signal * **MQTT support** with configurable host and topic +* **REST API** to query and set relay statuses +* Support for **multi-relay boards** (Sonoff Dual, Electrodragon ESP Relay Board,...) * Manual switch ON/OFF with button (single click the button) * AP mode backup (double click the button) -* Manual reeset the board (long click the button) +* Manual reset the board (long click the button) * Visual status of the connection via the LED * **Alexa** integration (Amazon Echo or Dot) by emulating a Belkin WeMo switch * Support for **automatic over-the-air updates** through the [NoFUSS Library][2] -* Support for **DHT22** sensors +* Support for **DHT22** and **DS18B20** sensors * Support for the **HLW8012** power sensor present in the Sonoff POW * Support for **current monitoring** through the [EmonLiteESP Library][3] using a non-intrusive current sensor ([requires some hacking][4]) * Command line configuration diff --git a/code/platformio.custom.ini b/code/platformio.custom.ini index 22178ada..68ff6edd 100644 --- a/code/platformio.custom.ini +++ b/code/platformio.custom.ini @@ -49,7 +49,6 @@ include = common board = nodemcuv2 platform = espressif8266 build_flags = -g -DNODEMCUV2 -DDEBUG_PORT=Serial -lib_ignore = [env:node-debug-ota] include = env:node-debug,ota @@ -89,14 +88,6 @@ build_flags = ${def.build_flags_debug} -DSONOFF_DUAL include = env:sonoff-dual-debug,ota build_flags = ${def.build_flags_ota} -DSONOFF_DUAL -[env:sonoff-dual-debug] -include = common -board = esp12e -build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF_DUAL - -[env:sonoff-dual-debug-ota] -include = env:sonoff-dual-debug,ota - [env:slampher-debug] include = common board = esp01_1m @@ -118,10 +109,11 @@ build_flags = ${def.build_flags_ota} -DS20 [env:electrodragon-debug] include = common board = esp12e -build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DESP_RELAY_BOARD +build_flags = -g -DDEBUG_PORT=Serial -DESP_RELAY_BOARD -DENABLE_FAUXMO=1 -DENABLE_DHT=1 -[env:electrodragon-debug-ota] +[env:electrodragon-ota] include = env:electrodragon-debug,ota +build_flags = -DESP_RELAY_BOARD -DENABLE_FAUXMO=1 -DENABLE_DHT=1 # ------------------------------------------------------------------------------ diff --git a/code/platformio.ini b/code/platformio.ini index 6b01fe16..ccb3536d 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -113,7 +113,7 @@ board = esp01_1m lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} extra_script = pio_hooks.py -build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DSONOFF_DUAL +build_flags = -g -Wl,-Tesp8266.flash.1m128.ld -DSONOFF_DUAL [env:sonoff-dual-debug-ota] platform = espressif8266 @@ -122,7 +122,7 @@ board = esp01_1m lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} extra_script = pio_hooks.py -build_flags = -g -Wl,-Tesp8266.flash.1m256.ld -DSONOFF_DUAL +build_flags = -g -Wl,-Tesp8266.flash.1m128.ld -DSONOFF_DUAL upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 @@ -176,7 +176,7 @@ board = esp12e lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} extra_script = pio_hooks.py -build_flags = -g -DDEBUG_PORT=Serial -DDEBUG_PORT=Serial -DESP_RELAY_BOARD +build_flags = -g -DDEBUG_PORT=Serial -DDEBUG_PORT=Serial -DESP_RELAY_BOARD -DENABLE_DHT=1 [env:electrodragon-debug-ota] platform = espressif8266 @@ -185,7 +185,7 @@ board = esp12e lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} extra_script = pio_hooks.py -build_flags = -g -DDEBUG_PORT=Serial -DDEBUG_PORT=Serial -DESP_RELAY_BOARD +build_flags = -g -DDEBUG_PORT=Serial -DDEBUG_PORT=Serial -DESP_RELAY_BOARD -DENABLE_DHT=1 upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 diff --git a/docs/Firmware.md b/docs/Firmware.md index 367d2ee5..648edb4e 100644 --- a/docs/Firmware.md +++ b/docs/Firmware.md @@ -14,9 +14,11 @@ If you are using PlatformIO /strongly recommended) it will take care of the libr * Marvin Roger's [AyncMqttClient](https://github.com/marvinroger/async-mqtt-client) * Adafruit's [DHT Sensor Library](https://github.com/adafruit/DHT-sensor-library) (required if compiling with DHT support: -DENABLE_DHT) * Adafruit's [Unified Sensor Library](https://github.com/adafruit/Adafruit_Sensor) (required if compiling with DHT support: -DENABLE_DHT) +* Paul Stoffregen (et al.) [OneWire](https://github.com/PaulStoffregen/OneWire) +* Miles Burton (et al.) [DallasTemperature](https://github.com/milesburton/Arduino-Temperature-Control-Library) * The PatternAgents (et al.) [Embedis](https://github.com/thingSoC/embedis) * German Martin's [NtpCLientLib](https://github.com/gmag11/NtpClient) -* Michael Maregolis & Paul Stoffregen's [Time](https://github.com/PaulStoffregen/Time) +* Michael Maregolis & Paul Stoffregen's [Time](https://github.com/PaulStoffregen/Time) * Randy Simons' [RemoteSwitch](https://github.com/jccprj/RemoteSwitch-arduino-library) (required if using custom RF module: -DENABLE_RF) And my own libraries: @@ -45,7 +47,7 @@ Wire your board (check the [Hardware page](Hardware.md)) and flash the firmware > pio run -t upload -e sonoff ``` -(or any other environment, depending on the board you are woring with). +(or any other environment, depending on the board you are working with). Library dependencies are automatically managed via PlatformIO Library Manager or included via submodules and linked from the "lib" folder. diff --git a/docs/Hardware.md b/docs/Hardware.md index aea90b93..f13d4121 100644 --- a/docs/Hardware.md +++ b/docs/Hardware.md @@ -8,8 +8,10 @@ This is the official list of supported hardware for the ESPurna firmware. The ha * [IteadStudio Sonoff RF](#iteadstudio-sonoff-rf) * [IteadStudio Sonoff TH](#iteadstudio-sonoff-th) * [IteadStudio Sonoff POW](#iteadstudio-sonoff-pow) +* [IteadStudio Sonoff DUAL](#iteadstudio-sonoff-dual) * [IteadStudio Slampher](#iteadstudio-slampher) * [IteadStudio S20](#iteadstudio-s20) +* [Electrodragon ESP Relay Board](#electrodragon-esp-relay-board) ## IteadStudio Sonoff @@ -80,6 +82,24 @@ As in the Sonoff the button is connected to GPIO0, so to enter flash mode press Same as for the [Sonoff TH](#iteadstudio-sonoff-th) above. +## IteadStudio Sonoff DUAL + +|Property|Value| +|---|---| +|Manufacturer|Itead Studio| +|Web page|https://www.itead.cc/sonoff-dual.html| +|Build flag|SONOFF_DUAL| + +### Flashing + +![Sonoff DUAL - Inside back view](images/sonoff-dual-flash.jpg) + +The Sonoff Dual it's a bit tricky to flash since GPIO0 is not connected to the button as in the TH or POW, but to the pin 15 in the SIL F330 chip that manages the buttons and the relays. SO you have to locate a pad connected to GPIO and short it to ground while powering the device. + +In the picture above you have a location of an available and easily accessible GPIO0 pad. The other required pins are brought out in the top header. Remember it's a *3V3* device. + +Once flashed use OTA to update the firmware or the filesystem. + ## IteadStudio Slampher |Property|Value| @@ -115,6 +135,26 @@ There is a labeled header in the front of the PCB and the button is connected to Solder a 4 pin male or female header and connect it to your USB-to-UART bridge. Again, remember **it's a 3V3 device**. Then press and hold the button and connect the programmer to your computer. The microcontroller will boot into flash mode and you are ready to update the firmware. +## Electrodragon ESP Relay Board + +|Property|Value| +|---|---| +|Manufacturer|Electrodragon| +|Web page|http://www.electrodragon.com/product/wifi-iot-relay-board-based-esp8266/| +|Build flag|ESP_RELAY_BOARD| + +### Flashing + +![Electrodragon ESP Relay Board - Front view](images/electrodragon-flash.jpg) + +The Electrodragon ESP Relay Board is pretty easy to flash IF you do not follow their wiki, it's all wrong. Check the picture above and note that: + +* Power the board from the 5V pin, GND to GND +* The RX pin in the header should go to your programmer TX pin and +* The TX pin in the header should go to your programmer RX pin +* The button labeled BTN2 is connected to GPIO0, so hold it down while powering the board, I've had better results keeping it down until the flashing starts + + [1]: https://www.itead.cc/sonoff-wifi-wireless-switch.html [2]: https://www.itead.cc/sonoff-rf.html [2]: https://www.itead.cc/sonoff-th.html diff --git a/docs/Troubleshooting.md b/docs/Troubleshooting.md index 61e76720..4e318157 100644 --- a/docs/Troubleshooting.md +++ b/docs/Troubleshooting.md @@ -1,5 +1,13 @@ # Troubleshooting +## Problems resetting the board + After flashing the firmware via serial do a hard reset of the device (unplug & plug). There is an issue with the ESP.reset() method. Check [https://github.com/esp8266/Arduino/issues/1017][1] for more info. +## Can't find espresiff8266_stage platform + +The fauxmoESP library requires the staging version of Arduino Core for ESP8266. Either you are using Arduino IDE or PlatformIO you will have to manually install this. Check the [documentation for the fauxmoESP library][2] for more info. + + [1]: https://github.com/esp8266/Arduino/issues/1017 +[2]: https://bitbucket.org/xoseperez/fauxmoesp diff --git a/docs/images/electrodragon-flash.jpg b/docs/images/electrodragon-flash.jpg new file mode 100644 index 00000000..b440bbdd Binary files /dev/null and b/docs/images/electrodragon-flash.jpg differ diff --git a/docs/images/sonoff-dual-flash.jpg b/docs/images/sonoff-dual-flash.jpg new file mode 100644 index 00000000..93dd3c70 Binary files /dev/null and b/docs/images/sonoff-dual-flash.jpg differ