Example 1 – interfacing a carbon dioxide sensor to the Raspberry Pi

We will be making use of the K30 carbon dioxide sensor (its documentation is available here, http://co2meters.com/Documentation/Datasheets/DS30-01%20-%20K30.pdf). It has a range of 0-10,000 ppm, and the sensor provides it carbon dioxide concentration readings via serial port as a response to certain commands from the Raspberry Pi.

The following diagram shows the connections between the Raspberry Pi and the K30 carbon dioxide sensor:

K30 carbon dioxide sensor interfaced with the Raspberry Pi

The receiver (Rx) pin of the sensor is connected to the transmitter (Tx-GPIO 14 (UART_TXD)) pin of the Raspberry Pi Zero (the yellow wire in the preceding figure). The transmitter (Tx) pin of the sensor is connected to the receiver (Rx-GPIO 15 (UART_RXD)) pin of the Raspberry Pi Zero (the green wire in the preceding figure).

In order to power the sensor, the G+ pin of the sensor (the red wire in the preceding figure) is connected to the 5V pin of the Raspberry Pi Zero. The G0 pin of the sensor is connected to the GND pin of the Raspberry Pi Zero (black wire in the earlier figure).

Typically, serial port communication is initiated by specifying the baud rate, the number of bits in a frame, stop bit, and flow control.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.42.196