TM1637 is a great cheap module and we have some introduction to TM1637, and some TM1637 projects like TM1637 clock, traffic light timer with push button, a planned project to make cooking top digital etc. This glowing temperature sensor for air-conditioned car with Arduino 7 Segment LED display & DHT11 sensor makes a practical sense. Later we will add digital speedometer function with it.
Arduino 7 Segment LED Display Temperature Sensor (TM1637 & DHT11)
It is really easy and cheap. You need to set up wiring like the easy schematic like in this guide and upload the code. You need two extra libraries, we already talked about TM1637.h
library during 7 Segment LED Display guides and rest is finding dht.h
on Github (it may be installed on Arduino IDE on your computer). We need to include these two in code :
1 2 | #include "dht.h" #include "TM1637.h library" |
We need an Arduino board, one TM1637 7 Segment 4 Digit Display module, one DHT11 KY-015 Temperature sensor module, an optional breadboard and few jumper wires.
---
Arduino 7 Segment LED Display Temperature Sensor : Circuit And Code
Here is the schematic :
Here is code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | #include <dht.h> #include "TM1637.h" //{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; //0~9,A,b,C,d,E,F #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(){ tm1637.init(); tm1637.set(BRIGHT_DARKEST); //BRIGHT_TYPICAL = 2,BRIGHT_DARKEST = 0,BRIGHTEST = 7; delay(500); } void loop(){ DHT.read11(dht_pin); 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(1,digitoneT); tm1637.display(2,digittwoT); tm1637.display(3,12); // put a C at the end delay (3000); tm1637.display(1,25); tm1637.display(2,digitoneH); tm1637.display(3,digittwoH); //Wait 3 seconds before accessing sensor again. //Fastest should be once every two seconds. delay(3000); }// end loop() |