PiicoDev Air Quality Sensor | Guide For Raspberry Pi

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
the picadev air quality sensor is a multi-gas sensor that detects volatile organic compounds things like ethanol oxidizing gases and even byproducts of human respiration and Metabolism the sensor is capable of sampling these gases and producing outputs for total volatile organic compounds equivalent CO2 and air quality index these metrics are commonly used to monitor indoor air quality and control ventilation systems today I'm going to show you how to get started with your picadev air quality sensor and a Raspberry Pi single board computer we'll connect these two together and get some example code running to read different air quality metrics first a closer look at the sensor [Music] he could have air quality sensor features two picadev connectors for daisy chaining connections with other Pica Dev Hardware there's an address switch labeled ASW this is used for uniquely addressing a second air quality sensor leave the switch in the off position for now to follow along you'll of course need a Raspberry Pi singleboard computer set up to run like a desktop computer check the article if you need help getting started there a picadev air quality sensor of course a pickerative adapter for Raspberry Pi and a pikitive cable to connect everything together connect the adapter to your pi and on a Raspberry Pi 4 there will be an arrow pointing towards the ethernet connector connect one end of your picado cable to any of the sockets on the adapter and connect the other end to your air quality sensor make sure this ASW switch is off once again I'll connect my keyboard and mouse a network lead display and finally power with your Pi booted up first make sure that the I squared C interface is enabled open the pi menu preferences and go to Raspberry Pi configuration and just make sure under the interfaces tab that i2c is set to enable next open funny from the programming menu and make sure you're running the latest version of Pico Dev go to tools manage packages and search Pico Dev that's with two eyes here it is and when you click through make sure that you have installed or upgraded as necessary in the article for this tutorial find the example reading air quality metrics and highlight all of that code and paste it into a new script in thoni where ready to run press the Green Run button and if prompted to save I'll just save this as air quality air underscore quality Dot py and I'm saving that to a picadev directory in my home directory click OK and here we have some air quality data streaming through the shell if I wave some error over this we ought to see that data change I'll stop the script so it stops scrolling and let's have a look at this data we have something called aqi which has a value of 2 which is good we have t-voc which is 135 parts per billion eco2 which is 605 parts per million and that's good and we have status warm-up let's have a look at each of these metrics in turn air quality index or aqi is an index that was developed in Germany but is recognized internationally it's a scale of one to five to represent the air quality we can see one correlates to a rating of excellent and 5 to a rating of unhealthy and there's also a few exposure and ventilation recommendations similarly for equivalent CO2 this sensor doesn't directly measure CO2 but in first the concentration based off other volatile organic compounds eco2 is also used in industry and has similarly a rating and a ventilation recommendation range and as for t-voc or a total volatile organic compounds this is really what the sensor is measuring it's measuring the concentrations of different gases and this is really the output these other ratings are rather inferred by algorithms that are running on the chip now my Chip's been running for a little while you may have noticed initially it was showing the status warm-up and now it's showing the status operating okay it's very likely that your sensor will be showing the initial startup status but what does that mean the picadev air quality sensor has three states initial startup warm-up and operating okay when the sensor first powers on it will be in this initial startup state which lasts up to an hour you can still use your sensor right away in this state but the accuracy will be improved once the sensor has warmed up if the sensor is allowed to run continuously for at least 24 hours it will never need this long initial startup process again instead it will perform a much faster warm-up which only lasts a few minutes let's do an experiment I have some sanitizing alcohol here which will produce a fume a volatile organic compound and if I uncap the lid and then waft some of that some of those Vapors down look look at that and immediately we have an aqi of five or unhealthy and if I remove the alcohol from the equation I clear the air around the sensor we should go back to a much more suitable air quality index and you can see that data correlate in the other two indices as well let's look at how the code works I'll stop The Script now we can see on the first line we import the device module the driver for this sensor the ens 160 we'll also import a function to create a short delay next up we call the initialization function this returns a sensor object that we assign to the variable sensor so anytime in the script where you see sensor that is referring to this physical air quality sensor then there's an infinite Loop and we query sensor.aqi to get the air quality index property sensor.tivoc and sensor.eco2 and we store those in equivalent variables now these return more than just a number you can see from our prints that aqi is returning a value which is in this case 2 and a rating or description which is good so when it comes to our print statement we can print aqi and then we can print the value of the aqi the numeric value but we can also print aqi dot rate which is that English word description and that's really neat because it means we don't need to do any logic we can just extract the number or in words what the rating is which can be useful for feedback or for data logging perhaps tivock does return just a number so here we just print the value of t-voc but similarly for aqi eco2 is present with a value and a rating and so since air quality is often used to drive say ventilation or to create some kind of alarm let's do a Code remix let's make it such that the Raspberry Pi will remind us to turn on the fan if the aqi goes above say three I will remove all of this code will keep the aqi line and we'll just add the following logic if aqi dot value is greater than three print turn on the fan we can rerun the script and hey we have an aqi that is one excellent but if we introduce our volatile organic compound sample and I'll just waft some of those Vapors over the sensor immediately we've shot from one up to five and we should turn on the fan now it's possible to read up to two air quality sensors on the same Pico Dev bus the only requirement is that they each need a unique address switch setting this is my second air quality sensor and I've set the address switch to on so now I have my original sensor which has its address switch off and my new sensor with this address switch on and I can add that to the end of my daisy chain find the code example for connecting to multiple sensors and we can see the diagram here where we have two sensors each with a different address switch setting copy the example code and I'll paste that into a new script I'll save that as multiple sensors dot p y and we'll run this script now in the Shell we have two values being printed A and B A is the value coming from our first sensor and B is the value coming from our second sensor here we're reading the total volatile organic compound the numbers are quite different and that is because this sensor has already been through its warm-up and this is a brand new sensor that's probably still in the initial startup phase with similar Imports at the top of the script we now have two sensors and so we're going to call the initialization function twice one for each sensor sensor a our first sensor is being initialized with the address switch off and sensor b the second sensor is being initialized with the address switch on here the zero and the one refer to the state of that switch now we have two sensor objects in our code and so we can read sensor a.tvoc and sensor b dot T lock we can access the unique properties of each unique sensor independently and finally we just have a print that prints the value as shown from each sensor and so there you have it we were able to connect a picadev air quality sensor to a Raspberry Pi and read three different air quality metrics we even did a Code remix where we could change the state of something based on the air quality in this case we were able to print a helpful message when the air quality became too poor and of course we can read two sensors independently if you make something cool from this startup project or you just have some questions let us know on our forums we're full-time makers and happy to help until next time happy making foreign
Info
Channel: Core Electronics
Views: 9,321
Rating: undefined out of 5
Keywords: electronics, maker, education, tutorial, technology, How To Use ENS160 Air Quality Sensor With Raspberry Pi, How To Program ENS160 Air Quality Sensor With Raspberry Pi, How To Program An Air Quality Sensor With Raspberry Pi, How To Measure Air Quality With Raspberry Pi, How To Code An Air Quality Sensor With Raspberry Pi, Raspberry Pi ENS160, Raspberry Pi Air Quality Sensor, Raspberry Pi, ENS160, Air Quality Sensor, Measure Air Quality, How To, Guide, PiicoDev, Tutorial
Id: VjVSkd2II1s
Channel Id: undefined
Length: 10min 38sec (638 seconds)
Published: Tue Oct 25 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.