Back to Step by Step Course by Robojax

Lesson 29: Using BMP280 Temperature Sensor | Arduino Step by Step Course

If you don't like to see ads while video is being played you can purchase YouTube premium Here

  • BMP280 library (from Gethub)
  • BOSCH Website for BMP280(website)
  • Part 3: Temperature Sensors

    In this lesson we learn how to use BMP280 to measure temperature and display it on the Serial monitor. We have more lectures and code for this sensor where we display temperature on LCD display and 4 digit LED seven segment display.

    
     
    /*
    
     * Robojax Arduino Step By Step Course
     * Lesson 29 Using BMEP280 Temperature Sensor
    
    
       Please watch video instruction here https://youtu.be/MaaQsbxclZY
     This code is available at http://robojax.com/course1/?vid=lecture11
     
    with over 100 lectures Free On  YouTube Watch it here http://robojax.com/L/?id=338
    Get the code for the course: http://robojax.com/L/?id=339 
    * 
    
    
     * This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.* 
     * This code has been download from Robojax.com
        This program is free software: you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation, either version 3 of the License, or
        (at your option) any later version.
    
        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.
    
        You should have received a copy of the GNU General Public License
        along with this program.  If not, see <https://www.gnu.org/licenses/>. 
    
    
    ***************************************************************************
      This is a library for the BMP280 humidity, temperature & pressure sensor
    
      Designed specifically to work with the Adafruit BMEP280 Breakout
      ----> http://www.adafruit.com/products/2651
    
      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 andopen-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 <SPI.h>
    #include <Adafruit_BMP280.h>
    
    #define BMP_SCK  (13)
    #define BMP_MISO (12)
    #define BMP_MOSI (11)
    #define BMP_CS   (10)
    
    Adafruit_BMP280 bmp; // I2C
    //Adafruit_BMP280 bmp(BMP_CS); // hardware SPI
    //Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO,  BMP_SCK);
    
    void setup() {
      Serial.begin(9600);
      Serial.println(F("BMP280 test"));
    
      if (!bmp.begin()) {
        Serial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
        while (1);
      }
    
      /* Default settings from datasheet. */
      bmp.setSampling(Adafruit_BMP280::MODE_NORMAL,     /* Operating Mode. */
                      Adafruit_BMP280::SAMPLING_X2,     /* Temp. oversampling */
                      Adafruit_BMP280::SAMPLING_X16,    /* Pressure oversampling */
                      Adafruit_BMP280::FILTER_X16,      /* Filtering. */
                      Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */
    }
    
    void loop() {
        Serial.print(F("Temperature = "));
        Serial.print(bmp.readTemperature());
        Serial.println(" *C");
        
        Serial.print(F("Pressure = "));
        Serial.print(bmp.readPressure());
        Serial.println(" Pa");
    
        Serial.print(F("Approx altitude = "));
        Serial.print(bmp.readAltitude(1013.25)); /* Adjusted to local forecast! */
        Serial.println(" m");
    
    
    
        Serial.println();
        delay(2000);
    }
    
       

    The least I expect from you is to thumb up the video and subscribe to my channel. I appriciate that. .I have spent months making these lectures and writing code. You don't lose anything by subscribging to my channel. Your subscription is stamp of approval to my videos and more people can find them and in it turn it helps 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 Amazon.com and affiliated sites.

    Right Side
    footer