
Cómo funciona
Sensirion SEN55 por I²C con sus órdenes reales: el script escribe 0x0021 en la dirección 0x69 para iniciar, consulta 0x03C4 y descompone los 24 bytes en PM2.5 (÷10), humedad (÷100) y temperatura (÷200), como firmware de producción. SEN55 está en 5 V porque su ventilador es una carga real; comparte el bus I²C C3 (SDA=G8, SCL=G9) con SSD1306, que dibuja una lectura por segundo.
Componentes del montaje
- ESP32-C3
- OLED 128×64
- SEN55
Cómo está conectado
- orificio a10→orificio B-5
- orificio a11→orificio B+5
- orificio a30→orificio B+9
- orificio a31→orificio B-9
- orificio a32→orificio a20
- orificio a33→orificio f11
- orificio a34→orificio B-9
- orificio a40→orificio B-9
- orificio a41→orificio f10
- orificio a42→orificio g11
- orificio a43→orificio b20
- ESP32-C3 · gnd→orificio e10
- ESP32-C3 · vin→orificio e11
- ESP32-C3 · g8→orificio e20
- ESP32-C3 · 3v3→orificio i10
- ESP32-C3 · g9→orificio i11
El código
Este script de MicroPython se ejecuta en la placa emulada en cada arranque; edítalo en Code.
from machine import I2C, Pin import framebuf, time i = I2C(0, scl=Pin(9), sda=Pin(8), freq=100000) 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) # Big digits: each pixel of the 8x8 font drawn as a k x k block def big(s, x, y, k): w = 8 * len(s) t = framebuf.FrameBuffer(bytearray(w), w, 8, framebuf.MONO_VLSB) t.text(s, 0, 0, 1) for cx in range(w): for cy in range(8): if t.pixel(cx, cy): fb.fill_rect(x + cx * k, y + cy * k, k, k, 1) # SEN55: CRC-8 (initial 0xff, polynomial 0x31), 20 ms command delay def read_words(command, count): i.writeto(0x69, command) time.sleep_ms(20) d = i.readfrom(0x69, count * 3) words = [] for k in range(count): a, b, checksum = d[k*3:k*3+3] crc = 0xff for value in (a, b): crc ^= value for bit in range(8): crc = ((crc << 1) ^ (0x31 if crc & 0x80 else 0)) & 0xff if crc != checksum: raise ValueError('SEN55 checksum mismatch') words.append((a << 8) | b) return words def signed(value): return value - 65536 if value & 0x8000 else value i.writeto(0x69, b'\x00\x21') time.sleep_ms(50) while True: if not read_words(b'\x02\x02', 1)[0]: time.sleep_ms(200) continue w = read_words(b'\x03\xc4', 8) if w[1] == 0xffff or w[4] in (0x7fff, 0xffff) or w[5] in (0x7fff, 0xffff): time.sleep(1) continue pm, rh, temp = w[1]/10, signed(w[4])/100, signed(w[5])/200 fb.fill(0) fb.text('PM2.5', 0, 0) fb.text('ug/m3', 88, 0) big('%.1f' % pm if pm < 100 else '%d' % pm, 0, 11, 3) fb.text('RH', 0, 37) fb.text('TEMP C', 64, 37) big('%d%%' % round(rh), 0, 48, 2) big('%.1f' % temp, 64, 48, 2) show() print('PM2.5', pm, 'RH', rh, 'T', temp) time.sleep(1)
Prueba esto
- Selecciona SEN55 y observa PM2.5 en vivo (ambiente simulado). Varía por sí solo; compara con OLED y Serial.
- Dos dispositivos, un bus: ejecuta I2C(0, scl=Pin(9), sda=Pin(8)).scan() en REPL y encuentra 0x3c y 0x69.
- Compara con el extractor, que convierte esas mismas lecturas en control del ventilador.
- Pasa el cursor por la alimentación SEN55: 5 V, no 3V3. El ventilador lo necesita.



