We will make use of the pySerial library (https://pyserial.readthedocs.io/en/latest/shortintro.html#opening-serial-ports) for interfacing the carbon dioxide sensor:
- As per the sensor's documentation, the sensor output can be read by initiating the serial port at a baud rate of 9600, no parity, 8 bits, and 1 stop bit. The GPIO serial port is ttyAMA0. The first step in interfacing with the sensor is initiating serial port communication:
import serial ser = serial.Serial("/dev/ttyAMA0")
- As per the sensor documentation (http://co2meters.com/Documentation/Other/SenseAirCommGuide.zip), the sensor responds to the following command for the carbon dioxide concentration:
Command to read carbon dioxide ...