Using a 4 bits 7 segment LED display with an Arduino

//Using a 4 bits 7 segment LED display with an Arduino

Using a 4 bits 7 segment LED display with an Arduino


Move away from the Serial Monitor to display values from your sensor by using this simple to use 4 Bits 7 segment LED module.

Thanks to the I2C Bus you can control it using only 2 wires, leaving more pins available on your MicroController to connect other things.

Using Arduino Modules is fast and easy since all the components needed are included on the pcb (resistors, capacitors, etc…).

To make things interesting we will use the DHT11 temperature and humidity sensor to display it’s reading on the Digital Tube Display.


As mentioned before, since the Digital tube display uses the I2C Bus, we only need 2 connections.

The DHT11 uses only 1 pin.

Both module need 5v and Ground to operate, so we are using the breadboard to use it’s VCC and Ground Rails.


The code will make use of 2 libraries, one for the DHT11 and the other for the Display.

Download both of these and extract them to your Library folder, then restart your IDE software.

The code below assumes that the data received for the Temperature and the Humidity will always have 2 digits.  If you want to experiment you could modify the code with some IF statements if those values have more than 2 digits or add a minus sign for negative temperature values.

Example : -19 degrees Celsius or over 100 degrees.

As always you can have a look at the tutorial video for more information.

#include "dht.h"
#include "TM1637.h"


#define dht_pin 2 // Pin sensor is connected to
#define CLK 3//Pins for TM1637       
#define DIO 4
TM1637 tm1637(CLK,DIO);
dht DHT;

void setup(){
  delay(1500);//Delay to let system boot

}//end "setup()"

void loop(){
  //Start of Program 

 int temp = DHT.temperature;
 int humidity = DHT.humidity;
 int digitoneT = temp / 10;
 int digittwoT = temp % 10;
 int digitoneH = humidity / 10;
 int digittwoH = humidity % 10;

    tm1637.display(3,12);  // put a C at the end
    delay (3000);

  //Wait 3 seconds before accessing sensor again.
  //Fastest should be once every two seconds.
}// end loop() 

Copy and paste the above code in the Arduino IDE to program your Arduino.

Used Libraries:

Download the DHT11 library created by RobTillaart:

Download the TM1637 library created by Frankie.Chu here:  

Once downloaded, just extract the content of the zip files inside your “arduino/libraries” folder.

By | 2018-02-23T17:29:55-05:00 January 17th, 2015|Tutorials|


  1. Cliff June 28, 2020 at 11:54 am - Reply

    Works well, but wondering how to get it to display in Fahrenheit.

  2. giuseppe festa April 26, 2019 at 8:28 am - Reply

    thanks worked out can i bother you again? I tried to change the 12 inside this line tm1637. show (3, 12) to see what happens and how the other wanted

  3. giuseppe April 24, 2019 at 12:14 pm - Reply

    ciao io non so come scaricare la libreria dht perché vado su gthub ma non vedo il pulsante di download mi aiuti?

    hi I don’t know how to download the dht library because I go to gthub but I don’t see the download button help me?

Leave A Comment