Tuesday, November 19, 2019

Bosch BME280 sensor with arduino for temp humidity and pressure


Buy sensor for here: http://s.click.aliexpress.com/e/KY9P6WRm



Arduino Libraries Required:
Adafruit_Sensor.h
Adafruit_BME280.h

Go to Tools -> Manage Libraries :
search for bme280 and select the adafruit one, and install all.

Wire connections:
- 5V and GND to coresponding
- the marked ones SDA, SCL on the end of the digital pins
- or the analog pins A4 (SDA) A5 (SCL)

Arduino Code:

#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
Adafruit_BME280 bme; // I2C
void setup()
{
    bool status;
    status = bme.begin();
}
void loop() {
float temp = bme.readTemperature();   // celsius
  float humidity = bme.readHumidity();  // read humidity
  float altitude = bme.readAltitude(1013.25);// read altitude  SEA LEVEL PRESSURE_HPA (1013.25)
  float pressure = bme.readPressure() / 100.0F; // read pressure
delay(5000);

}

No comments:

Post a Comment