Back to Step by Step Course by Robojax

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

Please select other codes for this lecture from the links below.

  • Purchase it from Amazon USA
  • Purchase it from Amazon Canada
  • Purchase it from all other Amazon
  • Purchase it from AliExpress
  • Purchase it from Banggood
  • BMP390 Bosch Official Product page
  • Part 6: Temperatures Sensors

    In this lesson BMP390 is explained, wiring shown for I2C and SPI. Then shown to display barometric pressure, temperature and approximate altitude on the serial monitor, on LCD1602, on LCD2004. Full wiring diagram and wiring shown. Library installation shown and approximate altitude is measurged on first floor and compared it with altitude on 25th floor. Code is fully explained and demonstrated using Arduino UNO and Arduino MEGA.

    • 01:19 Introduction
    • 03:42 Datasheet viewed
    • 05:42 Wiring Explained
    • 10:26 Code and library Explained
    • 16:51 LCD library and code
    • 25:26 SPI code settings
    • 26:17 Demo: Basic
    • 28:03 Demo: LCD1602
    • 29:41 Demo: LCD2004
    • 30:02 Demo: Thermostat
    • 32:07 Demo: Altitude on ground and 25th floor

    Affiliated with Amazon USA

    Affiliated with AliExpress

     * Lesson 96: Using Precision BMP390 Barometric Pressure and Temperatrure Sensor
     * with Arduino
     * Wath video instruction on YouTube:
     * Code updated by Ahmad Shamshiri for
     * on Jan 13, 2022 at 17:10 in Ajax, Ontario, Canada
      This video is part of Arduino Step by Step Course which starts here:
    If you found this tutorial helpful, please support me so I can continue creating contents like this
    and make donation using PayPal
      This is a library for the BMP390 temperature & pressure sensor
      Designed specifically to work with the Adafruit BMP388 Breakout
      These sensors use I2C or SPI to communicate, 2 or 4 pins are required
      to interface.
      Adafruit invests time and resources providing this open source code,
      please support Adafruit and open-source hardware by purchasing products
      from Adafruit!
      Written by Limor Fried & Kevin Townsend for Adafruit Industries.
      BSD license, all text above must be included in any redistribution
    #include <Wire.h>
    #include <Adafruit_Sensor.h>
    #include "Adafruit_BMP3XX.h"
    #define SEALEVELPRESSURE_HPA (1013.25)
    float temperatureC, temperatureK, temperatureF, pressure, altitude;
    Adafruit_BMP3XX bmp;
    void setup() {
      while (!Serial);
      Serial.println("Adafruit BMP388 / BMP390 test");
      if (!bmp.begin_I2C()) {   // hardware I2C mode, can pass in address & alt Wire
      Serial.println("Could not find a valid BMP3 sensor, check wiring!");
        while (1);
      // Set up oversampling and filter initialization
    void loop() {
      if (! bmp.performReading()) {
        Serial.println("Failed to perform reading :(");
     Serial.print("Temprature C: ");
     Serial.println(" C");
     Serial.print("Pressure: ");
     Serial.println(" hPa");
     Serial.print("Approximate Altitude: ");
     Serial.println(" m");
      if(temperatureC >38.0)
       digitalWrite(10, HIGH); 
        digitalWrite(10, LOW);
     *  readValues()
     * @brief reads the temperature based on the TEMPERATURE_UNIT
     * @param average temperature
     * @return returns one of the values above
     * Written by Ahmad Shamshiri for
     * on Jan 15, 2022 at 08:02 in Ajax, Ontario, Canada
    void readValues()
     //  BMPP390 
      temperatureC = bmp.temperature;// return Celsius
      temperatureF = bmp.temperature *9/5 + 32;//convert to Fahrenheit 
      temperatureK = bmp.temperature + 273.15;//convert to Kelvin
      altitude =  bmp.readAltitude(SEALEVELPRESSURE_HPA);// read altitude
      pressure = bmp.pressure / 100.0F; // get  pressure in hecto pascal
    }// readValues()
     * @brief prints degree symbol on serial monitor
     * @param none
     * @return returns nothing
     * Written by Ahmad Shamshiri on July 13, 2019
     * for Robojax Tutorial
    void printDegree()

    The least I expect from you is to give the video a thumbs up and subscribe to my channel. I appreciate it. I have spent hundreds of hours making these lectures and writing code. You don't lose anything by subscribing to my channel. Your subscription is a stamp of approval for my videos, helping more people find them and, in turn, helping me. Thank you!

    If you found this tutorial helpful, please support me so I can continue creating content like this. support me via PayPal

    **** AFFILIATE PROGRAM **** We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to and affiliated sites.

    Right Side