ESP8266 IoT BME280 temperature, humidity and pressure

This article documents a project with the Espressif ESP8266.

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, but recently, modules using the chip have become available on eBay for a couple of dollars.

The objective is a module that will take periodic temperature, humidity atmospheric pressure (barometer) measurements, and in this evolution publish them using a RESTful API.

The example platform used in this article is a Wemos D1Pro. In this case, the D1Pro is configured for an external antenna, and a modification is made to the board to add a 1N34A diode for the deep sleep reset circuit (NodeMCU devkit V1 deep sleep). A right angle header on the top of the board (as seen) and another on the underside on the opposite edge to get GND, +3.3, D3 and D4 for the BME280 sensor. There is less than $25 in parts in the pic above.

The ESP8266 is not 5V tolerant, so the BME280 should be powered from the 3V supply.

The sensor is read using I2C in this project.

Above is capture of the SDA line during sensor initialisation and read, the process takes about 70ms.

The code as it evolves is available online .

Above is a screenshot of graphs from Thingspeak  of temperature, humidity and pressure at 10min intervals.

Buying a BME280 module

Chinese cheats sell modules under the headline BME280 that in fact have a BMP280 on them, or as a trap for a more expensive BME280 option.

Some boards have level conversion (see above) which may be useful for some applications (eg with 5V MCU), though this project did not benefit from such. You need pics of both sides of the module to confirm the inclusion of a 3.3V regulator and level shifting circuitry.

Many boards are advertised as SPI but have only the I2C pins. Important if you want to use SPI, this project uses I2C so the small module is just fine.

Chinese cheats

If you buy low cost modules on eBay, they are unlikely to be genuine Bosch parts so of dubious specifications (fakes in terms of the Bosch datasheet) and not marked with the BME280 part number (much less the Bosch logo), and the Chinese cheats may even try to pass off BMP280 which are inferior in many ways, including that they cannot measure humidity.

MQTT version

The MQTT version is also under active development, the code as it evolves is available online .