ITEAD Studio Sonoff family is comprised of various inexpensive ESP8266 WiFi power switch, and the company sent me two of their latest CE certified models with Sonoff TH16 + external temperature & humidity probe, and Sonoff POW to measure power consumption. I checked the hardware is the first part of the review, and used Sonoff TH16 to control a water pump with the stock firmware and Ewelink Android app in the second part. It works reasonably well, but it relies on the cloud, so if you lose your Internet connection or the service closed, you can’t control the relay manually anymore. Luckily, the UART pins are exposed on Sonoff switches so you can solder a 4-pin header and connect a USB to TTL to flash your own firmware.
Please don’t connect Sonoff devices to the mains when programming them, it’s very dangerous, instead the USB to TTL board will power the system, and will allow you to program the board safely. Later you’ll be able to update the firmware, if needed, over the network.
The next step is to select the firmware you want to use, and I’ve been advised two firmware for ESP8266, namely ESPurna specifically designed for Sonoff devices, and ESPEasy with a larger community of users. The latter may be usable to control the relay, but it has yet to support HLW8012 chip used to measure power consumption in Sonoff POW, so I decided to go with ESPurna.
That’s the description of the firmware from its bitbucket page:
ESPurna (“spark” in Catalan) is a custom C firmware for ESP8266 based smart switches. It was originally developed with the ITead Sonoff in mind. Features:
- Asynchronous WebServer for configuration and simple relay toggle with basic authentication
- Communication between webserver and webclient via websockets with secure ticket check
- Flashing firmware Over-The-Air (OTA)
- Up to 3 configurable WIFI networks, connects to the strongest signal
- MQTT support with configurable host and topic
- 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)
- 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
- Support for DHT22 sensors
- Support for the HLW8012 power sensor present in the Sonoff POW
- Support for current monitoring through the EmonLiteESP Library using a non-intrusive current sensor (requires some hacking)
- Command line configuration
I could not find firmware release for ESPurna, but Xose Pérez – the developer – has provided some basic instructions to build and flash the firmware to Sonoff. Those are not really detailed however, and it took me nearly a full day to successfully build and flash the firmware to Sonoff POW, mostly because I was not quite familiar with most of the tools used. So I’ve reproduced the step I went through in Ubuntu 16.04, and hopefully this can help people getting things done more quickly.
Let’s retrieve the source code, and enter the code directory first:
1 2 3 |
sudo apt install git git clone https://bitbucket.org/xoseperez/espurna cd espurna/code |
You can build the project with PlatformIO or the Arduino IDE. The instructions are for PlatformIO so that’s what I used. There are two ways to build the code with the project wither using Platform IDE for Atom and the command line, or simply using the command line. With insights, I ended up using the command line, but I’ll show both methods.
Setup PlatformIO IDE for Atom to build ESPurna
First, you’ll need to download PlatformIO IDE for Atom for your operating systems, and install it. For Ubuntu 16.04, I selected “Download .deb” for Linux and installed it through through Ubuntu Software program. Alternatively, after download, you can install it from the command line:
1 |
sudo dpkg -i platformio-atom-linux-x86_64.deb |
You can now start Atom program in Ubuntu dash, select Open Project, and browse for espurna/code directory to load the project we’ve just gotten from Bitbucket.
The tick button on the top left corner is to build the project, and the right button just under is to upload the firmware to the target board. But if we try to build the firmware now it will fail with an error about “espressif8266_stage”. That’s because we need to install Espressif 8266 (Stage) development platform. First we need to enable Developer mode in the IDE by going to the top menu to select PlatformIO->Settings->PlatformIO IDE, and checking “Use development version of PlatformIO“.
Now install PlatformIO shell commands from either a system Terminal, or PlatformIO IDE terminal (PlatformIO->Terminal->New Terminal):
1 2 |
sudo ln -s /home/jaufranc/.atom/packages/platformio-ide/penv/bin/platformio /usr/local/bin/platformio sudo ln -s /home/jaufranc/.atom/packages/platformio-ide/penv/bin/pio /usr/local/bin/pio |
and finally install ESP8266 development platform:
1 |
platformio platform install https://github.com/platformio/platform-espressif8266.git#feature/stage |
At this point you can click on the tick icon to build the default “node-debug” environment, a build output window will show in the IDE, and quickly disappear if the build is successful.
Setup PlatformIO via Command Line to Build ESPurna
If instead we want to use the command line we can install the latest pip version, the developer version of PlatformIO, and the staging version of ESP8266 development platform:
1 2 3 4 |
sudo apt install python-pip sudo pip install --upgrade pip sudo pip install -U https://github.com/platformio/platformio/archive/develop.zip platformio platform install https://github.com/platformio/platform-espressif8266.git#feature/stage |
You can check the build environment is set properly by running the following command in espurna/code directory:
1 |
pio run -e node-debug |
It will automatically download, build and install all dependencies and build for “node-debug” firmware for NodeMCU board. If it is successful, it will end as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
Linking .pioenvs/node-debug/firmware.elf Calculating size .pioenvs/node-debug/firmware.elf text data bss dec hex filename 377725 12108 31520 421353 66de9 .pioenvs/node-debug/firmware.elf Building .pioenvs/node-debug/firmware.bin ========================= [SUCCESS] Took 91.20 seconds ========================= ================================== [SUMMARY] ================================== Environment node-debug [SUCCESS] Environment node-debug-ota [SKIP] Environment sonoff-debug [SKIP] Environment sonoff-debug-ota [SKIP] Environment sonoff-pow-debug [SKIP] Environment sonoff-pow-debug-ota [SKIP] Environment slampher-debug [SKIP] Environment slampher-debug-ota [SKIP] Environment s20-debug [SKIP] Environment s20-debug-ota [SKIP] Environment ac-device [SKIP] Environment washer-device [SKIP] Environment studio-lamp-device [SKIP] Environment living-lamp-device [SKIP] ========================= [SUCCESS] Took 91.21 seconds ========================= |
So I find the command line option much more easy and straightforward.
Build ESPurna for Sonoff POW
However, we are not using NodeMCU board here, but Sonoff POW, and there are two environments defined just for that:
- sonoff-pow-debug – Build firmware to flash over serial
- sonoff-pow-debug-ota – Build OTA firmware to upgrade the firmware over the network
The parameters for each environment are all defined in platformio.ini. First we need to build sonoff-pow-debug environment:
1 |
pio run -e sonoff-power-debug |
But it failed with an error message related to hlw8012 library:
1 2 3 4 5 |
Compiling .pioenvs/sonoff-pow-debug/FrameworkArduino/Stream.o /media/hdd/edev/esp8266/sonoff/espurna/code/src/pow.ino:13:21: fatal error: HLW8012.h: No such file or directory #include <HLW8012.h> ^ compilation terminated. |
I reported the issue on Bitbucket, but the main developer could not reproduce the issue. Eventually I found out that it could be a PlatformIO bug, as the system does not recursively checking for includes outside of main.ino. So I added <hlw8012.h> in the main.ino as follows:
1 2 3 4 5 |
#include <Arduino.h> #include "config/all.h" #ifdef SONOFF_POW #include <HLW8012.h> #endif |
and the build could complete:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
pio run -e sonoff-power-debug [Sat Dec 3 10:27:22 2016] Processing sonoff-pow-debug (build_flags: -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF_POW, lib_deps: DHT sensor library, Adafruit Unified Sensor, Time, ArduinoJson, ESPAsyncTCP, ESPAsyncWebServer, AsyncMqttClient, ESPAsyncUDP, Embedis, NtpClientLib, OneWire, DallasTemperature, https://bitbucket.org/xoseperez/justwifi.git, https://bitbucket.org/xoseperez/nofuss.git, https://bitbucket.org/xoseperez/hlw8012.git, https://bitbucket.org/xoseperez/emonliteesp.git, https://bitbucket.org/xoseperez/fauxmoESP.git, https://github.com/jccprj/RemoteSwitch-arduino-library, lib_ignore: FauxmoESP, ESPAsyncUDP, platform: espressif8266, board: esp01_1m, framework: arduino, extra_script: pio_hooks.py) .... Linking .pioenvs/sonoff-pow-debug/firmware.elf Calculating size .pioenvs/sonoff-pow-debug/firmware.elf text data bss dec hex filename 347600 10284 31296 389180 5f03c .pioenvs/sonoff-pow-debug/firmware.elf Building .pioenvs/sonoff-pow-debug/firmware.bin ========================= [SUCCESS] Took 3.49 seconds ========================= ================================== [SUMMARY] ================================== Environment node-debug [SKIP] Environment node-debug-ota [SKIP] Environment sonoff-debug [SKIP] Environment sonoff-debug-ota [SKIP] Environment sonoff-pow-debug [SUCCESS] Environment sonoff-pow-debug-ota [SKIP] Environment slampher-debug [SKIP] Environment slampher-debug-ota [SKIP] Environment s20-debug [SKIP] Environment s20-debug-ota [SKIP] Environment ac-device [SKIP] Environment washer-device [SKIP] Environment studio-lamp-device [SKIP] Environment living-lamp-device [SKIP] ========================= [SUCCESS] Took 3.49 seconds ========================= |
Since we’ve already changed the code, you may also consider changing “#define ADMIN_PASS fibonacci” in code/src/config/general.h to use a different default password. The password can also be changed in the web interface, but this makes sure you won’t have a device somewhere with the default password common to most users.
Flashing Firmware to Sonoff POW
Now that we’ve made sure the firmware could build, it’s time to flash it to the device.
First we need to setup some udev rules to allow flashing over serial:
1 2 |
sudo wget https://raw.githubusercontent.com/platformio/platformio/develop/scripts/99-platformio-udev.rules -O /etc/udev/rules.d/99-platformio-udev.rules sudo service udev restart |
Now connect the USB to TTL to a USB port on your computer, press the button (connected to GPIO0) on Sonoff POW for several seconds until both LEDs are off to make sure you are in bootloader mode, and start flashing with:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
pio run -t upload -e sonoff-pow-debug [Sat Dec 3 11:42:13 2016] Processing sonoff-pow-debug (build_flags: -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF_POW, lib_deps: DHT sensor library, Adafruit Unified Sensor, Time, ArduinoJson, ESPAsyncTCP, ESPAsyncWebServer, AsyncMqttClient, ESPAsyncUDP, Embedis, NtpClientLib, OneWire, DallasTemperature, https://bitbucket.org/xoseperez/justwifi.git, https://bitbucket.org/xoseperez/nofuss.git, https://bitbucket.org/xoseperez/hlw8012.git, https://bitbucket.org/xoseperez/emonliteesp.git, https://bitbucket.org/xoseperez/fauxmoESP.git, https://github.com/jccprj/RemoteSwitch-arduino-library, lib_ignore: FauxmoESP, ESPAsyncUDP, platform: espressif8266, board: esp01_1m, framework: arduino, extra_script: pio_hooks.py) -------------------------------------------------------------------------------- Verbose mode can be enabled via `-v, --verbose` option Converting main.ino Collected 41 compatible libraries Looking for dependencies... Library Dependency Graph |-- <DHT sensor library> v1.3.0 | |-- <Adafruit Unified Sensor> v1.0.2 | | |-- <WProgram> | |-- <WProgram> |-- <Adafruit Unified Sensor> v1.0.2 | |-- <WProgram> |-- <Time> v1.5 | |-- <WProgram> |-- <ArduinoJson> v5.7.2 |-- <ESPAsyncTCP> v1.0.0 |-- <ESPAsyncWebServer> | |-- <ESPAsyncTCP> v1.0.0 | |-- <ArduinoJson> v5.7.2 | |-- <ESP8266WiFi> v1.0 | |-- <Hash> v1.0 |-- <AsyncMqttClient> v0.5.0 | |-- <ESPAsyncTCP> v1.0.0 |-- <Embedis> v1.2.0 |-- <NtpClientLib> | |-- <WProgram> | |-- <Time> v1.5 | | |-- <WProgram> | |-- <ESP8266WiFi> v1.0 |-- <OneWire> v2.3.2 | |-- <WProgram> |-- <DallasTemperature> v3.7.7 | |-- <OneWire> v2.3.2 | | |-- <WProgram> |-- <Hash> v1.0 |-- <JustWifi> v1.1.0 | |-- <ESP8266WiFi> v1.0 |-- <ESP8266WiFi> v1.0 |-- <ESP8266mDNS> | |-- <ESP8266WiFi> v1.0 |-- <HLW8012> v0.1.0 |-- <DebounceEvent> |-- <EEPROM> v1.0 |-- <ArduinoOTA> v1.0 | |-- <ESP8266WiFi> v1.0 | |-- <ESP8266mDNS> | | |-- <ESP8266WiFi> v1.0 Compiling .pioenvs/sonoff-pow-debug/src/main.ino.o Looking for upload port... Auto-detected: /dev/ttyUSB0 Uploading .pioenvs/sonoff-pow-debug/firmware.bin Uploading 362032 bytes from .pioenvs/sonoff-pow-debug/firmware.bin to flash at 0x00000000 ................................................................................ [ 22% ] ................................................................................ [ 45% ] ................................................................................ [ 67% ] ................................................................................ [ 90% ] .................................. [ 100% ] ========================= [SUCCESS] Took 41.19 seconds ========================= ================================== [SUMMARY] ================================== Environment node-debug [SKIP] Environment node-debug-ota [SKIP] Environment sonoff-debug [SKIP] Environment sonoff-debug-ota [SKIP] Environment sonoff-pow-debug [SUCCESS] Environment sonoff-pow-debug-ota [SKIP] Environment slampher-debug [SKIP] Environment slampher-debug-ota [SKIP] Environment s20-debug [SKIP] Environment s20-debug-ota [SKIP] Environment ac-device [SKIP] Environment washer-device [SKIP] Environment studio-lamp-device [SKIP] Environment living-lamp-device [SKIP] ========================= [SUCCESS] Took 41.19 seconds ========================= |
Success! Great. If you have your own firmware to flash it may be useful to know the actual command used to flash the firmware was:
1 |
esptool -vv -cd ck -cb 115200 -cp "/dev/ttyUSB0" -cf .pioenvs/sonoff-pow-debug/firmware.bin |
Building and Flashing the ESPurna filesystem
Wait! We’ve just flashed the firmware, isn’t it all? Nope, as the webserver files are stored in another partitions, and compressed in a single index.html.gz file for better performance. The exact reasons why are further explained here.
We’ll need Node.js and gulp command line client:
1 2 3 |
sudo apt install npm nodejs nodejs-legacy sudo npm install npm@latest -g sudo npm install --global gulp-cli |
Now inside espurna/code folder , we can check if building the file systems works with two commands:
1 2 |
npm install gulp |
Here my successful gulp attempt:
1 2 3 4 5 6 7 8 9 10 11 |
[17:18:02] Using gulpfile ~/edev/espurna/code/gulpfile.js [17:18:02] Starting 'clean'... [17:18:02] Finished 'clean' after 4.83 ms [17:18:02] Starting 'files'... [17:18:02] Starting 'inline'... [17:18:06] Finished 'files' after 3.59 s [17:18:06] Finished 'inline' after 3.59 s [17:18:06] Starting 'buildfs'... [17:18:06] Finished 'buildfs' after 151 μs [17:18:06] Starting 'default'... [17:18:06] Finished 'default' after 22 μs |
Finally, we can run the following (which also runs the two commands above) to flash the file system to the board, after entering bootloader mode by pressing the button:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
pio run -t uploadfs -e sonoff-pow-debug [Sat Dec 3 12:12:07 2016] Processing sonoff-pow-debug (build_flags: -g -Wl,-Tesp8266.flash.1m256.ld -DDEBUG_PORT=Serial -DSONOFF_POW, lib_deps: DHT sensor library, Adafruit Unified Sensor, Time, ArduinoJson, ESPAsyncTCP, ESPAsyncWebServer, AsyncMqttClient, ESPAsyncUDP, Embedis, NtpClientLib, OneWire, DallasTemperature, https://bitbucket.org/xoseperez/justwifi.git, https://bitbucket.org/xoseperez/nofuss.git, https://bitbucket.org/xoseperez/hlw8012.git, https://bitbucket.org/xoseperez/emonliteesp.git, https://bitbucket.org/xoseperez/fauxmoESP.git, https://github.com/jccprj/RemoteSwitch-arduino-library, lib_ignore: FauxmoESP, ESPAsyncUDP, platform: espressif8266, board: esp01_1m, framework: arduino, extra_script: pio_hooks.py) -------------------------------------------------------------------------------- Verbose mode can be enabled via `-v, --verbose` option before_build_spiffs([".pioenvs/sonoff-pow-debug/spiffs.bin"], ["data"]) gulp buildfs [12:12:07] Using gulpfile /media/hdd/edev/esp8266/sonoff/espurna/code/gulpfile.js [12:12:07] Starting 'clean'... [12:12:08] Finished 'clean' after 4.5 ms [12:12:08] Starting 'files'... [12:12:08] Starting 'inline'... [12:12:10] Finished 'files' after 2.98 s [12:12:10] Finished 'inline' after 2.98 s [12:12:10] Starting 'buildfs'... [12:12:10] Finished 'buildfs' after 94 μs Building SPIFFS image from 'data' directory to .pioenvs/sonoff-pow-debug/spiffs.bin /index.html.gz /images/check.png /favicon.ico /fsversion Looking for upload port... Auto-detected: /dev/ttyUSB0 Uploading .pioenvs/sonoff-pow-debug/spiffs.bin Uploading 262144 bytes from .pioenvs/sonoff-pow-debug/spiffs.bin to flash at 0x000BB000 ................................................................................ [ 31% ] ................................................................................ [ 62% ] ................................................................................ [ 93% ] ................ [ 100% ] ========================= [SUCCESS] Took 31.08 seconds ========================= ================================== [SUMMARY] ================================== Environment node-debug [SKIP] Environment node-debug-ota [SKIP] Environment sonoff-debug [SKIP] Environment sonoff-debug-ota [SKIP] Environment sonoff-pow-debug [SUCCESS] Environment sonoff-pow-debug-ota [SKIP] Environment slampher-debug [SKIP] Environment slampher-debug-ota [SKIP] Environment s20-debug [SKIP] Environment s20-debug-ota [SKIP] Environment ac-device [SKIP] Environment washer-device [SKIP] Environment studio-lamp-device [SKIP] Environment living-lamp-device [SKIP] ========================= [SUCCESS] Took 31.08 seconds ========================= |
Now that’s done.
A Quick look at ESPurna Web Interface
ESPurna firmware and filesystem has now been flashed to Sonoff POW. But does it work?
I can see a new SONOFF_POW_XXXXX access point, so that does look good. I can connect using the default password “fibonacci”, then go to my web browser to access http://192.168.4.1, and login again with admin/fibonacci credentials.
ESPURNA 1.03 interface goes to the status menu first, and there I can turn on and off the relay remotely, and check the power consumption in watts, which remains at 0 watt since I have not connected it to the mains yet. It’s also possible to turn the relay on and off with the button, and there an option to select whether to turn on or off the relay at boot time, which is great since I need it on at all times.
The web interface also allows you to change general parameters including the hostname and password, as well as enable or disable the HTTP API (disabled by default). The WiFi section is used to connect to up to 3 wireless routers, the MQTT section lets you configure an MQTT (Mosquito) broker, and the power section is used to calibrate the power monitoring device.
If you just intend to check the current power consumption and turn on and off the switch with your phone, you don’t have to do anything else. But I’d like to find some ways to draw daily, weekly, monthly charts of my office power consumption using either MQTT or the HTTP API. I’ll have to study how to do that, and that will hopefully be the topic of my next post about Sonoff POW.
Sonoff POW can be purchased on ITEAD Studio for $10.50 plus shipping, but is currently out of stock with the company manufacturing a third batch soon.
Jean-Luc started CNX Software in 2010 as a part-time endeavor, before quitting his job as a software engineering manager, and starting to write daily news, and reviews full time later in 2011.
Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress
Thank you for the great report. Though I would suggest to change $ADMIN_PASS and $upload_flags (defaults to “fibonacci”) in
code/src/config/general.h
code/platformio.custom.ini
code/platformio.ini
as first step just to minimize the risk to expose another device with default logon credentials to the ‘Internet of shitty things’ 😉
So once you’ve successfully built the firmware it’s basically just connecting the various Sonoff devices to the host computer, enter flash mode and executing two commands to flash firmware and fs, right?
New devices should never be exposed to the internet until fully set up. Changes to the source code will result in them being overwritten next time you do a pull from master.
@tkaiser
I’ve added something in the tutorial about changing the default password in the code.
Yes, once you’ve done once Sonoff POW device, you can flash the others with:
If you really have many and want to speed up the process by a few second, you could instead run:
You’d still have to enter bootloader mode between each command. I wonder if there’s a way to combine both into a single command.
@cnxsoft
Regarding the password I thought it would be used in more than one location (see comment above)? Anyway: this should change it directly after checking out Xose’s repo:
The risk that an Espurna device gets compromised that way is rather low (since an attacker has to be pretty close to the device — almost physical access) but IMO it’s ‘good style’ to try to prevent any of these attacks and well known default logon credentials since nowadays connecting IoT devices to the net means that they are automagically attacked/infected seconds after (see the ‘funny’ TR-069 attacks from last weeks).
BTW: In the meantime due to insanely low priced Orange Pi Zero my interest in Sonoff devices dropped a bit but I’ll order a few of them anyway to get a clue how energy efficient they are (they should be able to beat OPi Zero’s 450mW)
Awesome. ENV vars are so the way to go
@tkaiser
The password in the ini files is for the OTA firmware. If you’ve changed the password in the firmware or in the web interface, this won’t work with the default password. So I understand you need to include the password used in Sonoff POW (which may be different from the one you set) for the OTA update to work.
Any form to flash without downloading all? And a binary :3
@Mario
Firmware and filesystem -> https://download.cnx-software.com/index.php/s/esEQuS6MUsqqszV
You can flash then with esptool as explained in the comment above.
Hi
I’m the developer. Thank you all for the great article and all your suggestions. Several things to note:
1) Using the staging version shouldn’t be necessary. The only reason it was was that the default environment had support for the fauxmoESP library, which requires the latest version of the Arduino Core for ESP8266. I have removed that requirement from the default environment.
2) I still cannot reproduce the issue you have with the HLW8018 header. It’s weird the same does not apply to other headers included from included files (like NtpClientLib, for instance). Even thou your fix did it for you I’d like to investigate a bit further first.
3) Default password topic. My idea is to force the user reset the password upon her first visit to the web interface. Would that work?
4) Binaries. I see there is a demand for that. Will create an official repository of binaries in the next few days along with the instructions to easily flash them.
As you might have noticed, even thou the documentation has been updated lately there is still a lot to do. Any suggestions will be welcome.
@Xose Pérez
Thank you for your great work on a better firmware for those devices. I think forcing a password change on first visit is ok even if it leaves the device potentially vulnerable in between (AP with known SSID and logon credentials). But that’s simply the user’s responsiblity to provide some level of physical access protection prior to password change and could be addressed with a simple sentence (in big red letters 😉 ) on download/project page.
Looking forward to play with ESPurna in 2017 🙂
@Xose Pérez
1) I had to install the staging version because the build would fail without it.
2) OK. I’ve provided more details in the issue on bitbucket. I could reproduce this in three Ubuntu 16.04 machines.
3) Looks good to me
4) If you release binaries, maybe it would be good to enable -DENABLE_FUSS so that people can get automatic firmware updates with possibly an option in the web interface to enable it (e.g. make it disable by default). Or is there an issue with the upload password (since people would use their own password)?
I’ve just been informed of another alternative firmware for Sonoff devices -> https://github.com/arendst/Sonoff-MQTT-OTA-Arduino
Does ESPurna works without the www-internet-connection, I don´t understand where the “ESPurna Web Interface” is “hosted”?
Is it correct: I don´t need a Hardware – Arduinoboard?
And Yes, a personal Password would be better.
@rebeL
The web interface is hosted in the device itself. It has a small webserver embedded. If by “www-internet-connection” you mean a “cloud”, yes, it works without internet connection. Just connect it to your local network to benefit from using it from your laptop or smartphone, MQTT, Alexa,…
I don’t know what you mean by if you need a hardware. ESPurna was coded with the Itead Sonoffs in mind but it will work with most of the ESP8266-based smarts switches out there.
@Xose Pérez
Thanks for reply. I will try it as soon as I have a USB_to_TTL adapter.
Anyone got experience of ESPurna with Domoticz?
Currently using Domoticz home automation software.
@Harley
Domoticz supports MQTT so it’s likely to work, unless there are some interoperability issues -> https://www.domoticz.com/wiki/MQTT
@cnxsoft
The MQTT message format for Domoticz is specific. Right now your best option is to “rewrite” messages back and forth from Node-RED or any other way. That’s also the approach that they suggest in that wiki page. So for instance, you will need to subscribe to “domoticz/out”, capture the messages like “{“command”: “switchscene”, “idx”: 24, “switchcmd”: “On” }” and republish to “/whatever_your_sonoff_topic>/relay/0” as either 0 or 1.
I learned something today since the SSID needs to be input manually in the web interface: SSIDs are case-sensitive…
I was wondering why it would always stay in SoftAP mode, and never switch to client mode. So now I know…
Will this work with Peter Scargill all-in-one script? It’s a raspberry pi script to install a MQTT server plus node-red? What are the directions to install this on a standard sonoff please?
@Chuxxsss
It’s quite likely to work with Peter’s software via MQTT, but interoperability would need to be tested. To build install ESPurna on Sonoff, simply replace sonoff-pow-debug by sonoff-debug in the instructions. It should even be easier since there won’t be any HW8012.h header issue.
It was my first attempt and, although I used to be a programmer, I had never used this environment before.
I did the whole procedure without a problem on a basic Sonoff.
Now I’m going to try and integrate the switch with some control software via MQTT.
Thank you!
Gianluca
Just to let you know the code builds without errors on arch linux. Platformio installed from AUR. Only one package that should be installed and is not in the dependency lis is python-setuptools from the extra-repositories.
A last thing I would ask. on the espurna bitbucket site Xose says it should be flashed with a 3,3v usb to ttl. My usb to ttl is the one a use for my dev boards (cubie, odroid). Can I use this one then before I start flashing or do I need another one?
@roel
I flashed the firmware with the USB to TTL board that came with my Cubieboard… Any USB to TTL board should do, just make sure it has 3.3V.
I flashed it with succes. To be sure I took 3,3V from my OPI-one.
One thing I had to find out was when you push the button when powering the board, you are imediately in the flashing mode. You don’t see blinking leds. If you see blinking leds, you are to late.
So you should power the board while pushing the button, release it and start flashing. The leds will not go on.
What I miss on the espurna firmware is setting switching schedules. Maybe You can do it throug the command line?
@roel
You could have a cronjob on your MQTT broker sending command through mosquitto_pub tool.
I think I will try ESP Easy, where you can set rules. Don’t know if they already support the power measurement though.
@Roel
please tell us if your tryings with ESP Easy will bring some success.
Looks like @Xose Pérez has implemented ESPurna support for Domoticz https://www.domoticz.com/forum/viewtopic.php?f=51&t=15177
Will cnx do a comparison between ESPurna and the Arendst versions, esp re: integration?
Supposedly ESPurna has more features including Alexa emulation, and Arendst is more targeted to Sonoff ?
(Scroll down to Jan 2 comments):
http://tech.scargill.net/more-from-sonoff/
Hi,
Does it work with ifttt ?
I have seen that it is emulating Belkin WeMo switch, but I am curios if someone is able to link it to ifttt?
Thank you!
@Adrian Andrei
I have no tried it yet, but since the latest firmware supports Domoticz, and I can see some people used IFTTT with Domoticz, I’m assuming this should be feasible.
@Athar
I will most probably not have time to check out Arendst firmware. The next step will probably be to install Domoticz in NanoPi NEO, learn how to use it, and set it up to get the data from Sonoff POW with ESPurna firmware.
Hi,
i build a binary from the code and flashed it to the Sonoff, that works.
I connected the WIFI Network”sonoff_xxxxx) from PC and Phone.
I got a got IP like 192.168.4.2
but after enter the “authentication challenge” admin/fibonacci i see a blank Website.
Any Idea`?
Thanks
@Harleken
This happened to me when I upgrade to ESPurna 1.4.4 and forgot to flash the file system.
So the question is have you also flashed the file system after flashing the firmware?
Binary files would be awesome :/
Using windows, and all the tutorials I find seam to use linux :/
@Ruben Tavares
If you install “Windows subsystem for Linux” in Windows 10, most of steps above can be used in Windows.
It’s possible you might need to change “/dev/ttyUSB0” to a Windows COM port instead.
Great post! I had followed it before and it worked great but when I went through it after a clean OS install I ran into a snag. The links from /usr/local/bin were broken. I didn’t have a penv folder and couldn’t figure out why. In the end the solution was simple.
I selected Install Shell Commands from the PlatformIO menu in Atom. That showed me that platformio and pio were in another location
~/.platformio/penv/bin/platformio
~/.platformio/penv/bin/pio
Hi,
I’ve no experience with electronics but I really want my Sonoff to work with Alexa Echo, how I’ll update the firmware of my Sonoff as a novice ? can I use Arduino UNO or Raspberry PI by using Arduino IDE to update firmware?
Please also suggest the best firmware and detail guide to update firmware.
Thank you
Hie,
can anyone tell me where to find and use gpio 14 on POW please? i am trying to hack a DHT22 into it to additionally get temp and humidity also. Using espurna firmware which should just pick it up from gpio14. (i tested that on sonoff basic)
@Khurram
Khurram, btw, i used a cheap FTDI like this one (http://www.ebay.co.uk/itm/Hobby-Components-UK-USB-to-serial-port-adapter-FTDI-with-3-3V-and-5V-outputs/130923180691?hash=item1e7ba13293:g:A~oAAOxyi-ZTXiu2)
you can use Arduino IDE to flash ESPURNA like i did and that has Alexa integration. just search for espurna.
@Umer
GPIO14 is not exposed on the board, you’d have to solder a wire directly to ESP8266 pin on the other side of the board.
@Harleken
What browser are you using? The webpage doesn’t load on Safari, Firefox works.