Thermometer - Arduino Project

Thermometer

The thermometer is a simple Arduino based project which measures the voltage from a thermostat and then converts it into temperature in Celsius and projects it onto an LCD. It is a simple project which I designed in the span of about 30 to 45 minutes.




All you will need for this project is:


  • An Arduino UNO
  • An LCD (Liquid Crystal Display specifically LCM1602C)
  • A Thermostat
  • A Potentiometer (10kΩ)
  • Wires
  • And the open-source Arduino Software (You can download it for free at https://www.arduino.cc/en/Main/Software)
  • A 220  Ω  Resistor

You first wire up your components as shown in the diagram below.


Even though I showed you the diagram of how the device should be wired, you should check what to plug in where on your device. I will explain why everything is wired in the way it is.

Let's start with the thermostat. It first needs to be connected to the circuit. You first connect the thermostat to the GND wire and then you connect it with the 5V wire (These wires have already been connected to the breadboard. This means that you just need to plug the thermostat into the right holes in the breadboard.) You then connect the thermostat into the A0 analog inlet. You plug it into the A0 analog inlet to make the arduino recieve the values recorded on the thermostat.

The potentiometer is connected very similarly. You first connect it to the GND wire then the 5V wire. You then connect it to the Vee pin on the LCD. This potentiometer is used to change the contrast of the LCD screen.

The LCD screen is connected through many pins. The first pin (GND) connects to the GND wire, the second pin (Vcc) connects to the 5V wire. The third (Vee) connects to the potentiometer. The fourth pin (RS) connects to the digital outlet 12 on the arduino, this is to state where the characters will appear. The fifth pin (R/W) connects to the GND wire. The sixth pin (E) connects to the digital outlet 11 on the arduino, this sets the LCD into a state where it is able to project things. Pins DB0 through DB7 connect to the digital inlets on the Arduino board. The BL+ pin connects to the 5V wire through a 220Ω resistor and the BL- pin connects to the GND wire.

Here are some pictures of how I wired up my arduino.










When your board is wired up you can start coding. Here is the simplest version of the code.

#include <LiquidCrystal.h> /*Here you include the library of the LCD*/
const int sensorPin = A0;  /*Here you set a sensorPin constant to the value A0 (a pin)*/
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
 Serial.begin(9600);
 lcd.begin(16, 2); /*Here you state how many rows and columns your LCD has*/ 
}

void loop() { 
 int sensorVal = analogRead(sensorPin); /*Here you make a variable which represents the output value*/ 
 float voltage = (sensorVal/1024.0) * 5.0; /*Here you are converting received value to temperature.*/ 
 float temperature = (voltage - .5) * 100; /*Here you convert the voltage into temperature*/ 

 lcd.clear(); 
 lcd.setCursor(0, 0);
 lcd.print("Tmp: "); 
 lcd.print(temperature); 
 lcd.print("C"); 
}

In this version of the code I added an animated signature and a Hot/Cold indicator.

#include <LiquidCrystal.h> /*Here you include the library of the LCD*/
const int sensorPin = A0;  /*Here you set a sensorPin constant to the value A0 (a pin)*/
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int pos = 0;
int inc = 1;

void setup() {
 Serial.begin(9600);
 lcd.begin(16, 2); /*Here you state how many rows and columns your LCD has*/ 
}
void loop() { 
 int sensorVal = analogRead(sensorPin); /*Here you make a variable which represents the output value*/ 
 float voltage = (sensorVal/1024.0) * 5.0; /*Here you are converting received value to temperature.*/ 
 float temperature = (voltage - .5) * 100; /*Here you convert the voltage into temperature*/ 
 lcd.clear(); 
 lcd.setCursor(0, 0);
 lcd.print("Tmp: "); 
 lcd.print(temperature); 
 lcd.print("C"); 
 if (temperature > 24){ /*With this if/else you make the label change from hot to cold*/ 
 lcd.print(" Hot"); 
 }else { 
 lcd.print(" Cold"); 
 } lcd.setCursor(pos, 1); /*Here you animate the bottom text by moving it left and right*/ 
 pos = pos + inc; 
 if (pos == 6 || pos == 0){ 
 inc = inc * (-1);
 } 
 lcd.print("By Someone");
 /*You sing yourself here*/ 
 delay(500); /*Here you make the arduino wait before it does something, this is made so that the data is readable on the LCD*/
}

Komentáre