Team14 barometric pressure sensor

From Sketching with Hardware at LMU Wiki
Jump to navigation Jump to search

PIM472 BME280 Temperature, Pressure, & Humidity Sensor[edit]

The BME280 is a sensor from Bosch used for measuring the temperature, air pressure and humidity. It is a nice environmental sensor for indoors or even outdoors in a suitable enclosure. The breakout board is compatible with 3.3 or 5 operating supply voltage and uses an I2C interface. This makes the sensor compatible for operating using any model of Raspberry Pi or Arduino microcontroller.

  • Pressure: range of 300 to 1100 hPa, sensitivity error ±0.25%, RMS Noise 0.2Pa
  • Temperature: range of -40 to 85°C
  • Humidity: accuracy tolerance ±3% relative humidity

Technical Specifications[edit]

If you’re using a Raspberry Pi, you can solder the PIM472 onto the bottom left 5 pins on your Raspberry Pi's GPIO header (pins 1, 3, 5, 6, 9).

Pinout[edit]

  • 2-6V - Power supply, compatible with 3.3V and 5V
  • SDA - Serial Data Input: I2C communication
  • SCL - Serial Clock Input: I2C communication
  • GND - Ground

Advantages and Disadvantages[edit]

Advantages[edit]

  • Three sensors in one
  • Many uses for mobile applications and wearables: health monitoring (heat stroke and dehydration warning, lung volume ), weather forecast, indoor and outdoor navigation, control of heating, ventilation, air conditioning (HVAC) systems, sports and leisure
  • I2C and SPI bus interface

Disadvantages[edit]

  • Price (~16€) high if you don’t need all three sensor functions

Getting the BME280 to work[edit]

Wiring with Wemos D1 Mini[edit]

  • Connect 2-6V to power supply (3.3V or 5V) - we use 5V
  • Connect SDA to any I2C data SDA pin - GPIO4 (D2)
  • Connect SCL to any I2C data SCL pin - GPIO5 (D1)
  • Connect GND to ground - G

Required Library[edit]

  • Download and save this code as BME280.py
  • Upload the code to the microcontroller

Code Example[edit]

 1 # import modules
 2 from time import sleep
 3 from machine import Pin, I2C
 4 import BME280
 5 
 6 # Initialise the BME280
 7 sda = Pin(4)
 8 scl = Pin(5)
 9 i2c = machine.I2C(sda=sda, scl=scl)
10 bme280 = BME280.BME280(i2c=i2c)
11 
12 # Print out temperature, air pressure and humidity values
13 while True:
14     temperature = bme280.temperature
15     pressure = bme280.pressure
16     humidity = bme280.humidity
17     
18     print('Temperature: ', temperature)
19     print('Air pressure: ', pressure)
20     print('Humidity: ', humidity)
21     print("----------------------")
22 
23     sleep(2)

Instructional Video[edit]