ESP8266 and BMP280 sensor example

BMP280 is an absolute barometric pressure sensor especially designed for mobile applications. The sensor module is housed in an extremely compact package. Its small dimensions and its low power consumption allow for the implementation in battery powered devices such as mobile phones, GPS modules or watches.

As its predecessor BMP180, BMP280 is based on Bosch’s proven Piezo-resistive pressure sensor technology featuring high accuracy and linearity as well as long term stability and high EMC robustness. Numerous device operation options offer highest flexibility to optimize the device regarding power consumption, resolution and filter performance. A tested set of default settings for example use case is provided to the developer in order to make design-in as easy as possible.

Applications

– Enhancement of GPS navigation (e.g. time-tofirst-fix improvement, dead-reckoning, slope detection)

– Indoor navigation (floor detection, elevator detection)

– Outdoor navigation, leisure and sports applications

– Weather forecast

– Health care applications (e.g. spirometry)

– Vertical velocity indication (e.g. rise/sink speed)

Parameter Technical data
Operation range (full accuracy) Pressure: 300…1100 hPa
Temperature: -40…85°C
Absolute accuracy
(Temp. @ 0…+65°C)
~ ±1 hPa
Relative accuracy
p = 700…900hPa
(Temp. @ +25…+40°C)
± 0.12 hPa (typical)
equivalent to ±1 m
Average current consumption (1 Hz data refresh rate) 2.74 μA, typical
(ultra-low power mode)
Average current consumption in sleep mode 0.1 μA
Average measurement time 5.5 msec
(ultra-low power preset)
Supply voltage VDDIO 1.2 … 3.6 V
Supply voltage VDD 1.71 … 3.6 V
Resolution of data Pressure: 0.01 hPa ( < 10 cm)
Temperature: 0.01° C
Temperature coefficient offset
(+25°…+40°C @900hPa)
± 0.12 hPa (typical)
equivalent to ±1 m
Interface I²C and SPI

 

Parts List

Here are the parts I used

 

Name Links
Wemos Mini
BMP280
Connecting cables

Layout

This is a layout diagram using an adafruit part, my module had clearly marked SDA and SCL connections

wemos and bmp280
wemos and bmp280

 

Code

This example requires https://github.com/adafruit/Adafruit_BMP280_Library and https://github.com/adafruit/Adafruit_Sensor

 

/***************************************************************************
This is a library for the BMP280 humidity, temperature & pressure sensor

Designed specifically to work with the Adafruit BMEP280 Breakout 
----> http://www.adafruit.com/products/2651

These sensors use I2C or SPI to communicate, 2 or 4 pins are required 
to interface.

Adafruit invests time and resources providing this open source code,
please support Adafruit andopen-source hardware by purchasing products
from Adafruit!

Written by Limor Fried & Kevin Townsend for Adafruit Industries. 
BSD license, all text above must be included in any redistribution
***************************************************************************/

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>

#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 11 
#define BMP_CS 10

Adafruit_BMP280 bme; // I2C
//Adafruit_BMP280 bme(BMP_CS); // hardware SPI
//Adafruit_BMP280 bme(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK);

void setup() {
Serial.begin(9600);
Serial.println(F("BMP280 test"));

if (!bme.begin()) { 
Serial.println("Could not find a valid BMP280 sensor, check wiring!");
while (1);
}
}

void loop() {
Serial.print("Temperature = ");
Serial.print(bme.readTemperature());
Serial.println(" *C");

Serial.print("Pressure = ");
Serial.print(bme.readPressure());
Serial.println(" Pa");

Serial.print("Approx altitude = ");
Serial.print(bme.readAltitude(1013.25)); // this should be adjusted to your local forcase
Serial.println(" m");

Serial.println();
delay(2000);
}

 

Output

Temperature = 27.65 *C
Pressure = 100592.44 Pa
Approx altitude = 61.17 m

Temperature = 28.72 *C
Pressure = 100589.25 Pa
Approx altitude = 61.44 m

Temperature = 29.31 *C
Pressure = 100590.25 Pa
Approx altitude = 61.35 m

Temperature = 29.70 *C
Pressure = 100588.21 Pa
Approx altitude = 61.53 m

Temperature = 30.01 *C
Pressure = 100581.49 Pa
Approx altitude = 62.09 m

Temperature = 28.95 *C
Pressure = 100601.21 Pa
Approx altitude = 60.44 m

 

Link

https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMP280-DS001-18.pdf

 

1 COMMENT

  1. AFAIK, it’s not a good idea to let SD0 floating. SD0 defines the address. High: 0x77 (same address as BMP180), Low: 0x76. When left floating, the address might change with electric charge or discharge.

LEAVE A REPLY

Please enter your comment!
Please enter your name here