ANN: New library, generic device/sensor framework

This is a new library of mine built on top of the recently announced esp8266_web_settings library.

It provides a generic framework for sensors or other "devices" (devices, unfortunately, being a somewhat ambiguous term in this context) that should make assembling sketches with an nice settings UI fairly easy. Hopefully we can build up a good library of "devices" if people like this.

GitHub link: GitHub - grmcdorman/esp8266_device_framework: A generic device supporting framework, where devices can be sensors, just information sources, or things like WiFi configuration.

There is much documentation there, and a fully working example that happens to be the code I'm using for an Ikea Vindriktning air quality sensor with an added SHT31-D temperature/humidity sensor.

Technically the UI belongs to the esp8266_web_settings library, but here's a screen shot of the web interface:

Via the esp8266_web_settings, a soft access point with a captive portal for initial configuration is provided automatically.

At present two physical sensors, the Vindriktning and the SHT31-D are supported; plus 5 "devices" as can be seen from the screen shot:

  • System Overview: a continually updating summary of system information;
  • System Details: a static list of system information like chip ID, sketch size, and the like;
  • WiFi status: a continually updating summary of WiFi status;
  • WiFi: a configuration panel for WiFi (does not scan for networks);
  • and MQTT: a configuration panel for MQTT (message publishing) that works with Home Assistant.

The main .ino file ends up being fairly simple, and you only get the bits you need; the compiler is smart enough to omit code that isn't used (aside: as long as there are few or no static variables).

More snapshots of the individual panels are in the Git repository.

One interesting issue that came up in development, though, is the size of the ESP Async Web Server library. The standard one, GitHub - me-no-dev/ESPAsyncWebServer: Async Web Server for ESP8266 and ESP32, compiles to a whopping 959K library file, and is correspondingly large in the ESP8266 binary (I got up to 60% of flash on my D1 Mini). The ESP Home fork, GitHub - esphome/ESPAsyncWebServer: Async Web Server for ESP8266 and ESP32, weighs in at 540K. Unfortunately, the ESP Home folks haven't said what they took out to reduce it to that size, but at least for the usage in this framework both libraries seem to work equivalently, aside from the size. So my recommendation is to use the me-no-dev version if you have the space to allow it, and use the esphome version if you don't. I am, personally, in the latter space; I can't fit the full sketch on the D1 Mini and have it function with the me-no-dev version.

1 Like

Just to expand on the difference between the two Async Web Server libraries:

Building using the me-no-dev libraries outputs:
RAM: [===== ] 54.4% (used 44540 bytes from 81920 bytes)
Flash: [====== ] 62.0% (used 647628 bytes from 1044464 bytes)
At run time, I see free heap is 12,832 (roughly; it of course varies). The runtime also reports a sketch size of 651,792.

With the ESP home fork:
RAM: [==== ] 40.3% (used 33008 bytes from 81920 bytes)
Flash: [==== ] 42.7% (used 446440 bytes from 1044464 bytes)
and 25128 bytes free in the heap, and a sketch size of 450,592.

This is the same code, by the way, on the same ESP device; the only variable is the one library.

That's a non-trivial difference.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.