//Multiple DS18B20 Temperature Sensors
// Displayed on 4x20 character LCD display#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>//-----( Declare Constants and Pin Numbers )-----
#define ONE_WIRE_BUS 3 // Data wire is plugged into port 3 on the Arduino (can be changed)
/-----( Declare objects )-----/
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
// DS18B20 Probes
DeviceAddress Probe1 = {
0x28, 0xC5, 0xEC, 0x34, 0x05, 0x00, 0x00, 0xE2 }; // ROOM
DeviceAddress Probe2 = {
0x28, 0xF2, 0xDE, 0x35, 0x05, 0x00, 0x00, 0x02 }; // TANKLiquidCrystal lcd(8, 7, 5, 4, 16, 2);
int nowTemp1;
int minTemp1=1269;
int maxTemp1=-1269;int nowTemp2;
int minTemp2=1269;
int maxTemp2=-1269;void setup() /****** SETUP: RUNS ONCE ******/
{
sensors.begin();
sensors.setResolution(Probe1, 12);
sensors.setResolution(Probe2, 12);lcd.begin (20,4);
float temp1 = sensors.getTempC(Probe1);
nowTemp1 = temp1 * 10 + 0.5;
maxTemp1 = nowTemp1;
minTemp1 = nowTemp1;float temp2 = sensors.getTempC(Probe2);
nowTemp2 = temp2 * 10 + 0.5;
maxTemp2 = nowTemp2;
minTemp2 = nowTemp2;}//--(end setup )---
void loop()
{
sensors.requestTemperatures();tempCalc1();
tempCalc2();
displayTemperature1();
displayTemperature2();
delay(1000); // <---- Do I need this? Too Long? Too Short?}
void displayTemperature1()
{
lcd.setCursor(0,0);
lcd.print(" ROOM");lcd.setCursor(0,1);
lcd.print("Now ");
if (nowTemp1 == -1269){
lcd.print("Err ");
}
else{
lcd.print(nowTemp1/10);
lcd.setCursor(6,1);
lcd.print(".");
lcd.print(nowTemp1%10);
}lcd.setCursor(0,2);
lcd.print("Max ");
if (maxTemp1 == -1269){
lcd.print("Err ");
}
else{
lcd.print(maxTemp1/10);
lcd.setCursor(6,2);
lcd.print(".");
lcd.print(maxTemp1%10);
}lcd.setCursor(0,3);
lcd.print("Min ");
if (minTemp1 == -1269){
lcd.print("Err ");
}
else{
lcd.print(minTemp1/10);
lcd.setCursor(6,3);
lcd.print(".");
lcd.print(minTemp1%10);
}
}void displayTemperature2()
{
lcd.setCursor(6,0);
lcd.print(" ROOM2 ");lcd.setCursor(8,1);
lcd.print(" Now ");
if (nowTemp2 == -1269){
lcd.print("Err ");
}
else{
lcd.print(nowTemp2/10);
lcd.setCursor(18,1);
lcd.print(".");
lcd.print(nowTemp2%10);
}lcd.setCursor(8,2);
lcd.print(" Max ");
if (maxTemp2 == -1269){
lcd.print("Err ");
}
else{
lcd.print(maxTemp2/10);
lcd.setCursor(18,2);
lcd.print(".");
lcd.print(maxTemp2%10);
}lcd.setCursor(8,3);
lcd.print(" Min ");
if (minTemp2 == -1269){
lcd.print("Err ");
}
else{
lcd.print(minTemp2/10);
lcd.setCursor(18,3);
lcd.print(".");
lcd.print(minTemp2%10);
}
}//Temp Calculations Probe 1
void tempCalc1()
{
float temp1 = sensors.getTempC(Probe1);nowTemp1=temp1 * 10 + 0.5;
if (nowTemp1 > maxTemp1) maxTemp1 = nowTemp1;
if (nowTemp1 < minTemp1) minTemp1 = nowTemp1;
}//Temp Calculations Probe 2
void tempCalc2()
{
float temp2 = sensors.getTempC(Probe2);nowTemp2=temp2 * 10 + 0.5;
if (nowTemp2 > maxTemp2) maxTemp2 = nowTemp2;
if (nowTemp2 < minTemp2) minTemp2 = nowTemp2;
}//( THE END )*/
This is what I have been running since last night. It seems to be working fine so far, although I'd like to improve it as much as possible. Will update when I have something new.