Breadboard
docs
Example project · ESP32

Air-quality station (SEN55 + OLED)

A desk-ready monitor: the ESP32 polls a Sensirion SEN55 over I2C and renders live PM2.5, humidity, and temperature to the OLED once a second. Press Run, then ▶ Run script in the serial monitor, and the display updates like the real appliance.

The Air-quality station (SEN55 + OLED) circuit as rendered by the simulator

What's on the bench

  • Battery
  • ESP32-C3
  • OLED 128×64
  • SEN55

The code

This MicroPython script runs on the emulated board every boot; edit it in the Code tab.

from machine import I2C, Pin
import framebuf, time
i = I2C(0, scl=Pin(9), sda=Pin(8))
buf = bytearray(1024)
fb = framebuf.FrameBuffer(buf, 128, 64, framebuf.MONO_VLSB)
for c in b'\xae\xd5\x80\xa8\x3f\xd3\x00\x40\x8d\x14\x20\x00\xa1\xc8\xda\x12\x81\xcf\xd9\xf1\xdb\x40\xa4\xa6\xaf':
    i.writeto(0x3c, bytes([0, c]))
def show():
    i.writeto(0x3c, b'\x00\x21\x00\x7f\x22\x00\x07')
    i.writeto(0x3c, b'\x40' + buf)

# SEN55: start measurement, then poll (Sensirion I2C command set)
i.writeto(0x69, b'\x00\x21')
time.sleep(0.2)
for n in range(60):
    i.writeto(0x69, b'\x03\xc4')
    d = i.readfrom(0x69, 24)
    w = [(d[k*3] << 8) | d[k*3+1] for k in range(8)]
    fb.fill(0)
    fb.text('AIR QUALITY', 20, 2)
    fb.text('PM2.5 %.1f ug' % (w[1]/10), 0, 20)
    fb.text('RH    %.1f %%' % (w[4]/100), 0, 34)
    fb.text('TEMP  %.1f C' % (w[5]/200), 0, 48)
    show()
    print('PM2.5', w[1]/10, 'RH', w[4]/100, 'T', w[5]/200)
    time.sleep(1)