Home Elements Boards Recipes

Minimal Sized Example

The Minimal examples can be used on ESP8266 boards that only have a small amount of Flash Memory (1 MByte) available for program and web UI storage like the ESP-01 board and devices like the sonoff S20 switch, sockets or bulbs.

The bulb example in the HomeDing library is made especially for WiFi bulbs with the ESP8266 processor inside. These devices only have a small amount of Flash Memory available (1 MByte) for program and web UI storage.

The plug example in the HomeDing library is made especially for plugs / socket switches. These devices only have a small amount of Flash Memory available (1 MByte) for program and web UI storage.

Because the flash memory is very limited on these devices the minimal sketch only contains Elements that are used within bulbs. e.g. no sensors and provide the base functionality combined with a set of elements that can be used in the configuration of the device.

Approach for development

These devices are not really usable during development.

Thereforefore it is recommended:

Reduced memory footprint

Compared to the Standard example some measures have been taken to reduce required program memory.

From the 1 MByte of memory only 128kByte of memory is used for the file system leaving about 445 kByte for program space while still enabling OTA / network based updates.

When compiling the sketch to create a firmware only a small set of elements are included (see below). The web files are also minimized and reduced in functionality to allow a minimal UI implementation and logging is disabled to save memory in the filesystem. Compared to the Standard example about 52 kByte less program space is required. When disabling the debug port in the Board configuration another 1.5 kByte can be saved.

Reducing the set of Elements

The elements that are included in this example sketch are those that support sockets, switches and lights but no sensors and displays. The logical, time and remote elements are included as well to support integration.

As of this writing the elements included are:

ota, device, value, button, switch, and, reference, time, alarm, ntptime, timer, schedule, digitalin, digitalout, remote, dht, color, light, neo, bl0937, my9291, ssdp

You can control what elements are included in the firmware file by enabling or disabling the #define statements for registering the elements in the sketch file.

If you like to know what element are available in a device just ask for the URL http://<devicename>/$elements

How to Configure and Upload

There are 2 transfer jobs to upload the firmware and the files of the filesystem.

1. Compile and upload the sketch

The sketch from this example can be compiled without any dependencies to external libraries. There are some options documented in the source code e.g. to enable WS2812 LED stripes (a.k.a. NeoPixels) that you may like to enable after installing the required libraries.

You can upload using a USB / Serial cable when flashing the first time or use the OTA feature after flashing any OTA enabled firmware. The example includes the OTA upload feature to enable remote updates.

2. Upload the web ui files

See Step by Step uploading the files for the web UI.

The files for such minimal devices are reduced and available in the v09m folder (not v09). Please be sure to adjust the URL by appending #v09m like http://outdoor/$update.htm#v09m. You may need to refresh the page until you see the text loading from: https://homeding.github.io/v09m/.

Web UI

The Web UI that comes with this example fits into 128 kByte and provides showing actual sensor and actor values implemented in the /ding.html file that is also available on the standard Web UI for the standard example.

Modifications

This example also acts as a starting point for other sensors that need no extensive ui capabilities or use the deep sleep mode and wake-up modus to save energy when powered by battery or solar.

Not included elements of the library can be added by defining the Element to be included in the sketch. There are some commented lines in the source code that show how this can be achieved.

When you implement your own elements you can just add them to the sketch folder.

Tags

Example