After using many packages to control Itead Sonoffs and even enjoying success with Tasmota which has Alexa compatibility, I’ve recently had a very favourable, exciting, even) experience with Xose Perez’s multi-purpose Espurna IOT firmware on some of my Sonoff power controllers.
On the subject of Amazon Alexa, SOME of my Sonoffs are working just fine with Espruino and Alexa, others not – more on that later, however I’m pleased to say that I’m enjoying great success with Node-Red-Contrib-Amazon-Echo in Node-Red so any issues with real devices and Amazon isn’t an issue – at least as far as on-off, colour and brightness is concerned.
Regular readers will know that I developed ESP-GO and usually flash either ESP-GO or Theo Arends’s Tasmota firmware onto my Itead Sonoff boards. Because of the FLASH size limitations on these Sonoffs and many similar units I’ve been gravitating towards Tasmota recently and generally it works well, controlling relays and handling MQTT communication with my Node-Red/MQTT based Raspberry Pi home control systems. I’ve been using release 6.6.0 of Tasmota since it first appeared but here we go – time for change?
I have however had some niggling issues with Tasmota. I started using it as back in my UK installation and being written in C++ and Arduino software-based, it handled hostnames on these devices no problem, something ESP-GO would not (being written in C, Espressif SDK-based). Recently in my installation in Spain, using Sonoff TH16, TH10 and DUAL devices, I could NOT get hostname resolution using Tasmota (maybe some recent changes) and also on those devices, though the latest Tasmota works including with Alexa, I’m not entirely happy about occasional temporary lock ups and minor issues talking to Alexa (certain friendly names don’t work too well)..
Hovever, Espurna and hostnames work PERFECTLY and I’m using a combination of MQTT control and the excellent Espurna web interface.
Only recently I had something of a game-changing day. I put the latest nightly build of Espurna (having read there was an Alexa issue on earlier versions of this firmware) onto all three Sonoff devices.
I have to say, in all most cases the Espurna software works reliably with Alexa but more importantly, very reliably using hostnames – the hostname lookup works a treat every time (so no more hunting around with “Advanced IP Scanner” on my PC looking for new devices recently added (never a lot of fun). I am controlling outputs, reading inputs and monitoring status on these devices easily.
And NOW as we leave Spain to head back to the UK for the winter, I’m leaving Sonoff WIFI units with ESPURNA and the built-in timing on the latter to protect my PC and WIMAX Internet access against power brownouts Installation, holding the power off for several seconds after a power cut to ensure a clean restart (I don’t have enough solar power to run all of my equipment) and setting this up was a breeze (trust me, I was ill last year and now have a memory like a sieve and less concentration than my cats), the use of Espurna contunues to be a sheer delight. I particularly like being able to add up to 5 WiFi access points based on best signal strength. My thanks to Mr Shark (Antonio) for pointing me in this direction.
What you see below is one of several web-based setup screens. They are all well done.
I will no doubt write a LOT more on this subject soon – but first I need to get Espurna installed on more devices – including Shelly and others. Being the end of summer we are leaving Southern Spain we’re heading back to the UK for the winter. I DO have a BOATLOAD of new gadgets in or arriving in the UK to write about.
I’ve been having a play…
That last function node uses one of my Node-Red global variables for time/date…
if (msg.payload==1) thecol=”red”; else thecol=”black”;
node.status({fill:thecol,shape:”dot”,text: “Relay: ” + ((msg.payload==1) ? “ON” : “OFF”) + global.get(“handyDate”)});
More on all of this later. For now, some travel.
The last release was last February but I see source changes that are most recent. Are we supposed to compile our own versions?
nightly builds are on Xose’s collaborator github: https://github.com/mcspr/espurna-nightly-builder/releases
It’s not clear from the Espurna site whether the firmware will work with a RF Bridge Version 2. There is info for v1 but that can be quite different as I know from trying to get Tasmota to work on the v2. Anyone had experience installing Espurna on the version 2? Thanks.
yes it does, i did a v1 for a friend and a v2 for me, info are quite clear: https://github.com/xoseperez/espurna/wiki/Hardware-Itead-Sonoff-RF-Bridge—Direct-Hack
I followed Espurna since the early stages the project and I like it.
I feel much more confortable developing on Espurna code-base than on Tasmota.
One interesting usage for Espurna is as a “base OS” where Espurna includes the bare minimum, so I can build up my very specific functions and integrations. Once acquainted with the code-base, just try #define ESPURNA_CORE
IMO also ESPhome is worth a mention for who embraces the excellent Home Assistant paradigm.
Piero
oh, please share details, i’m very interested! I was looking around in these days for a base to build an mqtt connected, with addon web gui too, for a max7219 based matrix display, using the excellent md_parola library…
and indeed i’ve found not as easy to start with tasmota, which already includes a matrix display but of an other type (supported by some adafruit library Theo uses), and they’re not interested in implementing max7219 based ones…
i’ve taken a look at espeasy too, but i’d like to use espurna as a base… thanks!
oh, esphome… it’s in a very active development, quite impressive what they reached in a short period of time, but i’d like to have something not almost bound to home assistant itself, even if i’m playing with it… i prefer standard mqtt, which esphome has too, but in the end, if no advanced use, why complicate my life: tasmota just does the job…
I hope not to loose too much formatting in this comment box, however this same content in PDF is here: https://mega.nz/#!K2ImgA4S!ZxuBt6nXMZBrgbN-xCR1uE8DFdHJPnqCOZ4Ltbx1Hsw
Espurna as an ESP8266 highly customizable base OS
—————————————————
Espurna supports a lot of devices and sensors, in addition to the common function as OTA update/upgrade, multiple wifi, backup/restore settings, Arduino/PlatformIO IDE, MQTT, REST API, InfluxDB, debug tools and code, and a lot of useful functions, see https://github.com/xoseperez/espurna
It’s developed in C and actually supporta only ESP8266, If embracing the HASS paradigm or even only as a MQTT client an alternative for ESP32/8266 may be ESPhome. All the other “competitors” I analyzed didn’t satisfy my requirements.
Espurna code-base appears to me well organized and clean, I feel confortable developing within it and doing my best to honor its architectural and coding standards.
This is a simplified recipe to kick-start using Espurna as a base OS on which one can develop some quite sophisticated things. Maybe it isn’t the best canonical recipe, but I hope it can help a quick startup. The essential trick is to make a good use of ESPURNA_CORE and/or custom.h:
1. Clone the espurna github repo to a local directory.
2. Using PlatformIO (VScode), open the espurna/code folder, it should contain the file platformio.ini
I never used the Arduino IDE with Espurna, but it’s supported.
3. Some dependencies (boards, frameworks, libraries, …) must be satisfied. This will happen more or less automatically, and it will depend on how you already used (or not) PlatformIO for other ESP8266 projects and SDKs. If you never did it, see the appropriate PlatformIO guide for your board.
4. To #define all in one (private) place, I find handy to use custom.h instead of ESPURNA_CORE . custom.h is excluded from github updates, so it does not interfere with usual git pull
To use custom.h in the build_flags I usually add -DUSE_CUSTOM_H
(WARNING: I was the original advocate of Espurna’s custom.h see https://github.com/xoseperez/espurna/issues/104, referenced inside all.h )
5. To get an ESPURNA_CORE equivalent (or to do a two-step update), I usually add my own definitions and some debug-only life simplifiers into espurna/config/custom.h , i.e.:
#pragma once
#define APP_REVISION “nnn”
#define USE_PASSWORD 0
#define WEB_FORCE_PASS_CHANGE 0
#define WS_AUTHENTICATION 0
#define TELNET_AUTHENTICATION 0
#define ADMIN_PASS “xxx”
#define WIFI1_SSID “yyy”
#define WIFI1_PASS “zzz”
//#define WIFI2_SSID “###”
//#define WIFI2_PASS “###”
…
#define MANUFACTURER “myName”
#define DEVICE “myDevice”
#define ALEXA_SUPPORT 0
#define API_SUPPORT 0
#define BROKER_SUPPORT 0
#define DOMOTICZ_SUPPORT 0
#define DEBUG_SERIAL_SUPPORT 0
#define DEBUG_TELNET_SUPPORT 1
#define DEBUG_WEB_SUPPORT 0
#define HOMEASSISTANT_SUPPORT 0
#define I2C_SUPPORT 1
#define MQTT_SUPPORT 1
#define NTP_SUPPORT 1
#define SCHEDULER_SUPPORT 1
#define SENSOR_SUPPORT 0
#define THINGSPEAK_SUPPORT 0
#define WEB_SUPPORT 1
#define BUTTON_SUPPORT 0
#define LED_SUPPORT 0
#define MDNS_SERVER_SUPPORT 1
#define TELNET_SUPPORT 1
#define TERMINAL_SUPPORT 1
and the other #define you need …
6. Give a look at all.h, general.h, hardware.h, sensors.h and espurna.ino, IMO these are the first source files one needs to learn when approaching Espurna. This way you will begin to understand the Espurna’s architecture and (very common) coding standards.
7. While crossing fingers, leave all as “git cloned” and check the default setup with clean + build. PlatformIO will take care of download/update the required libraries. The default device defined in platform.ini is default_envs = wemos-d1mini-relayshield , after this test build you can change it as you need.
8. Now define as default_envs the “env” you really use. Look at the [env:*] available in platformio.ini
9. Cross fingers again and check this new config with clean+build+upload to your device.
10. If all goes OK, your device should appear as a Wifi AP (192.168.4.1), the wifi and admin password are initially the same, or as configured in custom.h
The factory default password is fibonacci
11. I find handy to build+upload Espurna devices using PlatformIO via command line: pio -e run …
Hope this helps to start Espurning 🙂
PB @2019-09-06
thanks, much appreciated 🙂
I guess I will have to add espurna to my TODO list now
it’s good to have alternatives… in the end, all we want is a STABLE device which reacts and give feedback from sensors, if any… sometimes 1 firmware is more stable than others on a specific device, or you need something different (the RF part in espurna is WAY better than tasmota’s one)…
add an other arrow trying EspEasy, which has a good web gui from which you can configure EVERYTHING, no need to go to write rules (but you can: indeed, tasmota rules engine was just took from espeasy itself…), tons of sensors easily interfaceable from the gui itself (you can add an i2c sensor and display its values on an oled display without a single line of code)… it requires a little study, but it has its advantages for sure…
all in all, which ever you choose (last but not least Pete’s ESP-GO), all you need is stability and mqtt, add a bit of imagination and interaction and you’re good to go…
I’ll check the EspEasy too! The internet seems to like the VS videos and posts… so having an easy summary to what’s available with each Firmware… super useful!
The good thing about Espurna is that it has “per device” specific firmware, so it’s usually smaller than Tasmota and so no need for a double firmware upgrade (minimal first, full after that), because stock Espurna firmware is well below 500k… and no need to configure anything on the gpio side, as the firmware is tailored to the flashed device… just be sure to flash the right bin file 🙂
Also, if you go into MQTT, or HASS (home assistant), or Domoticz or whatever, you’ll find clear and detailed information and code snippets, WORKING ones, with the actual values you put in Espurna setup, so for example you just need to copy/paste the Home Assistant code from Espurna web gui to Home Assistant configuration.yaml file…
Oh, and take a look at Xose’s blog for more info and interesting stuff: https://tinkerman.cat/
I use his firmware in my connected power meter: https://tinkerman.cat/post/connected-power-meter/ and in my hacked Sonoff RF Bridge, thanks to his “Direct Hack” which can recognise LOTS more devices than the stock firmware, and you can GRAPHICALLY allow it to learn codes, no need to go to check log files as in Tasmota: https://tinkerman.cat/post/hacking-sonoff-rf-bridge-433/
And for Peter, with a little addon board you can monitor power using your sonoff TH: https://tinkerman.cat/post/power-monitoring-sonoff-th-adc121/
It is ALMOST perfect, but screen refresh doesn’t always work. STATUS web page for example. A couple of times I turned the output on or off using the button, everything worked but I had to hit REFRESH on the web page to see the change. SOMETIMES the page sees the change, other times not. Also, DUAL original firmware does 2 clicks to toggle the second relay… this does not work with Espurna. You have to hack the case and attach two buttons. Good – very good – but could be better for DUAL.
Bugger – I threw my RFBRIDGE away thinking it was of no use. I HAD sitched the Sonoff DUAL until Mr Shark told me about Espurna, as using it with Tasmota was not rewarding.
REgardless, thanks for the feedback guys, I wonder if you have any idea how useful these comments are to me (and presumably others). Lots is the answer.
well, you have the rflink which is better, it decodes rf devices codes, too… but the new way of rf handling seems to be RTL-SDR usb dongles… i can get the weather station signals of someone nearby my home 😀
p.s.: you can even add an IR LED to the rfbridge, and using it to control IR devices, too 🙂
https://1technophile.blogspot.com/2018/02/adding-infrared-emitter-to-sonoff-rf.html