TMP36 + LCD + Arduino: Indoor Temperature Monitor and Display
by UnicornClockworks in Circuits > Arduino
6486 Views, 15 Favorites, 0 Comments
TMP36 + LCD + Arduino: Indoor Temperature Monitor and Display
Hello World!
I'm Unicorn Clockworks and I'm back with another instructables. Here, we will make a temperature indicator and display using the TMP36 IC. This is a very cheap and accurate temperature sensor -- about 2 bucks (CAD). This can be used both indoor and outdoor, but I'm focusing on indoor applications so no weather proofing is necessary.
You can also use this for other micro controller besides the Arduino, namely NodeMCU and ESP8266, apart from a small change in code that I will highlight with italics in that step.
Materials
- Arduino or any Arudino-compatible microcontroller
- TMP36
- LCD Display
- Potentiometer
- Breadboard
- Jumper Wires
LCD Connections
The connections are labeled in the picture and the wires correspond to the images are noted below.
1a
- Connect the Brown wire (pin 16) to the GND pin on the Arduino
- Connect the Red wire (pin 15) to the 3.3V VCC pin on the Arduino
- Connect the Orange, Yellow, Green, Blue (pins 14-11) to pins 2 to 5 on the Arduino
2
- Connect the White wire (pin 1 on the LCD) to the common ground (pin 16)
- Connect the Grey wire (pin 2 on the LCD) to the common VCC source (pin 15)
- Connect the Purple wire to the signal pin of the potentiometer (pin 2 on the potentiometer)
3
- Connect the Purple wire (pin 1 on the potentiometer) to the common ground (pin 16)
- Connect the Grey wire (pin 3 on the potentiometer) to the common VCC source (pin 15)
4
- Connect the Yellow wire (pin 4 on the LCD) to pin 12 on the Arduino
- Connect the Black wire (pin 5 on the LCD) to the common ground (pin 1 on the potentiometer or pin 16 on the LCD, either works)
- Connect the Green wire (pin 6 on the LCD) to pin 11 on the Arduino
TMP36 Connections
- Connect the ground pin of the TMP36 -- pin 3 -- (as shown on the picture) to the any common ground (pin 1 on the potentiometer or GND on Arduino)
- Connect the VCC pin of the TMP36 -- pin 1 -- to any common VCC source (pin 1 on the potentiometer or pin 2 on the LCD)
- Connect the signal pin of the TMP36 -- pin 2 -- to pin A0 on the Arduino.
Coding
Keep in mind that this line of code is only for the Arduino board specifically and if you are using other Arduino-core-compatible micro controller, delete it.
volts = tempVal * 3.3;
Other than this minor change, it works on any micro controller device.
#include <LiquidCrystal.h> // built in arduino library<br> <liquidcrystal.h> LiquidCrystal lcd(12,11,5,4,3,2);</liquidcrystal.h>
int tempVal; //raw reading variable float volts; float tempC; float tempF;
void setup() { lcd.begin(16, 2); // clear old screen data lcd.clear(); // text to be dispalyed on the screen lcd.print("UnicornClockworks"); Serial.begin (9600); }
void loop() { //read the temp sensor and store it in tempVal tempVal = analogRead(A0); //converting that reading to voltage by multiplying the reading by 3.3V volts = tempVal * 3.3; volts /= 1023.0;
//calculate temperature celsius from voltage tempC = (volts - 0.5) * 100 ; // Convert from celcius to fahrenheit tempF = (tempC * 9.0 / 5.0) + 32.0; Serial.println(tempC); // (column 0) of the second line (line 1): lcd.setCursor(0,1); lcd.write ("Temp: "); lcd.setCursor (7, 1); lcd.print (tempC, 2);
lcd.setCursor (13, 1); lcd.write ("C");
// for farenheit temperatures /* lcd.setCursor(0,1); lcd.write ("Temp: "); lcd.write (tempF);
lcd.setCursor (10, 1) lcd.write ("F"); */ delay(1000); }
Downloads
It Works!
Upload the code to the Arduino and watch the display change. Test the sensor by touching it (make sure you have the polarity right so you don't burn your fingers.
Try it out yourself and have fun!
Unicorn Clockworks Out!