Hi guys,
I've managed to connect 5 temp. sensors to one bus using this code:
/* YourDuino Multiple DS18B20 Temperature Sensors on 1 wire
Connections:
DS18B20 Pinout (Left to Right, pins down, flat side toward you)
- Left = Ground
- Center = Signal (Pin 10): (with 3.3K to 4.7K resistor to +5 or 3.3 )
- Right = +5 or +3.3 V
Questions: terry@yourduino.com
V1.01 01/17/2013 ...based on examples from Rik Kretzinger
/*-----( Import needed libraries )-----*/
// Get 1-wire Library here: http://www.pjrc.com/teensy/td_libs_OneWire.html
#include <OneWire.h>
//Get DallasTemperature Library here: http://milesburton.com/Main_Page?title=Dallas_Temperature_Control_Library
#include <DallasTemperature.h>
/*-----( Declare Constants and Pin Numbers )-----*/
#define ONE_WIRE_BUS_PIN 10
//lcd
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
/*-----( Declare objects )-----*/
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS_PIN);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
/*-----( Declare Variables )-----*/
// 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 Probe01 = { 0x28, 0x78, 0xE0, 0x10, 0x05, 0x00, 0x00, 0xF0 };
DeviceAddress Probe02 = { 0x28, 0xA2, 0xA3, 0x10, 0x05, 0x00, 0x00, 0x5C };
DeviceAddress Probe03 = { 0x28, 0xB8, 0x45, 0x11, 0x05, 0x00, 0x00, 0x01 };
DeviceAddress Probe04 = { 0x28, 0xA2, 0x18, 0x11, 0x05, 0x00, 0x00, 0xEC };
DeviceAddress Probe05 = { 0x28, 0x73, 0x5A, 0x11, 0x05, 0x00, 0x00, 0x75 };
void setup() /****** SETUP: RUNS ONCE ******/
{
// start serial port to show results
Serial.begin(9600);
Serial.print("Initializing Temperature Control Library Version ");
Serial.println(DALLASTEMPLIBVERSION);
lcd.begin(20, 4);
// Initialize the Temperature measurement library
sensors.begin();
// set the resolution to 10 bit (Can be 9 to 12 bits .. lower is faster)
sensors.setResolution(Probe01, 10);
sensors.setResolution(Probe02, 10);
sensors.setResolution(Probe03, 10);
sensors.setResolution(Probe04, 10);
sensors.setResolution(Probe05, 10);
}//--(end setup )---
void loop() /****** LOOP: RUNS CONSTANTLY ******/
{
delay(1000);
Serial.println();
Serial.print("Number of Devices found on bus = ");
Serial.println(sensors.getDeviceCount());
Serial.print("Getting temperatures... ");
Serial.println();
// Command all devices on bus to read temperature
sensors.requestTemperatures();
Serial.print("Probe 01 temperature is: ");
printTemperature(Probe01);
Serial.println();
Serial.print("Probe 02 temperature is: ");
printTemperature(Probe02);
Serial.println();
Serial.print("Probe 03 temperature is: ");
printTemperature(Probe03);
Serial.println();
Serial.print("Probe 04 temperature is: ");
printTemperature(Probe04);
Serial.println();
Serial.print("Probe 05 temperature is: ");
printTemperature(Probe05);
Serial.println();
}//--(end main loop )---
/*-----( Declare User-written Functions )-----*/
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00)
{
Serial.print("Error getting temperature ");
}
else
{
Serial.print("C: ");
Serial.print(tempC);
Serial.print(" F: ");
Serial.print(DallasTemperature::toFahrenheit(tempC));
}
}// End printTemperature
//*********( THE END )***********
and what I'd like to do is to change the code so that it displays the temperature more accurately instead of every .25.
Which bit if the code do I need to tweak in order to get what I want? (funny enough, I just noticed that the sensor #5 shows all data, not only .25.
PS. I would also like to display this data on the LCD display. Which bit of the code do I need to modify to get it working properly?
Thanks in advance