Back to Step by Step Course by Robojax

Lesson 31: Using BMP280 Temperature Sensor with TM1637 LED Display | Arduino Step by Step Course

Related or required files and link to this lesson

Part 3: Temperature Sensors

In this lesson we learn how to use BMP280 to measure temperature and display it on TM1637 There is separate code for LCD2004 and LCD1602.

 * Robojax Arduino Step By Step Course
 * Part 3: Temperature Sensors
 * Lesson 31 BMP280 with TM1637
   Please watch video instruction here
 This code is available at
with over 100 lectures Free On  YouTube Watch it here
Get the code for the course:  
If you found this tutorial helpful, please support me so I can continue creating 
 make donation using PayPal
 Written/update by Ahmad Shamshiri in Ajax, Ontario Canada.

 * Code is available at

 * 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
    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
    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 <>. 
  This is a library for the BMP280 humidity, temperature & pressure sensor

  Designed specifically to work with the Adafruit BMEP280 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 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 <math.h>
#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);

// start of settings of TM1637 display
#include <Arduino.h>
#include <TM1637Display.h>

// Module connection pins (Digital Pins)
#define CLK 5
#define DIO 6
TM1637Display display(CLK, DIO);
uint8_t blank[] = { 0x0, 0x0, 0x0, 0x0 };// blank value for all digits
 uint8_t allSegment[] = { 0xff, 0xff, 0xff, 0xff };// all segment ON
// start of settings of TM1637 display

void setup() {
  Serial.println("BMP280 demo by Robojax");
  if (!bmp.begin()) {
      Serial.println("BMP280 Module Error"); 
    while (1);

void loop() {
  // Robojax example  Get the code for the course:  
  Serial.print(getTemp('C'));// print Temperature in Celsius
        Serial.println(" C");// print C 
  Serial.print(getTemp('F'));// print Temperature in Celsius
        Serial.println(" F");// print F   
  Serial.print(getTemp('K'));// print Temperature in Kelvin
        Serial.println(" K");// print K  





}// loop end

 * Written by Ahmad Shamshiri 
 * Jan 22, 2019 in Ajax, Ontario, Canada
 * getTemp(char type)
 * returns temperature in either C, F or K
 * @param type is character of upper case 
 * C is used to get Celsius
 * F is used to get fahrenheit
 * K is used for Kelvin
 * Written by Ahmad Shamshiri for
float getTemp(char type) {
    float c = bmp.readTemperature();//get main temperature in C
  float f = c * 9.0 / 5.0 + 32;// convert to fahrenheit
  if(type =='F')
    return f;// fahrenheit
  }else if(type =='K')
    return c + 274.15;// return Kelvin
   return c; //return Celsius
}//getTemp ends


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