ESP8266 IoT BME280 temperature, humidity and pressure – 06/2021 update

ESP8266 IoT BME280 temperature, humidity and pressure described an IoT project. This article documents an update for newer nodemcu core (NodeMCU and the revised support for BME280 (the older method having been deprecated).

This project is based on ESP8266 IoT DHT22 temperature and humidity – evolution 3, but uses the Bosch BME280 temperature, humidity and pressure sensor. The BME280 has been around for a couple of years, though recently, modules using the chip have become more expensive on eBay, around $10. If you find BME280s listed for much less than that, it is probably Chinese cheats doing a bait and switch… delivering BMP280 (pressure only). Continue reading ESP8266 IoT BME280 temperature, humidity and pressure – 06/2021 update

IoT water tank telemetry project – part 4

After a long hiatus… the project activity resumes.

Boxing is underway, and the code has been revised to use a BME280 sensor replacing the DHT sensor. The BME280 is a better sensor (less jitter), and is also capable of barometric pressure if that is of interest.

Experience has been that 18650 cells do not last when exposed to extreme temperatures in solar powered modules like this, so a single cell pouch 2000mAh LiPo will be used (as in the battery trials).

The code has been refactored to make measurements before starting the WiFi as WiFi activity injects noise into the ESP8266 ADC.

The nodemcu core was updated as part of this process.


The system is easy to calibrate in terms of stored water volume for containers with vertical sides where the change in volume with level is uniform… but there are lots of applications where that is not true, natural dams for example.

Above is a plot of volume versus depth of water for a container like a spherical bowl. The interpolation line is a cubic spline interpolation based on the six input data points, it is of course a very good fit to those points but would appear to be a good estimator of the regions between.

The code now contains a facility to perform a cubic spline interpolation of a small number of data points over the expected range of depths.


Above, a set of six points (as in the chart) in the format required of the code in a file named dam.xy.

The code calculates and stores an intermediate data file <name>.cstable if it does not exist for more rapid calculation. If the .xy file is updated, the corresponding .cstable file needs to be deleted.

The init.lua file is augmented to call a transform function from the httpreq function which customises the HTTP request.

function transform()
  if level<0 then level=0 end
  print("Volume: ",volume)

function httpreq() 
--  req=rest_url.."?api_key="..apikey.."&field1="..level.."&field2="..temperature.."&field3="..humidity
  return req,body

Above, the transform function fetches the function definitions for the cubic spline interpolation, and calculates an interpolated volume from the measured level (or depth) value.

Above is a trial run using a calibration generator for the level input, and its conversion to current volume of the storage.


One of the possible paths this project might follow was to use LoraWan… but experience with LoraWan has not been positive, particularly issues with the Laird gateway.

Above is the enclosure, an electrical box with transparent lid. The PV array is mounted inside the lid, the cheap Chinese ones tend to degrade too quickly when exposed to the elements. There is room in the box for a 2000mAh 1S Lipo battery. The switching circuit for the 24V DC-DC converter is mostly on the Veroboard under the (red) DC-DC converter (powers the 4-20mA loop). The module at lower left is a 1S battery management / protection board.

The resistor diagonally across the Wemos module is the 4-20mA sense resistor wired from A0 to ground. Experience is that locating the resistor on-board reduces the errors due to variable contact resistance through the module header pins.

If temperature / humidity monitoring is desired, a BME280 module plugs into the header near the antenna, but it needs to be remote from the box which gets quite hot in the direct sun.

The implementation supports easy development and update, if the battery and solar cell are disconnected, plugging a computer into the USB port on the Wemos board allows update and normal operation / testing.

SNTP synchronised clock v1 – boxing it up

The SNTP synchronised clock (ssc) is an ESP8266 based time of day clock with an LED display.

The code is fairly mature, and the boxed prototype will be build with a large 4 digit 7 segment LED display (1.2″ or 30mm) using the HT16K33 driver chip.

The prototype will be housed in an ABS Jiffy box, and a new lid cut from dark red transparent acrylic on the CNC router.

Above is the sketch of the layout. The screw holes in the display are M1.6, and there is no clearance for larger screws. Continue reading SNTP synchronised clock v1 – boxing it up

SNTP synchronised clock v1 – display options

The SNTP synchronised clock (ssc) is an ESP8266 based time of day clock with an LED display.

Code development progresses and a working prototype exists with three display options.

Directly supported 4 digit 7 segment LED displays

Several common driver boards are supported directly by the source code, most of these and variants can be purchased online for small money.


Above is a large 4 digit 7 segment LED display (1.2″ or 30mm) using the HT16K33 driver chip. Continue reading SNTP synchronised clock v1 – display options

SNTP synchronised clock v1 – a preview

The SNTP synchronised clock (ssc) is an ESP8266 based time of day clock with an LED display.

Design criteria

The design criteria are:

  • small, portable, powered from a 5V USB power supply;
  • synchronised to a SNPT (simple network time protocol) server;
  • flexibility for a range of displays (74HC595 static, TM1637, HT16K33);
  • configurable time zone offset and daylight saving offset;
  • configurable from a web page;
  • switchable HH:MM and MM:SS display formats; and
  • switchable daylight saving mode.

The concept is that it is synchronised to net time, and the only adjustment needed through the year is to flick the daylight saving mode.

The hardware comprises:

  • ESP8266 dev board of some kind;
  • 5V to 3.3V power supply; and
  • 4 digit 7 segment LED display, preferably with a colon in the middle.

Above is a development prototype using a Wemos D1 mini ESP8266 board and 4 digit display using 74HC595 shift registers. Continue reading SNTP synchronised clock v1 – a preview

Fix for a certain TM1637 LED display

There are a miriad of low cost displays for hobbyists in online shops, particularly targeting Arduinos where libraries exist to drive the most common chips.

This article looks at a 4 digit LED module particularly suited to a digital clock display. The driver chip is a TM1637, and it requires Vcc and Gnd, a data IO wire and data clock wire.

Above is an example that just didn’t work. Continue reading Fix for a certain TM1637 LED display

ESP8266, ESP32 reset – the (ugly) detail

Like many microcontrollers, the ESP8266 and ESP32 series contain an in-Silicon bootloader which can be initiated at chip reset by holding a pin low at the moment of reset.

Documentation is not helped by less than common terms (like EXTRSTB for a pin that is really a /RST, and it is labelled EN on the ESP32). The other relevant pin is known as GPIO00, but can be thought of as a /BOOT bin.

Automatic bootloader initiation

The firmware is uploaded using ordinary RS232/TTL, and it is possible to use modem control signals to control the /RST (EXTRSTB) and /BOOT (GPIO00 or IO0) pins, indeed the common convention is to use RS232 signals RTS for resetting the MCU, and DTR for boot selection.

So, it is possible to connect RS232/TTL /RTS to /RST and /DTR to /BOOT, and ESPTOOL will automatically initiate the boot loader when accessing the chip.

Above is a simulation of that type of direct connection. The RTS/DTR scenario is that from ESPTOOL, but it can be seen that even if the RTS transition was delayed somewhat the /BOOT pin is low and when /RST rises the chip will initiate the bootloader. The critical timing is that /BOOT is low when /RST transitions from low to high. Continue reading ESP8266, ESP32 reset – the (ugly) detail

Logging temperature meter (ltm) v1 – prototype trial run measuring ECT

Logging temperature meter (ltm) is a ESP8266 based temperature measurement and logging device.

Above is the prototype, but for this test a small thin film NTC thermistor was attached to the existing engine coolant temperature (ECT) sensor. Continue reading Logging temperature meter (ltm) v1 – prototype trial run measuring ECT