This is a driver for the Bosch BME280 temperature/pressure/humidity sensor, for use with MicroPython on ESP8266 boards
Go to file
Peter Dahlberg 179aa6cb07 get rid of function only called once 2016-05-20 21:38:08 +02:00
README.md Initial import from https://bitbucket.org/oscarBravo/wipy_bme280 2016-05-19 23:47:21 +02:00
bme280.py get rid of function only called once 2016-05-20 21:38:08 +02:00
bme280_const.py split into multiple files to not run out of memory while importing 2016-05-20 00:48:51 +02:00
i2c_device.py remove unused function 2016-05-20 21:09:45 +02:00

README.md

README

This is a driver for the Bosch BME280 temperature/pressure/humidity sensor, for use with MicroPython-based boards.

About the BME280

The Bosch BME280 Environmental Sensor is a combined temperature, pressure and humidity sensor. It can communicate via I2C or SPI; this driver uses I2C.

See the datasheet at https://www.adafruit.com/datasheets/BST-BME280_DS001-10.pdf for details.

Using the library

Use ftp to copy bme280.py to the flash or flash/lib directory on the board. Then:

import machine
import bme280

i2c = machine.I2C(0, pins=('GP11', 'GP10'))
bme = bme280.BME280(i2c=i2c)

print(bme.temperature, bme.pressure, bme.humidity)

Detailed usage

The temperature, pressure and humidity properties are convenience functions that provide human-readable string values to quickly check that the sensor is working. In practice, the methods to use are:

  • get_temperature(): returns the temperature in hundredths of a degree celsius. For example, the value 2534 indicates a temperature of 25.34 degrees.
  • get_pressure(): returns the atmospheric pressure. This 32-bit value consists of 24 bits indicating the integer value, and 8 bits indicating the fractional value. To get a value in Pascals, divide the return value by 256. For example, a value of 24674867 indicates 96386.2Pa, or 963.862hPa.
  • get_humidity(): returns the relative humidity. This 32-bit value consists of 22 bits indicating the integer value, and 10 bits indicating the fractional value. To get a value in %RH, divide the return value by 1024. For example, a value of 47445 indicates 46.333%RH.