Today’s (short) “duh!” story

I was going to try experimenting with ESP-Now (Espressif’s lightweight wireless protocol which uses a minimal networking stack to provide minimal, point-to-point communications between ESP modules), as it promises a very much faster start-up and delivery for short messages for things like dedicated battery-powered sensors which only send very limited amounts of data.  There are a few examples out there; the most notable probably being HarringayMakerSpace’s ESP-Now Examples repository by Anthony (TornTrousers) Elder, which I promptly downloaded.

I’m using PlatformIO as my build environment, mainly because I feel more comfortable using the command line, but also because it generally just works.  So, I created a new project directory with the BME sensor example and confidently connected up an ESP module to USB, ready to flash.  Uh-uh!  ’twas not to be.  The compile went merrily along until it hit the linker section and then fell over in a messy heap, with:-


Linking .pioenvs/nodemcuv2/firmware.elf
.pioenvs/nodemcuv2/src/espnow-sensor-bme280.ino.o:(.text.setup+0x1c): undefined reference to `esp_now_init'
.pioenvs/nodemcuv2/src/espnow-sensor-bme280.ino.o:(.text.setup+0x20): undefined reference to `esp_now_set_self_role'
.pioenvs/nodemcuv2/src/espnow-sensor-bme280.ino.o:(.text.setup+0x24): undefined reference to `esp_now_add_peer'
.pioenvs/nodemcuv2/src/espnow-sensor-bme280.ino.o:(.text.setup+0x28): undefined reference to `esp_now_register_send_cb'
.pioenvs/nodemcuv2/src/espnow-sensor-bme280.ino.o:(.text.setup+0x2c): undefined reference to `esp_now_send'
.pioenvs/nodemcuv2/src/espnow-sensor-bme280.ino.o: In function `setup':
espnow-sensor-bme280.ino.cpp:(.text.setup+0xa6): undefined reference to `esp_now_init'
espnow-sensor-bme280.ino.cpp:(.text.setup+0xbc): undefined reference to `esp_now_set_self_role'
espnow-sensor-bme280.ino.cpp:(.text.setup+0xce): undefined reference to `esp_now_add_peer'
espnow-sensor-bme280.ino.cpp:(.text.setup+0xd7): undefined reference to `esp_now_register_send_cb'
espnow-sensor-bme280.ino.cpp:(.text.setup+0xff): undefined reference to `esp_now_send'
collect2: error: ld returned 1 exit status

In other words, it couldn’t find the ESP-Now library.  This seemed pretty strange to me, as it’s and Espressif library, not a contributed, external library and, as such, I would have expected it to be automatically linked in.

I tried a lot of things (most of which were quite silly), to no avail.  A little bit of investigation showed that the ESP-Now library did indeed exist under:-

~/platformio//packages/framework-arduinoespressif8266/tools/sdk

…with the espnow.h sitting in the include subdir and the libespnow.a in the lib subdir.

A little bit of Oogleg’ing brought up a hit where an Arduino user was having the same problem, where the suggested (and tested) fix was to add “-lespnow” to the compiler.c.elf.libs line in the relevant platform.txt file, but unfortunately that didn’t seem to make any difference for PlatformIO.  I kept on thinking that it really shouldn’t be that difficult (most things aren’t with PlatformIO) and finally had a small flash of inspiration.

I went back to the project directory and simply added:-

build_flags = -lespnow

…into the [env:……] section of my platformio.ini file.

Clean compile; no errors.

Duh!  KISS!!


Special message for someone with more time on his hands than he actually wants and is probably scouring the ‘net for anything readable with ESP8266 in it.

Take it easy Pete and listen to what the Doc’ (and HID) says.  Let me know if you want some green tea (seriously!).  All the best!


 

Advertisements

Sonoff-TASMOTA Updates

Theo has (as usual) been very busy with TASMOTA and has pushed out two releases in the last couple of weeks.  The first, at the very end of October (the “Halloween-een” 5.9.0 release) was a fairly massive update, with portions of the code being updated to follow Google’s C++ style guide as well as rewrites of some of the code to use command look-up tables and JavaScript.  In addition to those, there are seventy-odd other fixes, changes and additions.  Phew!  A couple of the notable items are:-

  • Addition of support for the Arilux AL-LC01 RGB LED controller.
  • Addition of support for the Magic Home RGBW LED controller.
  • Addition of support for the KMC 70011 Power Monitoring Smart Plug.
  • Addition of support for the VEML6070 I2C Ultra Violet sensor.
  • Addition of support for ‘inverted’ PWM.
  • Addition of support for the Luani HVIO (230v dual power control) board.
  • Addition of sea-level pressure calculation and a new ‘altitude’ command.
  • Addition of support for up to 8 relays (possible new product hint?).
  • Fixes for timezone and southern hemisphere STD/DST times.
  • Fix for a large flash erase issue.
  • Fix for ‘all-off’ issue when SaveState is inactive.
  • Fix for a pressure calculation issue with some BMP sensors.

…and lots more (check out the _releasenotes.ino file in the sonoff directory for the full listing).

The second release, 5.9.1, on the 7th of Nov, doesn’t have quite so many updates, but does add functionality to make addition of external sensors even easier and also adds support for the ADS1115 I2C AtoD chip, which a lot of people are going to find very useful.

That’s just a short round-up (I have no idea where Theo gets the time to do all of this magic …he must type at the speed of light) and, as already mentioned above, there are a lot more changes and fixes in there, so I’d recommend that you stroll over to GitHub and pull the latest version (it’s almost guaranteed to have even newer additions by the time you get there).

 

 

A Bluetooth LE upgrade to OpenMQTTGateway

Florian Robert has been making regular additions to his OpenMQTTGateway package over the past few months.

OpenMQTTGateway is, as the name suggests, a bi-directional gateway between MQTT and other hardware and/or protocols that may be running in or around your smart home.  It supports most of the ESP8266 range of hardware, as well as an Arduino equipped with a Wiz W5100 ethernet adapter.  The basic idea is that your ESP (or Arduino) interfaces with MQTT on the main network and provides seamless communications with (for instance) 433MHz or IR devices which otherwise are not directly connected.

A while back Florian made the package easily upgradeable by adding module support, where contributors can add support for other hardware and protocols by adding additional module files, rather than having to mess with the core functionality.  This usually comes down to adding a single “ZgatewayXX.ino” or “ZsensorXX.ino” file (where “XX” is a unique identifier) and possibly an additional .h file, depending upon how complex your Z file is.

The latest addition is for a Bluetooth Low Energy based plant sensor (the Mi Flora) and provides a useful example of interfacing to BLE devices.

Automatic OTA Updates

Most OTA schemes just allow you to push an update to your ESP8266, but Xose Pérez’s latest offering, “NoFUSS”,  is a plug-in for your ESP8266 project which enables your ESP8266 to regularly check in with a specified server and automatically download an update if there’s one  available.  Neat!

In addition to the simple update functionality, NoFuss allows you to configure whether updates will be offered to specific groups of ESPs (for instance, temperature sensors which might all use the BME280 module) and to configure a specific load sequence (so that the SPIFFS filesystem on the target ESP might be updated before the actual project firmware).

The requirements for implementing this on your home network are fairly simple.  The server side requires a web-server capable of supporting PHP.  The ESP side requires that you add Xose’s NoFUSSClient library to your ESP project.  The configuration for both sides is explained in Xose’s original article and the git repository for the project is available here.

ESPurna updated to 1.9.4.

Tinkerman (Xose Pérez) has just updated his ESPurna package (an alternative to Theo’s TASMOTA) to version 1.9.4.  The change log shows additions for the Huacanxing H802 LED controller and the V9261F and ECH1560 energy metering ICs as well as fixes to ensure that all ESP8285 based devices are forced to use esp01_1m  (limited memory) and updates to MQTT handling.

If you’re using any version less than 1.9.0, it’s probably worth upgrading anyway, as that was the last major update, where Xose added support for a whole bunch of newer Sonoff products (including the RF Bridge, T1 light switch and 4CH Pro).

If you haven’t visited Xose’s site yet, it’s definitely worth checking out his recent RF Bridge article, as well as his tutorial on how to secure your IOT communications with an nginx reverse proxy and Let’s Encrypt certificates, both of which are very good reads.

Sonoff-TASMOTA Updated to 5.8.0

Theo has just released version 5.8.0 of the Sonoff-TASMOTA package into the wild, with a fairly varied collection of additions, updates and fixes.

There are several changes related to WS2812 LED control, a fix for a watchdog timeout problem, as well as other fixes for MQTT, language support and Domoticz and addition of support for the Yunshan Wifi Relay and Witty Cloud.  The complete changelog is available here:- https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/_releasenotes.ino.

Owen Duffy has a nice rundown on the pros and cons of the Yunshan WiFi Relay board on his blog (and it’s worth taking a look at some of his other ESP stuff, too).

Yay! ESP32 SPIFFS Arrives.

This is one that seems to have been blocking a few projects up until now (going by the number of “any updates?” emails to the forum thread).

The official SPIFFS implementation is now available from the Arduino-ESP32 repository.

That’s the good news.  The bad news is that it’s flagged as “initial” and doesn’t seem to have things like “info” support yet.  Never mind, we have SPIFFS;  thanks Hristo and Ivan!