Temperature, Humidity and Pressure sensor BME280

TTN version: TTNv3
Board: Adafruit Feather M0
Activation: OTAA
Device Class: Class A
Last updated: October 7, 2023

This article provides instructions for making a temperature, humidity and pressure sensor using Adafruit Feather M0 RFM95 LoRa Radio and BME280. If you haven’t set up Adafruit Feather M0 yet, check out our Adafruit Feather M0 tutorial (Activation – OTAA).BME280

 

Prepare

  • Adafruit Feather M0 RFM95 LoRa Radio
  • BME280
  • 5x wire
  • breadboard (optional)
  • PC + micro USB cable

 

BME280

To measure temperature, humidity and pressure, we will use the BME280 sensor. The sensor measures temperatures in the range of -40 °C to 85 °C, humidity in the range of 0 % to 100 % and pressure in the range of 300 hPa to 1100 hPa. The accuracy of temperature measurement is ± 1.0 ºC, humidity ± 3 % and pressure ±1 hPa.

 

BME280

 

Sensor assembly

Connect everything according to the schematics bellow.

Wire up the Adafruit Feather M0’s IO1 pin with pin 6. The sensor is connected using four pins. The BME280 pin VIN is connected to the supply voltage (3V pin on Adafruit Feather M0), the BME280 pin GND is connected to the ground (GND pin on Feather), the BME280 pin SCK is connected to Feather’s pin SCL and the BME280 pin SDI is connected to Feather’s pin SDA. The sensor requires a stabilized supply voltage in the range of 3.3 V to 5 V for its function.BME280_Schematics

 

Arduino IDE setup

  1. Run Arduino IDE.
  2. In the Arduino IDE Library Manager search Adafruit BME280 Library by Adafruit and install it with all dependencies (library Adafruit Unified Sensor and Adafruit BusIO).
  3. In the Arduino IDE Library Manager search CayenneLPP by Electronic Cats and install it.
  4. In the Arduino IDE Library Manager search RTCZero by Arduino and install it.

 

Printing measured values to Serial Monitor

  1. In the Arduino IDE File -> Examples -> Adafruit BME280 Library -> open bme280test
  2. Connect Adafruit Feather M0 using micro USB cable to your computer.
  3. In Arduino IDE click on Upload button to upload program to your Adafruit Feather M0.
  4. In Arduino IDE click on Serial Monitor button and you should every second see this:BME280 Arduino IDE Serial Monitor

 

Sending measured values to TTS

We have prepared four programs for measuring temperature, humidity and pressure. The first program sends the current measured values. The second program sends averages of measured values over a certain period of time. The other two programs extend the first two with a low power mode, which is great when you run this sensor on battery power.

Programs

 

Instructions

  1. Copy and paste one of this programs to your Arduino IDE.
  2. In program replace APPEUIDEVEUI and APPKEY with keys in TTS. Keys are in TTS -> Applications -> YourAppName -> YourEndDeviceName -> Overview -> Activation information.
  3. In TTS -> Applications -> YourAppName -> YourEndDeviceName -> Payload formatters -> Uplink change Formatter type to CayenneLPP. For more information, check out our Cayenne LPP tutorial.
  4. Save changes.
  5. Connect Adafruit Feather M0 using micro USB cable to your computer.
  6. In Arduino IDE click on Upload button to upload program to your Adafruit Feather M0.
  7. In TTS -> Applications -> YourAppName -> YourEndDeviceName -> Live data you should every 5 minutes (Low Power Mode – 10 minutes) see this:BME280_TTN

    Data visualization

    If you want to visualize your measured data, continue with the following tutorial: