Have you ever had a bug in your code that turned you from a rational, reasonable human being to an angry, paranoid person? I’m talking about those times when you’re a 100% sure that your code is correct, so you start thinking there must be something very weird going on that causes it to crash. It gotta be something else! Maybe the virtual machine is broken, maybe it’s a compiler bug! When you’re working with hardware it’s even easier to find reasons. This wire doesn’t look really good, maybe I should replace it. Well, to keep programmers from wondering and wandering aimlessly, debugging tools have been invented. But debugging tools come with a warning. “Not to be used when you’re tired!” Haha!
After the device is initialized and one of the „active measurements” mode is set, the sensor provides samples of data that can be read from the register called (in the datasheet) „Algorithm Results Data”. This is an 8-byte read only register that contains the calculated eCO2 (ppm) and TVOC (ppb) values followed by the STATUS register, ERROR_ID register and the RAW_DATA register(which holds current + voltage). As you can see, the device provides multiple types of information: eCO2, TVOC, current through the sensor, voltage across the sensor. For each of these types of data we are going to define an IIO channel.
Some drivers use a setup/initialization function to set up default values, to put the device in a known state, etc. I defined a function like this for ccs811 sensor:
A driver is described using the i2c_driver struct. In order to register our chip driver, we first need to populate this struct.
In my last post, I described the hardware setup using the UDOO NEO board. UDOO was fun to play with and I successfully managed to make it work with our IIO kernel. However, copying the kernel to the microSD, everytime changes were made, was not very convenient. So, we came up with solutions to this problem and one way of solving this was to boot over network. Unfortunately, this version of UDOO Neo doesn’t have an Ethernet port. Besides, UDOO is a little more complex than we need for our purpose now. So, to speed things up, my mentors equipped me with an USB-to-I2C adapter.
This is the CCS811 Air Quality Sensor.
Do you remember your first coding experience, your very first “Hello world” program? Was it fun for you to see the results produced by your code? Did you feel the need to run it again, to add some more words, did you print some other messages afterwards? Well, I didn’t! I was just staying there and thinking “Wait, how does this work?!”. I wanted to understand the entire process, from high-level software, all the way down to hardware. I wanted to know what a compiler was, how the operating system manages the resources, how the text is displayed on my screen. But as my teacher explained to me back then, these were not questions to be answered in one class. That was in high-school and that’s how I made the decision to study Computer Science. And here I am, just finishing my third year of Bachelor’s Degree at Politehnica University of Bucharest, still getting answers to part of those questions. Hello, world, my name is Narcisa.