💾 Archived View for jaeyoung.se › posts › breath-sensor captured on 2023-04-26 at 13:12:43. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-03-20)
-=-=-=-=-=-=-
date = 2021-11-09 tags = ["hardware"] title = "Controlling CO2 sensor and HD44780 LCD display with Raspberry Pi and Go"
This is a digital gas sensor
and an LCD display
, controlled by Raspberry Pi, that I wired together back in 2019. The CS811 sensor reports two values: 'equivalent carbon dioxide' (eCO2), and 'Volatile Organic Compounds' (VOC), PPM. I am not too sure what those terms mean, not strong on chemistry, anyways I wired it to display the reported values on LCD display continuously. I assume high values mean bad. It can be seen that the values jump momentarily when I blow on the sensor.
There are plenty of guides and libraries for this kind of thing on the Internet, but, for me then, this electronics hobby thing wouldn't have felt like a hobby if I just followed guides and used libraries. So I used Go to write all codes for it (sans the operating system), which was the language I was into then, and still am.
These days, if I were to interface with an unknown hardware or software, I'd always reach for Python, to play with it first. I find Python and its interpreted environment simply superior for exploring and prototyping compared to using compiled languages.
Also, I'd just use a library.
At first, I was concerned that I'd have to use C or low-level instructions to control the hardware ports on RPi, but it turned out Linux provides a neat set of ioctl commands for that use, at least for the I2C ports. So no need to leave Go.
I grabbed
by this Japanese guy, for controlling I2C ports, and the rest was the datasheets.
https://cdn.sparkfun.com/assets/2/c/c/6/5/CN04-2019_attachment_CCS811_Datasheet_v1-06.pdf
https://www.sparkfun.com/datasheets/LCD/HD44780.pdf