#sensor

2 posts
Replying to @michael
michael
@michael
Public en edited
Photo of Raspberry Pi Pico connected to CozIR Ambient CO2 sensor with jumper wires
Photo of Raspberry Pi Pico connected to CozIR Ambient CO2 sensor with jumper wires

@michael

MicroPython version of CozIR Ambient demo script:

from machine import UART, Pin
import time

uart1 = UART(1, baudrate=9600, tx=Pin(4), rx=Pin(5))

uart1.write(b'K 2\r\n')
uart1.flush()
time.sleep(1)
print("COZIR CO2 sensor ready\n")

uart1.write(b'Z\r\n')
time.sleep_ms(100)
discard = uart1.read(10)

while True:
    uart1.write(b'Z\r\n')
    time.sleep_ms(10)
    resp = uart1.read(10)
    resp = resp[:8]
    fltCo2 = int(resp[2:])
    print("CO2 (ppm) = " + str(fltCo2))
    time.sleep(1)

Upload script to Pico and run:

(.venv) $ mpremote pico cp cozir.py :cozir.py + exec "import cozir.py" 
cp cozir.py :cozir.py
COZIR CO2 sensor ready

CO2 (ppm) = 802
CO2 (ppm) = 802
CO2 (ppm) = 810
CO2 (ppm) = 808
^C(.venv) $ 

#MicroPython #RaspberryPiPico #CO2 #sensor

Photo of CozIR Ambient CO2 sensor, Raspberry Pi Pico 2 W on a breadboard and a plastic box with jumper wires, all placed on a laminated pinout diagram
Photo of CozIR Ambient CO2 sensor, Raspberry Pi Pico 2 W on a breadboard and a plastic box with jumper wires, all placed on a laminated pinout diagram
Load older posts