Wednesday, December 1, 2010

Two DS18B20 Temp Sensors on LCD Display!

We are finally posting our multi DS18B20 Temp Sensor LCD project. Right now we are monitoring two sensors on one data pin, but could add many such sensors. Just need to add the additional chip id numbers to the code. We will experiment with wire length and outdoor mounting in the near future. Please review and comment.

Find your DS18B20 address!

// This Arduino sketch reads DS18B20 "1-Wire" digital
// temperature sensors.

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

// Connections:
// rs (LCD pin 4) to Arduino pin 12
// rw (LCD pin 5) to Arduino pin 11
// enable (LCD pin 6) to Arduino pin 10
// LCD pin 15 to Arduino pin 13
// LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

int backLight = 13; // pin 13 will control the backlight

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

// 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:

DeviceAddress insideThermometer = { 0x28, 0x3C, 0xF2, 0xA7, 0x02, 0x00, 0x00, 0xCB };
DeviceAddress outsideThermometer = { 0x28, 0x20, 0x04, 0xA8, 0x02, 0x00, 0x00, 0x4D };

void setup(void)
// Start up the library
// set the resolution to 10 bit (good enough?)
sensors.setResolution(insideThermometer, 10);
sensors.setResolution(outsideThermometer, 10);

pinMode(backLight, OUTPUT);
digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
lcd.begin(16,2); // columns, rows. use 16,2 for a 16x2 LCD, etc.
lcd.clear(); // start with a blank screen

void printTemperature(DeviceAddress deviceAddress)
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
} else {

void loop(void)
lcd.print("In: ");
lcd.print("Out: ");

Sunday, November 28, 2010

Determining your Dallas 1 wire address

1-Wire devices, such as the DS18B20 digital temperature sensor, are great to use with Arduino boards because you can connect many of them to a single IO pin. The freely available software libraries and example code make using 1-wire devices simple. There is only one problem we have seen with the examples on the web. If you have more than one device connected to a single pin, say an indoor temperature sensor, as well as an outdoor temperature sensor, how does your Arduino know which is which?

Using the tutorial at, We determined the following on our two DS18B20 Temp Sensors:

0x28, 0x3C, 0xF2, 0xA7, 0x02, 0x00, 0x00, 0xCB

0x28, 0x20, 0x04, 0xA8, 0x02, 0x00, 0x00, 0x4D

Now we are ready to move forward with the indoor/outdoor temperature monitor. To be continued ...

The Reverse Geocache™ Puzzle Box

I recently read a story about a wedding gift that gave a distance to a destination, and would not open until the destination was reached. It is based upon a mix of Arduino, a gps sensor, and good old inventiveness baked with art and engineering, and was finally frosted with love and emotion for friends. What started out as a private wedding gift, and eventually brought much of the world into it's story, is in 4 parts, took a year to accomplish, and is a must read.
Related Posts Plugin for WordPress, Blogger...