Skip to content

Pressure & Humidity Wireling Python Tutorial

This Wireling lets you measure Humidity, Pressure, Temperature, and the approximate Altitude all from the small BME280 sensor.

Technical Details

Bosch BME280 Sensor Specs

  • Digital interface I²C (up to 3.4 MHz) and SPI (3 and 4 wire, up to 10 MHz)
  • Operating range -40…+85 °C, 0…100 % rel. humidity, 300…1100 hPa
  • Humidity sensor and pressure sensor can be independently enabled/ disabled
  • Register and performance compatible with Bosch Sensortec BMP280 digital pressure sensor
  • RoHS compliant, halogen-free, MSL1
  • Pressure Sensor 
  • RMS Noise 0.2 Pa, Equiv. to 1.7 cm
  • Offset temperature coefficient ±1.5 Pa/K, Equiv. to ±12.6 cm at 1 °C temperature change
  • Humidity Sensor:
  • Response time 1 s
  • Accuracy tolerance ±3 % relative humidity
  • Hysteresis ±1% relative humidity

    Power Requirements

    • Voltage: 3.0V - 5.5V 
    • Current:
      • 1.8 µA @ 1 Hz humidity and temperature
      • 2.8 µA @ 1 Hz pressure and temperature
      • 3.6 µA @ 1 Hz humidity, pressure, and temperature
      • 0.1 µA in sleep mode

    Pins Used

    • A5/SCL - I²C Serial Clock line
    • A4/SDA - I²C Serial Data line

    Dimensions

    • 10mm x 10mm (.394 inches x .394 inches)
    • Max Height (from the lower bottom of Wireling to upper top Wireling Connector): 3.70mm (0.15 inches)
    • Weight: 1 gram (.04 ounces)

    Materials

    Hardware

    Required Software

    • Python 3 (Python 2 is not supported!)
    • All Python packages mentioned in the Pi Hat setup tutorial (tinycircuits-wireling, Adafruit-Blinka, adafruit-circuitpython-ads1x15, and adafruit-circuitpython-busdevice)
    • BME280 Python Example
    • BME280 Python package mentioned later

    Hardware Assembly

    Plug your Wireling into the port you plan on using! The default in the included program is port 0.

    If you want to use a different port, you just need to change the port value in the program mentioned later.


    Programming

    Install the necessary Python package:

    sudo pip3 install adafruit-circuitpython-bme280
    

    Lets look at the beginning of one of the package examples:

    bme280_example.py
    # Example prints the temperature, pressure, humidity, and altitude of the BME280
    # sensor
    # Library by: Adafruit
    # Example modified by: Laverena Wienclaw for TinyCircuits
    
    import time
    import board
    import busio
    import adafruit_bme280
    import tinycircuits_wireling
    
    # Enable power to pi hat and wirelings
    wireling = tinycircuits_wireling.Wireling()
    wireling.selectPort(0) # Select port (0-3) labeled on the Pi Hat
    
    # Create library object using our Bus I2C port
    i2c = busio.I2C(board.SCL, board.SDA)
    bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)
    
    # OR create library object using our Bus SPI port
    #spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
    #bme_cs = digitalio.DigitalInOut(board.D10)
    #bme280 = adafruit_bme280.Adafruit_BME280_SPI(spi, bme_cs)
    
    # change this to match the location's pressure (hPa) at sea level
    bme280.sea_level_pressure = 1013.25
    
    while True:
        print("\nTemperature: %0.1f C" % bme280.temperature)
        print("Humidity: %0.1f %%" % bme280.humidity)
        print("Pressure: %0.1f hPa" % bme280.pressure)
        print("Altitude = %0.2f meters" % bme280.altitude)
        time.sleep(2)
    
    

    Run Program

    Navigate in the terminal to the directory with the file parent to the examples folder.

    python3 bme280_example.py
    

    After the program is running, your terminal should begin printing the sensor values:

    Temperature: 30.9 C
    Humidity: 30.1 %
    Pressure: 975.0 hPa
    Altitude = 323.59 meters
    

    Downloads


    Contact Us

    If you have any questions or feedback, feel free to email us or make a post on our forum. Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it.

    Thanks for making with us!