Arduino Weather Station Project - BME280 Sensor

Hooking Up the Bosch BME280 Temperature, Humidity and Pressure Sensor (Part 3)

Once we have connected up the DS18B20 and tested it with the sketch we can hookup the BME280 sensor. We are connecting up the sensor using I2C communications. We are using a 5V supply for this sensor. It will be connected to pins A4 and A5 on the Arduino board. Refer to the hookup diagram shown below.

Hookup Arduino to BME280 and DS18B20

For this weather station the BME280 and DS18B20 sensors are inside the homemade weather chamber. The BME280 is mounted inside a small plastic box with air vents that sits inside the chamber. The DS18B20 waterproof sensor is mounted in the top so that it is exposed to the airflow through the vents.

Inside the box with the BME280 is a wiring block that takes all the wires from wire sensors and feeds it through one cable back to the Arduino control box. In the diagram below we show the wiring details for this sensor box.

Shelter breakout box

Software

Carrying on from the sketch we created previously we need to add the code for the BME280. To do this we need to include the cactus_io_BME280_I2C library.

We create a BME280_I2C object which we will use to communicate with the sensor. In the Setup function we call begin() which will initialise the BME280 sensor.

In the loop we call ds.readSensor() and bme.readSensor() to read the data from each sensor. We then call get_Temperature_C() (or get_Temperature_F), getHumidity() and getPresure_MB() to display data from the sensor.

The new or modified code has been highlighted.

Library

To communicate with the BME280 sensor we are using the cactus_io_BME280_I2C library.


Basic Weather Station DS18B20, BME280 Sketch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "cactus_io_DS18B20.h"
#include "cactus_io_BME280_I2C.h"

int DS18B20_Pin = 9; //DS18S20 Signal pin on digital 9

// Create DS18B20, BME280 object
DS18B20 ds(DS18B20_Pin);
BME280_I2C bme; // I2C using address 0x77

void setup() {
ds.readSensor();

Serial.begin(9600)
Serial.println("cactus.io | Weather Station DS18B20, BME280 Sensor Test");
Serial.println("DS Temp\t\tBME Temp\tHumidity\t\tPressure");

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

void loop() {
ds.readSensor();
bme.readSensor();

Serial.print(ds.getTemperature_C()); Serial.print(" *C\t");
Serial.print(bme.getTemperature_C()); Serial.print(" *C\t");
Serial.print(bme.getHumidity()); Serial.print(" %\t\t");
Serial.print(bme.getPressure_MB()); Serial.print(" mb");

// Add a 2 second delay.
delay(2000);
}

Sketch Console Output

If we have a successful hoolup then we should see the following in the console. The display is updated every 2 seconds.

Connect Arduino to DS18B20, BME280 Sensor

Next Step

In part 4 of this project we are going to hookup the Hydreon RG-11 rain sensor.