@ -1,21 +0,0 @@ | |||
# Configuration | |||
*TODO* | |||
## First boot | |||
On normal boot (i.e. button not pressed) it will execute the firmware. It configures the hardware (button, LED, relay), the SPIFFS memory access, the WIFI, the WebServer and MQTT connection and whatever other enabled modules. | |||
Obviously the default values for WIFI network and MQTT will probably not match your requirements. The device will start in Soft AP creating a WIFI SSID named "DEVICE_XXXXXX", where DEVICE will be an identifier of your device and XXXXXX are the last 3 bytes of the radio MAC. Connect with phone, PC, laptop, whatever to that network, password is "fibonacci". Once connected browse to 192.168.4.1. It will then present an **authentication challenge**. Default user and password are "admin" and "fibonacci" (again). Then you will be presented a configuration page where you will be able to define different configuration parameters, including changing the default password. The same password is used for the WIFI Access Point, for the web interface and for the OTA firmware upload. | |||
## WiFi configuration | |||
You can configure up to three WIFI networks. It will then try to connect to the configure WIFI networks in order of signal strength. If none of the 3 attempts succeed it will default to SoftAP mode again. You can also switch to SoftAP mode by double click the on-board button or reset the board long clicking it. | |||
## MQTT | |||
Once connected to an access point (so in station mode) the board will try to connect the MQTT server defined. | |||
The device will publish the relay state to the given topic and it will subscribe to the same topic for remote switching. Don't worry, it avoids infinite loops. | |||
You can also use "{identifier}" as place holder in the topic. It will be translated to your device ID (same as the soft AP network it creates). |
@ -1,77 +0,0 @@ | |||
# Filesystem | |||
## Introduction | |||
Normally when you flash an ESP8266 you only flash the firmware, like for any other microcontroller. But the ESP8266 has plenty of room and normally it is split into different partitions. One such partition is used to store web files like a normal webserver. | |||
Problem is that, even thou the ESP8266 is a very capable microcontroller it has its limitations and does not handle very well concurrent connections. This is specially true for the *default* webserver that comes with the Arduino Core for ESP8266. | |||
On the other side, to provide a good user experience and work with a comfortable development environment you end up having different files: scripts, stylesheet files, images,... The browser will load the index.html file and quickly request for all those other files and the ESP8266 will easily struggle trying to serve them all. | |||
So the trick here is to squeeze them all into one single compressed file just before uploading it. Luckily, we can do that automatically. | |||
## Web interface build process | |||
The build process reads the HTML files, looks for the stylesheet and script files linked there, grabs them, minifies them and includes them inline, in the same order they are loaded. The resulting single HTML file is then cleaned, further minified and compressed resulting in a single index.html.gz file. This way the ESP8266 webserver can serve it really fast. | |||
To build this file we are using **[Gulp][1]**, a build system built in [node.js][2]. So you will need node (and [npm][3], its package manager) first. [Read the documentation][4] on how to install them. | |||
Once you have node and npm installed, go to the 'code' folder and install all the dependencies with: | |||
``` | |||
npm install | |||
``` | |||
It will take a minute or two. Then you are ready to build the webserver files with: | |||
``` | |||
gulp | |||
``` | |||
It will create a populate a 'data' folder with all the required files. | |||
## Images | |||
Along with the HTML, CSS and JS files compressed into the index.html.gz file, the ESPurna firmware uses some images in its web interface. These are the favicon.ico file and a **sprite** for the iPhone style buttons in the interface. Again the idea is to use the minimum possible number of files. | |||
## Flashing it | |||
### Using PlatformIO | |||
[PlatformIO][5] allows the developer to define hooks to be executed before or after certain actions. This is really cool since we can plug one such hook to the *uploadfs* target to automatically build the web interface before uploading it to the board. | |||
This is done by specifying the script with the hook definitions in the *extra_script* option in the platformio.ini file. The script, written in python, binds the target file (spiffs.bin) to a method that executes the gulp command we have seen before. | |||
``` | |||
#!/bin/python | |||
from SCons.Script import DefaultEnvironment | |||
env = DefaultEnvironment() | |||
def before_build_spiffs(source, target, env): | |||
env.Execute("gulp buildfs") | |||
env.AddPreAction(".pioenvs/%s/spiffs.bin" % env['PIOENV'], before_build_spiffs) | |||
``` | |||
The included platformio.ini file has all this already configured, so you don't have to worry about it. Just type: | |||
``` | |||
pio run -t uploadfs -e sonoff | |||
``` | |||
(or whatever other enviroment) and you are good to go. | |||
### Using Arduino IDE | |||
First you will have to manually build the data folder contents using gulp (see [instructions above](#web-interface-build-process)). | |||
Then you will have to have the "[ESP8266 Sketch Data Upload][6]" utility installed. Check the instructions in the previous link. The data folder should be a subfolder of the code folder for the tool to find it. Then just execute it and it will upload the data folder contents to your board. | |||
[1]: http://gulpjs.com/ | |||
[2]: https://nodejs.org/en/ | |||
[3]: https://www.npmjs.com/ | |||
[4]: https://docs.npmjs.com/getting-started/installing-node | |||
[5]: http://www.platformio.org | |||
[6]: https://github.com/esp8266/Arduino/blob/master/doc/filesystem.md#uploading-files-to-file-system |
@ -1,56 +0,0 @@ | |||
# Firmware | |||
## Build the firmware | |||
The project is ready to be build using [PlatformIO][1]. | |||
Please refer to their web page for instructions on how to install the builder. | |||
If you are using PlatformIO /strongly recommended) it will take care of the library dependencies. Otherwise you will have to install them manually: | |||
* Benoit Blanchon's [ArduinoJson](https://github.com/bblanchon/ArduinoJson) | |||
* Hristo Gochkov's [ESPAsyncTCP](https://github.com/me-no-dev/ESPAsyncTCP) | |||
* Hristo Gochkov's [ESPAsyncUDP](https://github.com/me-no-dev/ESPAsyncUDP) | |||
* Hristo Gochkov's [ESPAsyncWebServer](https://github.com/me-no-dev/ESPAsyncWebServer) | |||
* 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) | |||
* Randy Simons' [RemoteSwitch](https://github.com/jccprj/RemoteSwitch-arduino-library) (required if using custom RF module: -DENABLE_RF) | |||
And my own libraries: | |||
* [JustWifi](https://bitbucket.org/xoseperez/justwifi.git) | |||
* [FauxmoESP](https://bitbucket.org/xoseperez/fauxmoesp.git) (required if compiling with WeMo emulation support: -DENABLE_FAUXMO) | |||
* [HLW8012](https://bitbucket.org/xoseperez/hlw8012.git) (required if compiling for Sonoff POW: -DENABLE_POW) | |||
* [EmonLiteESP](https://bitbucket.org/xoseperez/emonliteesp.git) (required if compiling with Energy Monitoring support: -DENABLE_EMON) | |||
* [NoFUSS](https://bitbucket.org/xoseperez/nofuss.git) (required if compiling with NoFUSS Automatic OTA support: -DENABLE_NOFUSS) | |||
**Note**: 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](https://bitbucket.org/xoseperez/fauxmoesp) for more info. | |||
Once you have all the code, you can check if it's working by: | |||
```bash | |||
> pio run -e node-debug | |||
``` | |||
If it compiles you are ready to flash the firmware. | |||
## Flash your board | |||
Wire your board (check the [Hardware page](Hardware.md)) and flash the firmware (with ```upload```): | |||
```bash | |||
> pio run -t upload -e sonoff | |||
``` | |||
(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. | |||
Once the firmware is uploaded next step is to upload the web interface. Check how to [build and flash the filesystem](Filesystem.md). | |||
[1]: http://www.platformio.org |
@ -1,216 +0,0 @@ | |||
# Supported Hardware | |||
This is the official list of supported hardware for the ESPurna firmware. The hardware configuration for each of these boards can be selected by supplying the build flag (see [Firmware section](Firmware.h)). | |||
**CAUTION: Never ever connect any of these devices to your computer and to mains at the same time. Never ever manipulate them while connected to mains. Seriously. I don't want you to die. I hold no responsibility for any damage to you, your family, your house,... for any action or results derived from flashing or using these devices.** | |||
* [IteadStudio Sonoff](#iteadstudio-sonoff) | |||
* [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 Sonoff TOUCH](#iteadstudio-sonoff-touch) | |||
* [IteadStudio Sonoff 4CH](#iteadstudio-sonoff-4ch) | |||
* [IteadStudio Sonoff SV](#iteadstudio-sonoff-sv) | |||
* [IteadStudio Slampher](#iteadstudio-slampher) | |||
* [IteadStudio S20](#iteadstudio-s20) | |||
* [Electrodragon ESP Relay Board](#electrodragon-esp-relay-board) | |||
* [WorkChoice EcoPlug](#workchoice-ecoplug) | |||
## IteadStudio Sonoff | |||
|Property|Value| | |||
|---|---| | |||
|Manufacturer|Itead Studio| | |||
|Web page|[https://www.itead.cc/sonoff-wifi-wireless-switch.html](https://www.itead.cc/sonoff-wifi-wireless-switch.html)| | |||
|Build flag|SONOFF| | |||
The [IteadStudio Sonoff][1] has an ESP8266 on board with a 8Mbit flash memory chip, a mains to 3V3 transformer and a relay (GPIO12). It also features a button (GPIO0), an LED (GPIO13) and an unpopulated header you can use to reprogram it. | |||
### Flashing | |||
![Sonoff - Inside front view](images/sonoff-flash.jpg) | |||
The unpopulated header in the Sonoff has all the required pins. My board has a 5 pins header in-line with the button. They are (from the button outwards) 3V3, RX, TX, GND and GPIO14. | |||
Last one is not necessary. Mind it's a **3V3 device**, if connected to 5V you will probably fry it. Button is connected to GPIO0 on the ESP8266 chip, so to enter flash mode you have to hold the button pressed while powering on the board, then you can release it again. | |||
## IteadStudio Sonoff RF | |||
|Property|Value| | |||
|---|---| | |||
|Manufacturer|Itead Studio| | |||
|Web page|[https://www.itead.cc/sonoff-rf.html][2]| | |||
|Build flag|SONOFF_RF| | |||
### Flashing | |||
![Sonoff POW - Inside back view](images/sonoff-rf-flash.jpg) | |||
The Sonoff RF has the same unpopulated header as the Sonoff. It is a 5 pins header in-line with the button. They are (from the button outwards) 3V3, RX, TX, GND and GPIO14. | |||
Solder a male or female header here and connect your USB-to-UART programmer (remember **it's a 3V3 device**). This time through **the button is not connected to GPIO0** but to a EFM8BB1 microcontroller that also monitors the RF module output. | |||
There are a couple of ways to enter flash mode. Some recommend to move 0Ohm R9 resistor to R21 to connect the button directly to the ESP8266 GPIO0 and use it in the same way as for the Sonoff or Sonoff TH. The drawback is the by doing that you lose the RF capability. | |||
My recommendation is to **temporary shortcut the bottom pad of the unpopulated R21 footprint** (see the image above) and connect your USB-to-UART board at the same time. You will have to do it just once (unless there is something really wrong in the firmware) and use OTA updates from there on. | |||
## IteadStudio Sonoff TH | |||
|Property|Value| | |||
|---|---| | |||
|Manufacturer|Itead Studio| | |||
|Web page|[https://www.itead.cc/sonoff-th.html](https://www.itead.cc/sonoff-th.html)| | |||
|Build flag|SONOFF_TH| | |||
### Flashing | |||
![Sonoff TH - Inside back view](images/sonoff-th-flash.jpg) | |||
You have all the required pins in an unpopulated header in one of the corners of the board (see top left corner in the image above). Solder a 4 pins male or female header here and connect it to your favourite USB-to-UART module. Remember: **it's a 3V3 device**!!. | |||
As in the Sonoff the button is connected to GPIO0, so to enter flash mode press and hold the button and connect the programmer to your computer to power the board. | |||
## IteadStudio Sonoff POW | |||
|Property|Value| | |||
|---|---| | |||
|Manufacturer|Itead Studio| | |||
|Web page|[https://www.itead.cc/sonoff-pow.html](https://www.itead.cc/sonoff-pow.html)| | |||
|Build flag|SONOFF_POW| | |||
### Flashing | |||
![Sonoff POW - Inside back view](images/sonoff-pow-flash.jpg) | |||
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](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 Sonoff TOUCH | |||
|Property|Value| | |||
|---|---| | |||
|Manufacturer|Itead Studio| | |||
|Web page|[https://www.itead.cc/sonoff-touch.html](https://www.itead.cc/sonoff-touch.html)| | |||
|Build flag|SONOFF_TOUCH| | |||
### Flashing | |||
*TODO* | |||
## IteadStudio Sonoff 4CH | |||
|Property|Value| | |||
|---|---| | |||
|Manufacturer|Itead Studio| | |||
|Web page|[https://www.itead.cc/sonoff-4ch.html](https://www.itead.cc/sonoff-4ch.html)| | |||
|Build flag|SONOFF_4CH| | |||
### Flashing | |||
*TODO* | |||
## IteadStudio Sonoff SV | |||
|Property|Value| | |||
|---|---| | |||
|Manufacturer|Itead Studio| | |||
|Web page|[https://www.itead.cc/sonoff-sv.html](https://www.itead.cc/sonoff-sv.html)| | |||
|Build flag|SONOFF_SV| | |||
### Flashing | |||
*TODO* | |||
## IteadStudio Slampher | |||
|Property|Value| | |||
|---|---| | |||
|Manufacturer|Itead Studio| | |||
|Web page|[https://www.itead.cc/slampher.html](https://www.itead.cc/slampher.html)| | |||
|Build flag|SLAMPHER| | |||
### Flashing | |||
![Slampher - Inside front view](images/slampher-flash1.jpg) | |||
![Slampher - Flashing short](images/slampher-flash2.jpg) | |||
There is a 4 pin unpopulated header in a border near the ESP8266 chip. Starting form the little white mark this header brings out 3V3, RX, TX and GND. Solder a male or female header here and connect your USB-to-UART programmer (remember it's a 3V3 device). This time through **the button is not connected to GPIO0** but to a EFM8BB1 microcontroller that also monitors the RF module output. | |||
There are a couple of ways to enter flash mode. Some recommend to move R21 to R20 (at the top right of the first picture above) to connect the button directly to the ESP8266 GPIO0 and use it in the same way as for the Sonoff or Sonoff TH. The drawback is the by doing that you lose the RF capability. | |||
My recommendation is to **temporary shortcut the right pad of the unpopulated R20 footprint** (see second image above) and connect your USB-to-UART board at the same time. You will have to do it just once (unless there is something really wrong in the firmware) and use OTA updates from there on. | |||
## IteadStudio S20 Smart Socket | |||
|Property|Value| | |||
|---|---| | |||
|Manufacturer|Itead Studio| | |||
|Web page|[https://www.itead.cc/smart-socket.html](https://www.itead.cc/smart-socket.html)| | |||
|Build flag|S20| | |||
### Flashing | |||
![S20 Smart Socket - Inside front view](images/s20-flash.jpg) | |||
There is a labeled header in the front of the PCB and the button is connected to GPIO0, so no problems here. | |||
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/](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 | |||
## WorkChoice EcoPlug | |||
|Property|Value| | |||
|---|---| | |||
|Manufacturer|WorkChoice| | |||
|Web page (non-official)|[http://thegreatgeekery.blogspot.com.es/2016/02/ecoplug-wifi-switch-hacking.html](http://thegreatgeekery.blogspot.com.es/2016/02/ecoplug-wifi-switch-hacking.html)| | |||
|Build flag|ECOPLUG| | |||
### Flashing | |||
*TODO* | |||
[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 | |||
[4]: https://www.itead.cc/sonoff-pow.html | |||
[5]: https://www.itead.cc/slampher.html | |||
[6]: https://www.itead.cc/smart-socket.html |
@ -1,28 +0,0 @@ | |||
# Over-the-air updates | |||
## Manually driven OTA updates | |||
Once you have flashed your board with the ESPurna firmware you can flash it again over-the-air using PlatformIO and the ```ota``` environment: | |||
```bash | |||
> pio run -t upload -e node-debug-ota | |||
> pio run -t uploadfs -e node-debug-ota | |||
``` | |||
When using OTA environment it defaults to the IP address of the device in SoftAP mode. If you want to flash it when connected to your home network best way is to supply the IP of the device: | |||
```bash | |||
> pio run -t upload -e node-debug-ota --upload-port 192.168.1.151 | |||
> pio run -t uploadfs -e node-debug-ota --upload-port 192.168.1.151 | |||
``` | |||
Please note that if you have changed the admin password from the web interface you will have to change it too in the platformio.ini file for the OTA to work. Check for the *upload_flags* option in your ota-enabled environment. | |||
## Automatic OTA updates | |||
You can also use the automatic OTA update feature. Check the [NoFUSS library][6] for more info. | |||
This options is disabled by default. Enable it in your firmware with the -DENABLE_FUSS build flag. | |||
[6]: https://bitbucket.org/xoseperez/nofuss |
@ -1,3 +0,0 @@ | |||
# Sensors | |||
*TODO* |
@ -1,13 +0,0 @@ | |||
# 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 |