Arduino Temperature Display V1

projectImage

A functional and accurate project that is perfect for beginners, and displays the current temperature and light levels.

Useful for many things - use it check the temperature in your server room, check how hot and fast your fireplace is burning, or check if the fridge is open. The ideas are endless!

You could always edit it to contain more sensors, or could add a datalogger module.

projectImage
HARDWARE LIST
1 Uno R3
1 DS18B20
1 I2C LCD
1 LDR Module
1 Mini Breadboard
1 pack M/M Jumper Leads
1 4.7k resistor
projectImage
STEP 1
Start by connecting the I2C 1602 LCD to your Arduino Uno. Ensure that the SDA and SCL pins are inserted correctly. The VCC pin on the backpack goes to 5 volts on the Uno, and gnd goes to ground.
STEP 2
Insert the DS18B20 into the breadboard after stripping the ends of the wires. Place a 4.7k resistor across the data wire (yellow) and the vcc wire (red). Using jumpers, connect the red wire to 5 volts on the Uno, the black wire to ground, and the yellow wire to digital pin 2.
STEP 3
Connect the Uno to your PC via a USB cable.
STEP 4
Upload the code.
STEP 5
An optional step would be to construct a suitable box to house your project.

You will notice that lines 52 through 65 are commented out in the below code. That code that is commented out replaces the farenheit temperature with the light levels. To implement it, comment out lines 42 through 50 and uncomment lines 52 through 65.

CODE
#include <OneWire.h>                       // library to access DS18B20
#include <DallasTemperature.h>             // library to support DS18B20
#include <Wire.h>                          // library for communicating to I2C devices
#include <hd44780.h>                       // main hd44780 library
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class library

hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto configure expander chip

OneWire oneWire(2); // tell the library to use the digital pin the DS18B20 is connected to

DallasTemperature sensors(&oneWire); // tell the library to compute temp on the oneWire pin

int IOL; // initialize the LDR pin name as a 16-bit value

void setup() {
  Serial.begin(9600); // setup Serial for debug
  sensors.begin(); // start DS18B20
  IOL = analogRead(A0); // initialize LDR as analog pin 0 - read only
  lcd.begin(16, 2); // initialize lcd as 16 columns, 2 rows
  lcd.clear(); // clear any old data on the lcd
  // if there is lots of ambient light, turn on the lcd backlight
  if (IOL < 500) {
    lcd.backlight();
  }
  // if the ambient light is low, turn off the backlight
  if (IOL >= 500) {
    lcd.noBacklight();
  }
}

void loop() {
  IOL = analogRead(A0); // initialize LDR as analog pin 0 - read only
  // if there is lots of ambient light, turn on the lcd backlight
  if (IOL < 500) {
    lcd.backlight();
  }
  // if the ambient light is low, turn off the backlight
  if (IOL >= 500) {
    lcd.noBacklight();
  }

  sensors.requestTemperatures(); // send data asking for temperature to DS18B20
  lcd.setCursor(0, 0); // set the lcd cursor for celsius temperature
  lcd.print("Temp C: "); // print explanation of following data
  lcd.print(sensors.getTempCByIndex(0)); // print the degrees in celsius
  lcd.print("       "); // print spaces to blank out any remanants of data
  lcd.setCursor(0, 1); // set the lcd for farenheit temperature
  lcd.print("Temp F: "); // print explanation of following data
  lcd.print(DallasTemperature::toFahrenheit(sensors.getTempCByIndex(0))); // Convert tempC to Fahrenheit and print it
  lcd.print("       "); // print spaces to blank out any remanants of data

/*
  sensors.requestTemperatures(); // send data asking for temperature to DS18B20
  lcd.setCursor(0, 0); // set the lcd cursor for celsius temperature
  lcd.print(F("Temp: ")); // print explanation of following data from program storage
  lcd.print(sensors.getTempCByIndex(0)); // print the degrees in celsius
  lcd.print(F(" ")); // print space from program storage
  lcd.print((char)223); // print degrees symbol
  lcd.print(F("C")); // print celsius abbreviation
  lcd.print("       "); // print spaces to blank out any remanants of data
  lcd.setCursor(0, 1); // set the lcd for light levels
  lcd.print(F("Light Level: ")); // print explanation of following data
  lcd.print(IOL); // print light levels
  lcd.print("       "); // print spaces to blank out any remanants of data
*/
}

V2 of this temperature logger will be way better, I'm planning on incorporating humidity and time!

License
All Rights
Reserved
licensBg
0