Skip to content

tibroc/bme280

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MicroPython Interface to the Bosch BME280

This is a MicroPython interface to configure and read out the Bosch BME280 humidity, pressure and temperature sensor. It is supposed to provide an API to the sensor's full functionality and be cross-functional between boards. It was tested on the ESP32, the ESP8266 and the PyBoard v1.1.

Hardware Set-Up

Connect the Vin pin of the sensor to a 3.3V outlet on the board and the GND to ground. You can connect the SDA and SCL pins of the sensor's I2C-bus basically to any general purpose pin on your board of choice. Then configure your I2C in your MicroPython script as described below. For more info on the sensor and its functions have a look at the datasheet.

Usage

I2C-connection

You first need to initialize a I2C-connection to your sensor. The sensor's default address on the bus is 0x76 and it is saved in constants.py. However, you can override this setting for each instance of the sensor-class when initializing it. An example to set-up your I2C-interface might look like this:

import machine

# configure the I2C-pins (change the ids according to your set-up)
sda_pin = machine.Pin('x1', machine.Pin.OUT)
scl_pin = machine.Pin('x2', machine.Pin.OUT)

# init the i2c connection
i2c = machine.I2C(scl=scl_pin, sda=sda_pin, freq=100000)

# see if your sensor is there
i2c.scan()

Initialize Sensor

import bme280

# initialize a sensor
sensor = bme280.bme280_instance(i2c_connection=i2c, bme_address=None)

# read values
print(sensor.get_values)

About

A micropython interface to the bme280

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages