Two DS18B20 Temp Sensors on LCD Display!

Share on facebook
Share on google
Share on twitter
Share on linkedin
A VPN is an essential component of IT security, whether you’re just starting a business or are already up and running. Most business interactions and transactions happen online and VPN

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:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html

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
sensors.begin();
// 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 16×2 LCD, etc.
lcd.clear(); // start with a blank screen
}

void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
lcd.print(“Error”);
} else {
lcd.print(tempC);
lcd.print(“/”);
lcd.print(DallasTemperature::toFahrenheit(tempC));
}
}

void loop(void)
{
delay(2000);
sensors.requestTemperatures();
lcd.setCursor(0,0);
lcd.print(“In: “);
printTemperature(insideThermometer);
lcd.setCursor(0,1);
lcd.print(“Out: “);
printTemperature(outsideThermometer);
}

Steve Spence

Steve Spence

Leave a Reply

8 thoughts on “Two DS18B20 Temp Sensors on LCD Display!”

  1. Steve – great work on this. There is a lot of work on the internet about the DS18B20's, but little on simple applications on getting them to perform for the non-technical makers that have no engineering or programing backgrounds. This is important work, so please keep it up. This is a awesome IC that will have a big impact once the power of them are unleashed in simple to follow projects that are replicable by the average maker!!!

  2. Thanks for this info, I've been looking everywhere for info on using multiple DS18B20s as I was struggling with assigning the different IDs to user variables, your post helped loads, thanks

  3. Bonjour,
    Je suis entrain de réaliser le “thermostat de capteur solaire” de dcphilippe de ptiwatt.
    Mais j’ai un problème avec leur montage, car c’est le bus “OneWire” qui affecte les postes aux DS18B220. Je m’explique :
    Il y a un composant dans le capteur, On le nomme “SOURCE”,
    Un dans le ballon d’eau chaude “BALLON”
    Si le capteur “SOURCE” s’envoie en l’air, que je change le composant, il devient “BALLON”.
    Et là, tout le système s’écroule….
    Je cherche à fixer l’adresse du DS18B20 au poste attribué. En cas de problème, on corrige l’adresse et change le composant, et tout repart.
    Si vous pouviez me mettre sur la voie de la résolution, ce serait merveilleux… J’ai essayé plusieurs manip, mais je ne suis pas programmeur, et mes compétences laisses un peu à désirer.
    D’avance, je vous en remercie

      1. For what it is worth… here is the translation from French to English-ish.
        Hello,
        I’m working on the ptiwatt “solar collector thermostat”.
        But I have a problem with their editing, because it is the bus “OneWire” that affects the positions DS18B220. Let me explain :
        There is a component in the sensor, It’s called “SOURCE”,
        One in the hot water tank “BALLOON”
        If the sensor “SOURCE” is sent in the air, that I change the component, it becomes “BALLOON”.
        And there, the whole system collapses …
        I am looking to fix the address of the DS18B20 at the assigned position. In case of problems, we correct the address and change the component, and everything goes again.
        If you could put me on the way to resolution, it would be wonderful … I tried several manip, but I’m not a programmer, and my skills left a little to be desired.
        In advance, I thank you

Leave a Comment

Your email address will not be published. Required fields are marked *