PymateIO-I2C-Bus
Abstract
Pymate Expansion bus bring many connections.
Two of the pins can be used as I2C bus, very useful to connect I2C sensors and actuators.
To demonstrate the usage, this example will connect a BMP280 atmospheric pressure & temperature sensor.
The BMP280/BME280 sensors are well supported under MicroPython . They both used the same driver, BME280 returns the additional humidity value.
Wiring
Note that a 3.3V regulator is used to power the BMP280 sensor.
10KΩ pull-up resistor are used on the SDA, SCL signal lines to pull them to 3.3V.
BMP/BME Library
Prior to use this sensor, the bme280.py library file must be copied to the MicroPython board.
Use the following instruction to install the BMP/BME280 library from the repository.
On a WiFi capable platform, use REPL to as follow:
>>> import mip
>>> mip.install("github:mchobby/esp8266-upy/bme280-bmp280")On computer, use the MicroPython MPRemote utility as folows:
mpremote mip install github:mchobby/esp8266-upy/bme280-bmp280Code
Here the example script accessing the I2C bus and using the BME280 driver to acquire the sensor data
from pymate.board import Board
from bme280 import BME280
brd = Board()
i2c = brd.i2c( freq=400000 )
bmp = BME280( i2c=i2c ) # BMP280 & BME280 works the same
print( "Found devices", i2c.scan() )
# Request data from the sensor
print( "Sensor values:", bmp.values )
print( "That's all Folks" )Executing the script shows the following result:
Found devices [119]
Sensor values: ('21.09C', '1002.97hPa', '0.00%')
That's all Folks
PymateIO all right reserved © 2026 - Written by MCHobby for PymateIO