Lesson 96: Barometric Pressure, Temperature, Approximate Altitude Sensor BMP390 with LCD

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi welcome to an Arduino  step-by-step course by Robojax we are going to measure temperature pressure  and approximate altitude and display it on the   serial monitor then I’m going to test it with  measuring approximate altitude at 25th floor   to see the difference between first floor  and 25th floor and I’m going to show you how   to display it on a lcd screen 1602 with two  line and we are going to display it on the lcd   with four lines then I’m going to demonstrate  how to control a relay where you can control   a load heater or cooler or whatever you want with  this I’m going to provide you the code so you can   use two or more of these sensors at the same time  wiring diagram for bmp3 and if you purchase this   this pink sensor of bmp390 we are reading to  minus 10 degrees Celsius 13 degrees Fahrenheit this is a bmp 390 barometric pressure temperature  and approximate altitude sensor this is very   precise with comparing to bmp 180 bmp 280  and other previous versions and because of   the precision I was I’m making this video the  actual sensor is this tiny sensor the rest of   the components are making it possible to be used  with spi and I square c all the resistors whatever   is needed and also there is a voltage regulator  so you can use this with 3.3 volts and 5 volts   here I’m connecting it to 3.3 volts and it works  fine and you so you can connect it to 5 volts or   3.3 volts that's like this with these cables and  connectors and I have no idea where to use this   and where this will be used but anyway they also  provided with this header where we can solder it   either from this side because the sensor is on  the other side I believe we should solder it in   here the sensor is also sold in this type of  package 8.80 cents with four dollar shipping   if you're connected to external five volts if  this one is five volts it goes to the regulator   and comes back you can output or get hundred  milliampere three point three volts from this   pin so this is output pin for 3.3 volts if you  connect 5 volts here the logic level do not worry   if you connect even 5 volts or 3.3 volts there is  a logic level converter which will take care of   everything so it can work with 3.3 volts logic or  5 volts logic no worries also you can also display   temperature in Celsius for example if you want  Fahrenheit pressure and hectopascal altitude   approximate altitude based on the pressure from  sea level so we are displaying it on their cd   either lcd 1602 or lcd 204 and four lines   so this will be very easy if you followed my  previous lectures I have full explanation of   this lcd and how to use it the link for that  video is below the video in the description and here is the manufacturer website Bosch  that's a German manufacturer and the pressure   sensor bm bmp390 height of the sensor is 0.75  millimeter the width is 2 millimeter and what   length is 2 2 by 2 by 0.75 millimeter these  are the characteristics of the actual sensor so the pressure that can measure is  from 300 pascal up to 1250 hectopascal   and the vddio the input output the voltages  are 3.6 volts the supply voltage is 3.3   volts here up to 3.6 but we have here a  voltage regulator which will work with   5 volts interface can be I square c or spi which  current that it consume is 3.2 microampere at one   hertz every second it will update the data  at one hertz absolute accuracy of pressure   is plus minus 0.5 hectopascal at between 0 to  65 degrees Celsius with this range relative axis   accuracy of pressure plus minus 0.03 hectopascal  that's equivalent to plus minus 25 centimeter   so pressure that we are measuring  or the altitude it will vary   minimum of plus minus 25 centimeter  long term stability is in 12 months   it will go up plus minus 0.16 hectopascal  maximum that's the most important one   maximum sampling rate is 2200 hertz so in one  second it can read the data up to 200 hertz and here's the wiring diagram for bmp 390  with Arduino uno the VIN is connected using   orange wire to 5 volts ground is connected  using yellow wire to ground scl is connected   using green wire to the last pin this is  scl pin and sda is connected using blue wire   to the second last pin connect scl to the  last pin in here and sda to the last second   or a4 where blue wire and if you purchase this  pink sensor of bmp 390 vcc is connected using   orange wire to 5 volts ground is connected  with yellow wire to the ground scl is connected   using green wire to the last pin and sda is  connected using blue wire to the last second pin you can also connect scl to the last pin in  here and sda to the last second or a4 with the   blue wire and here is my wiring orange wire from  this top from this side is connected to 5 volts   of Arduino connecting it to 3.3 volts and it works  fine one pin is empty the third pin is ground I’ve   been connected using yellow wire to ground off  Arduino and then scl is connected using this   green wire to scl and here and blue is sda  it has been connected to if the airplane sda blue can be also connected here  to a4 and scl can be connected to a5   so you can use that for something else so this  these pins are exactly the same as these two pens here is wiring diagram for bmp390 with lcd we are  connecting VIN to pin 12 this has been defined as   extra 5 volts in the code ground is connected  using yellow wire to the ground on this side   scl is connected to the last pin sda is connected  to the last second this is for the sensor for the   lcd ground is connected using this brown  wire to ground vcc is connected to 5 volts   sda using orange wire is connected to analog  4 or a4 scl is connected to a5 if you're using   this pink module for the lcd it's exactly the  same but here vcc is connected to 12 volts ground   is connected to the ground scl is connected to  the last pin SDA is connected to the last second   I’ve connected the 5 volts or vcc  to pin 12 we are I’ve defined it as   power or vcc for this module and yellow the ground  the ground pin is connected to the ground and then   we have green scl I’ve been connected to the  last pin sda is connected to the last second pin   so these are sda and scl so the sensor is  connected to this pin for this lcd I’m showing   you very close up so you can see it ground  this and here ground is connected using this   brown wire to ground the next pane is vcc  this vcc is red I’ve been connected to 5 volts   sda is orange it has been connected to a4 and  last one is scl it has been connected to a5   and here's the wiring if you want to use  the spi all the pins have been connected   from this side in the same order I put them here  so the first pin the interrupt is not used the cs   pin have been connected to pin 10 the ground is  connected to ground and the last one is connected   to 3.3 volts you can use it to 5 volts as well  if you found this tutorial helpful please thumb   up and also click on the subscribe on the right  side in the lower corner I really appreciate it now let's install the library click on  sketch include library manage libraries wait for this to complete until  you can type and here type bmpmp3x and here you got other adafruit  bmp3xx and click on install df robot also has a library we're going to  install that as well so the installation is   complete close this now we can open one  of the examples go to file examples and scroll down adafruit bmp3x and here is this simple test  let's open it now let me explain the code   after you install the library this wire is for I  square c communication we do need the spi because   we need to use very little wires and these are  all definition for spi if you want to use these   pins connect them like that you can leave that but  I’m not going to use it because these are extra so   this is the default hectopascal value for c level  pressure and here we are defining bmp whatever   name you want you can put another name here this  is just an object from this instance of the class   inside the setup we just print set the serial  monitor two hundred fifteen thousand two hundred   if I click on tools serial monitor on this  right side you will see that is the number   and it this line checks if the serial is not  available keep it and wait forever and don't   do anything if the serial otherwise it print  this on the screen and here this one checks if   bmp dot begin I square c is not true or not  available then again print this could not   find bmp3 and while one while one mean the same  as this it means wait forever so the program will   stop at this point and these are if you uncomment  them these will be used for two types of hardware   spi and software spi which are we are not going  to use so that's why they have been commented out   and these are some of the over sampling  and filtering initialization that   is set by the manufacturer and  it has been implemented here   do not worry about these and this is  the over sampling issue eight times   here set the pressure that's at temperature  over sampling pressure filter coefficient   3 and frequency is 50 here which means the  output data it will read it 50 times a second   now that this code will run only once inside  the loop this says f bmp perform reading if   this can read it will be true otherwise  false so if this is false then print this   and exit it says failed to perform  reading otherwise if this is not true then   we have this text temperature bmp dot  temperature so this is the value that we need   and this will print the letter c at the end this  is one line print and the last one is print ln   so this will create another line after this  we have a new line and then we have pressure   you see this pressure divided by 100 it converts  it to hecto otherwise the pressure is just pascal   it will not be hectopascal because hectopascal  is readable so we def divided by 100 so this is   another line and then it says approximate  altitude here it says bmp read altitude   c level pressure and hectopascal is  passed to this function of bmp object   and it's a print approximate altitude and it  prints m at the end so it looks like meter   and then we are creating another separate line  wait two seconds so of course you can change it   you don't have to set it to two seconds make it  and this sensor can go up to five milliseconds   which will be very fast but make sure to remove  all these uh serial print values you cannot print   it this fast so remove this and use the pressure  or temperature or whatever you have in your   application let's say you want to use some  pressure for something this is a temperature I’m   copying it and you want to take some action let's  say you want to turn on a relay so here you say f   temperature is greater than 38  degrees let's say you want to   check the temperature if it is greater than  38 degrees open and close and here you can   turn a pin on or do something turn a device  camera whatever you want or send us a mess   but for simplicity let's say you want to turn  on pin 10 which is connected to a relay so digital right and 10 high so 10 will be high else digital right and then low so this was just a very  simple action but you can have multiple statement   multiple uh thing that you can do this was just  for temperature you can do the same thing for   altitude you can do the same thing for pressure  and take action if you're my student and following   my course you should already have your system  ready for lcd otherwise watch the video because   I’m not going to explain it here fully but quickly  how to install the driver for this I will provide   you the link download the file the library  for this lcd click on sketch include library   add the zip library and then point  it to where you have saved it   if this was the zip file select and click  open and it will be installed next in the code this is part of the Arduino you do need  to do anything the wire is for I square   c communication I’m defining here an integer bmp  VIN pin this is a voltage for bmp and I’ve defined   pin 12 you can change it to another print that  you wish and this is just Boolean for Fahrenheit   I was trying to do for something it's just  extra this line is lcd liquid crystal i2c   this is for the lcd and here we are defining  from the same class we are getting the instance   of the class and creating an object called an  object called lcd and we pass here the address   for the lcd 0x3f and then 16 means 16 line and two  mean 16 characters sorry and two mean two lines to   get this address you need to I square c uh scanner  I will provide you here this is a square c scanner   I will provide you the code download and  install it and upload uploaded your Arduino when you are uploading this make sure to  disconnect the sensor this is just for the   lcd if I open it now you will see that I’m  reading two address if I this is for the   module and let me disconnect that you will  see that we are reading only one address 0x   before it was 2 for both of them so this  is for the lcd I’m just closing it I will   provide you the length for this so that is the  address that we are reading from that screen   inside the setup we are defining the bmp VIN pin  the voltage pin as an output and in the next line   immediately we are getting the same pin and we  are setting it to high so this will generate   five volts at this pin which we define here pin  12 so we don't need to use breadboard or anything   this is just defining the serial  monitor to print some text for us   I’ve explained this before in the previous  introduction I’m not going to explain it this   line is initializing their cd this is turning on  the backlight this is just printing that object's   text on the screen and this is just  printing the text on the screen you will see that we are reading only one address  0x before it was 2 for both of them so this is   for the lcd I’m just closing it I will provide  you the length for this so that is the address   that we are reading from that screen inside  the setup we are defining the bmp VIN pin   the voltage pin as an output and in the next line  immediately we are getting the same pin and we are   setting it to high so this will generate five  volts at this pin which we define here pin 12.   so we don't need to use breadboard or anything  this is just defining the serial monitor to print   some text for us I’ve explained this before in the  previous introduction I’m not going to explain it   this line is initializing their cd this is turning  on the backlight this is just printing that object   text on the screen and this is just  printing the text on the screen text is the text that you're  reading now here and this is bmp   390. that's the text on the second one this will  run only once and then you will not see it again inside the loop this line is clearing the  screen so every time we read it we have to   clear the screen and this line lcd display  is a function at the bottom of the code   which I have written to display first we put  the character character 0 for example let's wait   for this and then yes character zero line zero  this means line zero and then we put this text   that is the text that you saw as a Celsius and then we did not worry well space and then  this space is being printed on the screen   and then 99 means we don't  worry where this text is   happening I just put that number because we  don't have 99 and then line mean at line zero and here this get bmp if you want  print if you want to print Celsius   you just put Celsius and here we put the unit so this line if you want to print it as a Fahrenheit  just wait you will see it print f hr Fahrenheit   because one height was long I just put it as  dot and at character nine it goes and prints it   and here we just getBMP so if you want Fahrenheit  and this is the unit after that after four seconds   we clear the screen again and then we print the  pressure pres. and then actual pressure reading   here we say get bmp and this line is  printing the approximate altitude ap out   approximate altitude we use a and then the unit  is m meter get bmp when we pass the character   here this is reading the temperature and we check  if it is Fahrenheit then the temperature we are   multiplying it by this value and adding so it  becomes Fahrenheit and we set it as a value   if somebody asked for kelvin we type add the  temperature to we add 273.15 to temperature   that's kelvin if somebody wants pressure we get  the pressure divided by 100 so it big it will   become hectopascal and if it is a altitude then  we get the altitude else we get the temperature   which is the just regular temperature and we  return the value so this is getting the value   I’m going to show you how it is displayed and here  that lcd display all those information that we are   passing this sets the character where to start  printing the value because we print the text and   then we press the print the value this is printing  the title that you are passing whatever it is   Celsius pressure whatever and then we check if it  is not 99 which means set the cursor to somewhere   otherwise we don't set it and then we print  the value whatever is this value either   temperature pressure altitude and after  that we print the symbol if it is c   we say print this degree series here  this round is printed using character 233   and then we print c and then if it is Fahrenheit  you print f or pascal all these units are printed   uh using these values here hectopascal meter  print m and that's it so this was the full   explanation of the code and here is the code  for using it with 204 everything is the same   except you have to type here 20 for number of  characters and four and of course you have to   put the I square c or I to c address using the i2c  scanner and here's the code if you want to use the   spi communication these pins have been used  here pin 13. in order 10 11 12 13 these are   from right to left on the module exactly the  same from here so that's that goes to 10 11 12 13   in the same order that you see them in here  and here inside the setup I used this line   that uses all those pin definition  and passes them to library   the rest of the code is exactly the same if  you found this tutorial helpful please thumb   up and also click on the subscribe on the right  side in the lower corner I really appreciate it so here is a sensor let me open the serial monitor  and here this is now showing the value like that and it shows 23.9 degrees Celsius   the pressure and that's approximate  altitude based on the pressure 127.56 now I have this heat gun let me apply some heat I   have to be careful not to burn it because  this has a limit up to 90 degrees Celsius so I just stopped it now still it's  sensing 56 59 degrees Celsius 61 and 64 even still now I think it should go  backwards slowly because it's stopped now yes so now it's going down if I put my  finger and cool it down it might go faster so the and here is the demonstration with bmp390 on  lcd it shows the degrees Celsius and degree   Fahrenheit then the pressure and hectopascal and  also approximate altitude so it's just rotating   I’m just providing this demonstration for uh  learning purpose so we might not need everything   I’ve explained the code fully so you  can remove any element that you want   out of this applying some  extra heat with the heat gun so you will be able to read it and  here I hope it doesn't burn my hand so now let me apply I applied a lot of heat so let's wait 52 degrees and 69 and that's in Fahrenheit 126.   so the sensor is just printing whatever  speed you want so that's the pressure and just let's wait altitude 105.2 mil 105  meter at the moment based on that pressure   and here is a demonstration using the 2004  with 20 characters and 4 line where you can   see everything on the same page temperature  in Celsius temperature in Fahrenheit   the pressure in hectopascal and approximate  altitude all in one with the same sensor let me demonstrate it I’ve set the start  temperature to 30 and stop at 45 so I can test it   and you will see the result  quickly but for real life   application this will be like whatever you want   very close like two three degrees difference in  between but this is just a demonstration right now and I will apply this heat gun you will read the  temperature here at the moment it is 22 degrees   Celsius of this sensor and I’m  applying some heat using this heat gun so you will read it in here when it  reaches at 45 it will turn off as you can see it says relay off and  the light is off it's now almost 54. now this light is off which means the relay is  off which means the heater is now off because   the temperature is very high when the room  gets cooler back to 30 it doesn't allow it   to go below 30 so the heater will turn on so this  will be connected to heater where these terminals   and here so the relay will keep your heater on  until it reaches back to 45 so right now it's   50 52 degrees let me cool it down by putting  my finger maybe so if it gets cooler yeah 46   now this will turn on as you can see it  turned on at 30 so the heater is now working   to heat up and then when it reaches back  to the stop level it will just stop it and here for elevation test I’m going to  go to this spot in ajax Ontario, Canada. this is the spot I’m gonna go to  this building on the 25th floor   first we have to test the altitude at this spot  this is the ice skating field I’m sitting in here and here this is a project and we are reading minus 10 degrees  Celsius 13 degrees Fahrenheit and strangely enough I’m getting minus 15. area so I’m going to go at the 25th floor   there and then measure at this point when  I measure the temperature and altitude I’m going here at the 25th floor and here here on google earth it  shows the elevation of this   spot is 85 meters also on the right  corner here you can see the elevation and now I’m going to the 25th floor look so 25th floor let's go and yes this is where I was at the bottom now  here I’m on the 25th floor and here we are mommy and we're reading 57.2 meters and on the  first floor it was showing minus 14. so so minus 14 plus this number minus  15 plus this it would make sense   so that is approximate altitude and the  suppression shows 18 I just opened the window but   the room is around 20 to 23 degrees this is just  close to the window and here the 20 foot below   and head of the project minus 10 degrees Celsius minus 9.89 please make sure to subscribe by clicking  at the subscribe button in here thank you   thank you for watching tutorial from Robojax  if you learned something and found this useful   please thumb up as this will help my  video in the search algorithm of YouTube   if you have comment or question please  post it at the comment section below   I try to answer and reply and don't forget to  subscribe to get updates on my upcoming videos
Info
Channel: Robojax
Views: 7,470
Rating: undefined out of 5
Keywords: tutorial, training, video, robojax, download, step by step, course, bmp390, temperature, pressure, approximate, altitude, lcd, lcd1602, lcd2004, library, elevation, measure, action, relay, I2C, spi, how to
Id: XevQYG_A5xA
Channel Id: undefined
Length: 37min 42sec (2262 seconds)
Published: Sun Jan 16 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.