Arduino Temperature Probe

image
I have been playing around with the Arduino for a few months and one of the things I wanted to build was a nice temperature monitor with a simple screen. I have the Arduino Uno board and had a GHI Electronics LCD Button Shield that I thought I could use. After playing around with connecting the Arduino to the LCD Shield I found that I could control it and even use the buttons (with some slight tweaks to the logic that is used in the standard Arduino Button Shield logic). I had also previously purchased one of the Sparkfun waterproof temperature probes and went through the trouble of installing the resistor inline as recommended here:

http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html

This is how I have it wired to the Arduino (using the LCD Shield pins as mounting points):
DS18B20 wiring diagram
I have the resistor and the solder connections in the shrink tube here:
image

The probe itself can be pruchased at Sparkfun:
https://www.sparkfun.com/products/11050

I also had to make sure I knew the address of the probe, but they also have a nice tutorial for getting the address of your probe here:

http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html

To run the LCD Button Shield I used the simple LiquidCrystal code I found here:

http://www.hobbytronics.co.uk/arduino-lcd-keypad-shield

It should work with any of the Arduino Button Shields.

The final code I used is here:

// This Arduino sketch reads DS18B20 "1-Wire" digital
// temperature sensors.
// It also uses the LCD button shield which needs the LiquidCrystal Library available here:
// http://arduino.cc/en/Reference/LiquidCrystal
// Tutorial:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html

#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

// Assign the addresses of your 1-Wire temp sensors.
// See the tutorial on how to obtain these addresses:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html
// this is a unique sensor Id and will be specific to your sensor, use the link above to discover the Id of your sensor
DeviceAddress tempProbe = { 0x28, 0xB0, 0x0C, 0x37, 0x04, 0x00, 0x00, 0x68 };

//holds the latest temp reading
float tempF;

void setup(void)
{
// start serial port
Serial.begin(9600);
// Start up the library
sensors.begin();
// set the resolution to 10 bit (good enough?)
sensors.setResolution(tempProbe, 10);

// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
//set the cursor to first row, first character
lcd.setCursor(0,0);
//show which version of software it is running
lcd.print("LCD:TempProbe v1");

}

void printTempSerial(float temp)
{//sends temp info to serial port
Serial.print("Probe temperature is: ");
if (temp < -100) {
Serial.print("Error getting temperature");
} else {
Serial.print("F: ");
Serial.print(temp);
}
Serial.print("\n\r\n\r");
}

void LCDTemp(float temp)
{//send temp info to LCD shield
//first character, second row
lcd.setCursor(0,1);

if (temp < -100) {
lcd.print("Error: check connection");
} else {
lcd.print (temp);
lcd.print (" Fahrenheit");
}
}

void loop(void)
{
//gets all temp probes on bus (i.e. pin 3)
sensors.requestTemperatures();
//get the temp of a specific sensor on bus by unique probe Id
tempF = sensors.getTempF(tempProbe);
//send temp over serial debug
printTempSerial(tempF);
//send temp to LCD display
LCDTemp(tempF);

//wait 2 seconds to next reading
delay(2000);
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s