WildBill,
latest code:
With no alarm lcd displays:
TEMP0 = 22.25 ( CURRENT TEMP)
TEMP1 = 22.25 ( CURRENT TEMP)
When alarm occurs on temp1 LCD displays:
TEMP0 = 22.25 ( CURRENT TEMP)
Alarm1 = 29.50 ( CURRENT TEMP) plus Led is blinking
When alarm occurs on temp0 LCD displays:
Alarm0 = 25.50 ( CURRENT TEMP) ---- but "Alarm0" is blinking and led is not blinking
TEMP1 = 22.50 ( CURRENT TEMP)
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 16/2
// LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 20/
// pin connected to sensor
int tempPin = 2;
// define the onewire obj needed for connecting to onewire components
OneWire oneWire(tempPin);
// define dallas obj, makes it easier to read temp
DallasTemperature tempSens(&oneWire);
DeviceAddress insideThermometer = {
0x28, 0x25, 0x33, 0xDC, 0x03, 0x00, 0x00, 0x7E };
DeviceAddress outsideThermometer = {
0x28, 0x67, 0x3D, 0xDC, 0x03, 0x00, 0x00, 0xC7 };
void setup() {
// set up the serial console
Serial.begin(9600);
pinMode(7, OUTPUT); //pin selected to control OVER TEMP LED
// digitalWrite(7, LOW);
lcd.init(); // initialize the lcd
lcd.backlight();
//lcd.begin(16,2); // columns, rows. use 16,2 for a 16x2 LCD, etc.
lcd.clear(); // start with a blank screen
// initialise the temp sensor
tempSens.begin();
// set the resolution to 10 bit (good enough?)
tempSens.setResolution(insideThermometer, 10);
tempSens.setResolution(outsideThermometer, 10);
}
void loop() {
// get the current temperature
tempSens.requestTemperatures();
// get the temperature in centigrade
// index 0 as multiple temp sensors can be connected on same bus
float t = tempSens.getTempCByIndex(0);
Serial.print("TEMP0 = ");
Serial.print(t);
lcd.setCursor(0,0);
lcd.print("TEMP0 = ");
lcd.print(t);
delay(500);
float t1 = tempSens.getTempCByIndex(1);
lcd.setCursor(0,1);
lcd.print("TEMP1 = ");
lcd.print(t1);
Serial.print("TEMP1= ");
Serial.print(t1);
//delay(200);
if (t > 29) //sensor0
{
lcd.setCursor(0,0);
Serial.println("Alarm0= ");
lcd.print("Alarm0= ");
lcd.setCursor(8,0);
Serial.println(t);
lcd.print(t);
digitalWrite(7,HIGH);
}
if (t1 > 25) //sensor 1
{
lcd.setCursor(0,1);
Serial.println("Alarm1= ");
lcd.print("Alarm1= ");
lcd.setCursor(8,1);
Serial.println(t1);
lcd.print(t1);
digitalWrite(7,HIGH);
}
else
{
digitalWrite(7,LOW);
}
}