PiicoDev Atmospheric Sensor BME280 | Raspberry Pi Pico Guide

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
let's read atmospheric data like temperature humidity and air pressure from our pico dev atmospheric sensor using a raspberry pi pico i'll show you how to connect these two together run some example code to get those readings and did you know you can also infer changes in altitude based off air pressure really easy i'll show you how we do that as well let's get started [Music] to follow along you'll need a raspberry pi pico with pins soldered facing down a pico dev atmospheric sensor and expansion board for raspberry pi pico and a picket of cable to connect everything together start by connecting your pico to the expansion board making sure that the usb connection is on the same side as the 2 pin battery connector you can double check that pin number 0 on the expansion board is to the left side of that usb connector connect your pico dev cable into the port at the bottom of the board and connect the other end to your atmospheric sensor and i'll use a picot of platform to keep everything nice and secure and connect to your computer with a usb lead find the download section in the article for this tutorial and download the three files you'll need right-click each link and select save link as save them somewhere that makes sense i'm using a folder that i've made in my documents folder open funny and use the file pane to navigate to where you saved your files if you need help getting started with sony we have a tutorial for that too just briefly the pico dev unified file and the bme 280 file are drivers for driving these picodev modules the main.py file is the user code for this project upload all three files to your pico with a shift click a right click and then upload two and now we can see the three files appear on our pico press ctrl d to restart the pico and we should immediately see weather data streaming up the shell so in the studio today it's 18 degrees the air pressure is at about a thousand and four hectopascals which is the same as millibar and we're at 70 relative humidity press control c to stop the execution of the script and we'll edit the file that's directly on the pico so coming down to the raspberry pi pc menu double click main dot py and this is the example code for this tutorial we start off by importing the pkdev atmospheric sensor module and also a function to sleep so that we can create a delay we initialize the sensor using the initialization function and also zero altitude so we take a altitude reading from the sensor and we assign that to a variable called zero out more on that later in the infinite loop we just read temperature in degree c pressure in pascals and humidity in percent relative humidity by calling the sensor.values function remember the sensor is the instance of our atmospheric sensor we then do a little conversion to convert from pressure in pascals to pressure in hectopascals by dividing by a hundred and then we just print the data to the console so you can see this print statement we print temperature c but we convert it to a string first and then concatenate it with degrees celsius and we repeat that for pressure and 4 percent relative humidity finally there's just a 100 millisecond sleep so what's going on with the zero altitude here well in the second part of the infinite loop we have a different print statement if i uncomment that with alt 4 and i'll comment out the first print statement with alt 3 that means that our plot will look a bit nicer we can take a look at what's happening in this print statement we're once again calling sensor.altitude which we were calling before in the initialization but this time we're taking the difference of the current altitude with the zero altitude so it's like we're taking the relative altitude measurement from when we first started the pico when we first started executing the script if we save the script with control s and then reboot with control d now we're reading difference in altitude and you can see there's a little bit of noise in the measurement but in general the line is quite flat once this once this rescales we can see the noise it looks like it's between 20 25 centimeters and negative 25 centimeters maybe up to half a meter in either direction we can actually initialize the sensor with a little bit of filtering when we initialize the sensor we can pass it the argument iir and that's for an infinite impulse response filter and i'm going to set the iir filter parameter to 3. i'll save that again and when we rerun the script there's a lot less jagged noise in this signal now and that's going to be really useful because now if i raise the sensor the scale has just rescaled but if i raise the sensor we can see that line trends upwards and then as i lower it we can see it trends back down that's pretty amazing we we just raised the sensor by what half a meter or something maybe we can see we're at about 25 centimeters and now we're at about well where does it stay becomes stable we're at about 90 centimeters and that you know that seems about right that means that we can if we can infer altitude differences of less than a meter using just air pressure we've been editing the file that is on the raspberry pi pico and you can tell because the main.py title is wrapped in these square brackets square brackets means it's on the device if we open the file that's on our computer it still looks like it did when we download it we're still just running the first print statement if you want to save your changes then you can stop the script with control c right click that main.py file and download it to our local computer you'll get a warning that we're going to overwrite the existing file that's okay for now and now when we open the file on our computer it's with the changes that we created we've got the the first print commented and the second print uncommented so we've downloaded the file from our pico and there you have some fast atmospheric data using a pico dev atmospheric sensor and raspberry pi pico i'd love to see what you make from this starter project let us know over on the core electronics forums if you make something cool or if you just have some questions thanks for watching
Info
Channel: Core Electronics
Views: 6,254
Rating: undefined out of 5
Keywords: How To Use BME280 Atmospheric Sensor With Raspberry Pi Pico, How To Program BME280 Atmospheric Sensor With Raspberry Pi Pico, How To Program An Atmospheric Sensor With Raspberry Pi Pico, How To Measure Temperature With Raspberry Pi Pico, How To Measure Barometric Pressure With Raspberry Pi Pico, How To Measure Humidity With Raspberry Pi Pico, Raspberry Pi Pico Atmospheric Sensor Measure, Raspberry Pi Pico, BME280, Atmospheric Sensor, How To, Guide, PiicoDev, Pico
Id: mn8f9a9vDlg
Channel Id: undefined
Length: 6min 49sec (409 seconds)
Published: Mon Jul 19 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.