This repository contains CircuitPython scripts (programs) for testing the Winsen ZE15-CO carbon monoxide sensor using UART communication on a Raspberry Pi Pico.
Currently included:
- Initiative Upload Mode Test - Reads CO concentration automatically sent by the sensor every second.
- Question and Answer Mode Test - Sends requests to the sensor and reads responses.
Datasheet: ZE15-CO Official Datasheet
- Sensor TX - Pico GP1 (RX)
- Sensor RX - Pico GP0 (TX)
- Sensor GND - Pico GND
- Sensor VCC - Pico 5V
The ZE15-CO sensor communicates using a UART (serial) interface at:
- Baud Rate: 9600
- Data Bits: 8
- Stop Bits: 1
- Parity: None
It supports two communication modes: Initiative Upload Mode and Q&A Mode.
Initiative Upload Mode (Default)
- The sensor automatically sends a 9-byte data packet every 1 second.
- No commands are needed from the microcontroller.
- Each packet contains the CO concentration value in ppm.
Initiative Upload Mode Data Packet Format (9 bytes per packet)
Byte0 Byte1 Byte2 Byte3 Byte4 Byte5 Byte6 Byte7 Byte8
0xFF 0x04 0x03 0x01 [HIGH] [LOW] 0x13 0x88 [CHK]
Byte | Description |
---|---|
0xFF |
Start byte |
0x04 |
Gas type (CO) |
0x03 |
Unit (ppm) |
0x01 |
Number of decimal places (fixed at 0.1 ppm) |
[HIGH] | CO Concentration High Byte |
[LOW] | CO Concentration Low Byte |
0x13 |
Full range high byte (fixed) |
0x88 |
Full range low byte (fixed) |
[CHK] | Checksum |
CO Concentration Formula:
CO ppm = (HIGH * 256 + LOW) * 0.1
Example:
Received Data: ['0xFF', '0x04', '0x03', '0x01', '0x00', '0x05', '0x13', '0x88', '0x58']
- HIGH =
0x00
(0 in decimal) - LOW =
0x05
(5 in decimal) - CO ppm = (0 * 256 + 5) * 0.1 = 0.5 ppm
Question & Answer (Q&A) Mode
- The microcontroller sends a command request to the sensor.
- The sensor responds with a CO concentration reading.
Q&A Mode Request Data Packet Format (9 bytes)
0xFF 0x01 0x86 0x00 0x00 0x00 0x00 0x00 [CHK]
Q&A Mode Response Data Packet Format (9 bytes)
0xFF 0x86 [HIGH] [LOW] 0x00 0x00 [HIGH] [LOW] [CHK]
- Install CircuitPython on the Raspberry Pi Pico. (Guide)
- Copy
code.py
to the Pico. - Open a serial terminal (Mu Editor, Thonny, or screen).
- View CO ppm readings which update every second.