Introduction: LCD Display of Temperature in C or F by Choosing the Type With an IR Remote
FRENCH VERSION HERE
In this program w'll see how to capture a temperature, display it on an LCD display and choose if we want to display it in C or F with an infrared remote.
In this tuto I use:
-A Sainsmart card (like Arduino UNO)
-A LCD QC1602A
-A variator
-A LM35 temperature sensor
-A VS838 infrared sensor
-A 330kOhm resistor
-Jumpers
-A connection grid
In this program w'll see how to capture a temperature, display it on an LCD display and choose if we want to display it in C or F with an infrared remote.
In this tuto I use:
-A Sainsmart card (like Arduino UNO)
-A LCD QC1602A
-A variator
-A LM35 temperature sensor
-A VS838 infrared sensor
-A 330kOhm resistor
-Jumpers
-A connection grid
Step 1: Connections
Connection:
-GND port of the Arduino card plugs to the "-" column of the grid. (GND)
-5V port of the Arduino card plugs to the "+" column of the grid.
-LCD VSS pin plugs to the "-" column of the grid (GND).
-LCD VDD pin plugs to the "+" column of the grid (5V).
-LCD V0 pin plugs to the central variator pin.
-Arduino card port number 7 plugs to the LCD RS pin.
-Arduino card port number 8 plugs to the LCD E pin.
-Arduino card port number 9 plugs to the LCD D4 pin.
-Arduino card port number 10 plugs to the LCD D5 pin.
-Arduino card port number 11 plugs to the LCD D6 pin.
-Arduino card port number 12 plugs to the LCD D7 pin.
-Arduino card port A0 plugs to the central LM35 sensor.
-Notched LM35 pin plugs to the "+" column of the grid. (5V)(Right pin when the sensor faces to the user).
-Remaining LM35 pin plugs to the "-" column with a (330 kΩ) resistor.
-The 2 outside variator pins plugs to the "-" column of the grid.
-LCD RW pin plugs to the "-" column of the grid.
-LCD A pin plugs to the "+" column of the grid.
-LCD K pin plugs to the "-" column of the grid.
-Left infrared sensor pin (when the sensor faces to the user) plugs to the Arduino card port number 2.
-Central infrared sensor pin plugs to the "-" column of the grid.
-Right infrared sensor pin plugs to the "+" column of the grid.
-GND port of the Arduino card plugs to the "-" column of the grid. (GND)
-5V port of the Arduino card plugs to the "+" column of the grid.
-LCD VSS pin plugs to the "-" column of the grid (GND).
-LCD VDD pin plugs to the "+" column of the grid (5V).
-LCD V0 pin plugs to the central variator pin.
-Arduino card port number 7 plugs to the LCD RS pin.
-Arduino card port number 8 plugs to the LCD E pin.
-Arduino card port number 9 plugs to the LCD D4 pin.
-Arduino card port number 10 plugs to the LCD D5 pin.
-Arduino card port number 11 plugs to the LCD D6 pin.
-Arduino card port number 12 plugs to the LCD D7 pin.
-Arduino card port A0 plugs to the central LM35 sensor.
-Notched LM35 pin plugs to the "+" column of the grid. (5V)(Right pin when the sensor faces to the user).
-Remaining LM35 pin plugs to the "-" column with a (330 kΩ) resistor.
-The 2 outside variator pins plugs to the "-" column of the grid.
-LCD RW pin plugs to the "-" column of the grid.
-LCD A pin plugs to the "+" column of the grid.
-LCD K pin plugs to the "-" column of the grid.
-Left infrared sensor pin (when the sensor faces to the user) plugs to the Arduino card port number 2.
-Central infrared sensor pin plugs to the "-" column of the grid.
-Right infrared sensor pin plugs to the "+" column of the grid.
Step 2:
Add IR remote library
http://www.mediafire.com/download/jd5j7911amju36g/IRremote.zip
Do some test to recognize your infrared code with this program.
#include "IRremote.h"
int IRpin = 11;
IRrecv irrecv(IRpin);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop()
{
if (irrecv.decode(&results))
{
Serial.println(results.value, DEC); // Print the Serial 'results.value'
irrecv.resume(); // Receive the next value
}
}
source
http://www.mediafire.com/download/jd5j7911amju36g/IRremote.zip
Do some test to recognize your infrared code with this program.
#include "IRremote.h"
int IRpin = 11;
IRrecv irrecv(IRpin);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop()
{
if (irrecv.decode(&results))
{
Serial.println(results.value, DEC); // Print the Serial 'results.value'
irrecv.resume(); // Receive the next value
}
}
source
Step 3:
Copy and paste the following program.
Don't forget to change your "results.value"
/*
This program will permit you to display on a LCD the temperature of the place in °C or °F as the user want by using an infrared remote.
This program is written by Pierre-Olivier TILLOY is free of modification.
Connection:
-GND port of the Arduino card plugs to the "-" column of the grid. (GND)
-5V port of the Arduino card plugs to the "+" column of the grid.
-LCD VSS pin plugs to the "-" column of the grid (GND).
-LCD VDD pin plugs to the "+" column of the grid (5V).
-LCD V0 pin plugs to the central variator pin.
-Arduino card port number 7 plugs to the LCD RS pin.
-Arduino card port number 8 plugs to the LCD E pin.
-Arduino card port number 9 plugs to the LCD D4 pin.
-Arduino card port number 10 plugs to the LCD D5 pin.
-Arduino card port number 11 plugs to the LCD D6 pin.
-Arduino card port number 12 plugs to the LCD D7 pin.
-Arduino card port A0 plugs to the left LM35 sensor pin.
-Right LM35 pin plugs to the "+" column of the grid. (5V)(Right pin when the sensor faces to the user).
-Cnetral LM35 pin plugs to the "-" column with a (330 kΩ) resistor.
-The 2 outside variator pins plugs to the "-" column of the grid.
-LCD RW pin plugs to the "-" column of the grid.
-LCD A pin plugs to the "+" column of the grid.
-LCD K pin plugs to the "-" column of the grid.
-Left infrared sensor pin (when the sensor faces to the user) plugs to the Arduino card port number 2.
-Central infrared sensor pin plugs to the "-" column of the grid.
-Right infrared sensor pin plugs to the "+" column of the grid.
For Sainsmart card, please verify power switch is set on 5V.
/!\ VERIFY THAT CABLES ARE GOOD PLUGGED OTHERWISE THE LCD CAN DISPLAY WRONG VALUE/!\
*/
#include "IRremote.h" //Include infrared library.
#include "LiquidCrystal.h" //Include LCD library.
int tempPin = 0; //We define the received variavle by the sensor with a value of 0.
float tempC = 0; //We define a temperature variable in celcius wich we predefine a value of 0.
float tempF = 0; //We define a temperature variable in fahrenheit wich we predefine a value of 0.
LiquidCrystal lcd(7, 8, 9, 10, 11 , 12); //We define wich are LCD interface pins.
int IRpin = 2; //We declare the sneding variable of the infrared sensor plugs to the port 2 of the Arduino card.
IRrecv irrecv(IRpin); //We declare the IRpin variable is the pin wich receive the infrared data.
decode_results results; //We decode infrared signal.
void setup () {
Serial.begin(9600); //Data transfert is done in 9600bps.
irrecv.enableIRIn(); //Enable receiving processus.
lcd.begin(16, 2); //Indicate the number of square per line then the number of line of the LCD.
lcd.setCursor(3, 0); //We indicate where begin the texte to display.
lcd.print("Temperature"); //We indicate the text to diplay.
lcd.setCursor(5, 1);
lcd.print("Sensor");
delay(2000); //We define the time of display (in milliseconds).
lcd.clear(); //Clear the screen.
lcd.setCursor(4, 0);
lcd.print("Program");
lcd.setCursor(3, 1);
lcd.print("written by");
delay(2000);
lcd.clear();
lcd.setCursor(1, 0);
lcd.print("Pierre-Olivier");
lcd.setCursor(5, 1);
lcd.print("TILLOY");
delay(3500);
lcd.clear();
}
void loop () {
if (irrecv.decode(&results)) { //Try to receive an infrared code.
Serial.println(results.value, DEC); //Print the value code in the serial monitor.
irrecv.resume(); //Prepare the sensor to receive a new code.
}
Serial.println("");
Serial.println("Donnee brut recu par le capteur de temperature: "); //Print the text in the serial monitor.
Serial.println(analogRead(tempPin)); //Print the temperature sensor value in the serial monitor.
int rawvoltage = analogRead(tempPin); //We define a variable equal to the analog temperature sensor value.
tempC = ((rawvoltage/1024.0)*5000.0)/100; //The variable tempC take calcul value.
Serial.println (tempC); //We print the new tempC value in the serial moinitor.
lcd.setCursor(3, 0);
lcd.print("Temperature");
lcd.setCursor(4, 1);
lcd.print("is ");
if (results.value == 16724175) { //Replace "16724175" by the value wich correspond to your infrared code. If your choosen value equal the receive value, execute the follwing program.
lcd.setCursor(7, 1);
lcd.print(tempC);
lcd.setCursor(13,1);
lcd.print("C");
delay(500);
}
int tempF = (tempC * 9)/ 5 + 32; //Conversion of the température in fahrenheit.
Serial.println (tempF); //We print the new tempF value in the serial monitor.
if (results.value == 16718055) { //Replace "16718055" by the value wich correspond to your infrared code. If your choosen value equal the receive value, execute the follwing program.
lcd.setCursor(7,1);
lcd.print(tempF);
lcd.setCursor(13,1);
lcd.print("F");
delay(500);
}
} //End of the program.
Don't forget to change your "results.value"
/*
This program will permit you to display on a LCD the temperature of the place in °C or °F as the user want by using an infrared remote.
This program is written by Pierre-Olivier TILLOY is free of modification.
Connection:
-GND port of the Arduino card plugs to the "-" column of the grid. (GND)
-5V port of the Arduino card plugs to the "+" column of the grid.
-LCD VSS pin plugs to the "-" column of the grid (GND).
-LCD VDD pin plugs to the "+" column of the grid (5V).
-LCD V0 pin plugs to the central variator pin.
-Arduino card port number 7 plugs to the LCD RS pin.
-Arduino card port number 8 plugs to the LCD E pin.
-Arduino card port number 9 plugs to the LCD D4 pin.
-Arduino card port number 10 plugs to the LCD D5 pin.
-Arduino card port number 11 plugs to the LCD D6 pin.
-Arduino card port number 12 plugs to the LCD D7 pin.
-Arduino card port A0 plugs to the left LM35 sensor pin.
-Right LM35 pin plugs to the "+" column of the grid. (5V)(Right pin when the sensor faces to the user).
-Cnetral LM35 pin plugs to the "-" column with a (330 kΩ) resistor.
-The 2 outside variator pins plugs to the "-" column of the grid.
-LCD RW pin plugs to the "-" column of the grid.
-LCD A pin plugs to the "+" column of the grid.
-LCD K pin plugs to the "-" column of the grid.
-Left infrared sensor pin (when the sensor faces to the user) plugs to the Arduino card port number 2.
-Central infrared sensor pin plugs to the "-" column of the grid.
-Right infrared sensor pin plugs to the "+" column of the grid.
For Sainsmart card, please verify power switch is set on 5V.
/!\ VERIFY THAT CABLES ARE GOOD PLUGGED OTHERWISE THE LCD CAN DISPLAY WRONG VALUE/!\
*/
#include "IRremote.h" //Include infrared library.
#include "LiquidCrystal.h" //Include LCD library.
int tempPin = 0; //We define the received variavle by the sensor with a value of 0.
float tempC = 0; //We define a temperature variable in celcius wich we predefine a value of 0.
float tempF = 0; //We define a temperature variable in fahrenheit wich we predefine a value of 0.
LiquidCrystal lcd(7, 8, 9, 10, 11 , 12); //We define wich are LCD interface pins.
int IRpin = 2; //We declare the sneding variable of the infrared sensor plugs to the port 2 of the Arduino card.
IRrecv irrecv(IRpin); //We declare the IRpin variable is the pin wich receive the infrared data.
decode_results results; //We decode infrared signal.
void setup () {
Serial.begin(9600); //Data transfert is done in 9600bps.
irrecv.enableIRIn(); //Enable receiving processus.
lcd.begin(16, 2); //Indicate the number of square per line then the number of line of the LCD.
lcd.setCursor(3, 0); //We indicate where begin the texte to display.
lcd.print("Temperature"); //We indicate the text to diplay.
lcd.setCursor(5, 1);
lcd.print("Sensor");
delay(2000); //We define the time of display (in milliseconds).
lcd.clear(); //Clear the screen.
lcd.setCursor(4, 0);
lcd.print("Program");
lcd.setCursor(3, 1);
lcd.print("written by");
delay(2000);
lcd.clear();
lcd.setCursor(1, 0);
lcd.print("Pierre-Olivier");
lcd.setCursor(5, 1);
lcd.print("TILLOY");
delay(3500);
lcd.clear();
}
void loop () {
if (irrecv.decode(&results)) { //Try to receive an infrared code.
Serial.println(results.value, DEC); //Print the value code in the serial monitor.
irrecv.resume(); //Prepare the sensor to receive a new code.
}
Serial.println("");
Serial.println("Donnee brut recu par le capteur de temperature: "); //Print the text in the serial monitor.
Serial.println(analogRead(tempPin)); //Print the temperature sensor value in the serial monitor.
int rawvoltage = analogRead(tempPin); //We define a variable equal to the analog temperature sensor value.
tempC = ((rawvoltage/1024.0)*5000.0)/100; //The variable tempC take calcul value.
Serial.println (tempC); //We print the new tempC value in the serial moinitor.
lcd.setCursor(3, 0);
lcd.print("Temperature");
lcd.setCursor(4, 1);
lcd.print("is ");
if (results.value == 16724175) { //Replace "16724175" by the value wich correspond to your infrared code. If your choosen value equal the receive value, execute the follwing program.
lcd.setCursor(7, 1);
lcd.print(tempC);
lcd.setCursor(13,1);
lcd.print("C");
delay(500);
}
int tempF = (tempC * 9)/ 5 + 32; //Conversion of the température in fahrenheit.
Serial.println (tempF); //We print the new tempF value in the serial monitor.
if (results.value == 16718055) { //Replace "16718055" by the value wich correspond to your infrared code. If your choosen value equal the receive value, execute the follwing program.
lcd.setCursor(7,1);
lcd.print(tempF);
lcd.setCursor(13,1);
lcd.print("F");
delay(500);
}
} //End of the program.



