When using the above Im thinking you have to find the address of each sensor using a sketch to search for them. I had a sketch that was working and now it does not. Can someone take a look at this sketch and tell me where those temp address might be. Thanks
#include <LiquidCrystal.h>
//I2C bus support
#include <Wire.h>
//I2C
#include <LiquidCrystal_I2C.h>
//OneWire bus suport
#include <OneWire.h>
//DS18B20 temperature sensor support
#include <DallasTemperature.h>
//DS18B20 sensor pin
#define ONE_WIRE_BUS 8
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address for the LCD display
#define MOTION_SENSOR_READ_PIN 3 // can be only 2
#define MOTION_SENSOR_DEFAULT 0 // set to 0 if by default your sensor returns LOW and to 1 if it returns HIGH (with pullup)
#define SWITCH_READ_PIN 2 // can be only 3 for you
#define SWITCH_DEFAULT 0 // set to 0 if by default your sensor returns LOW and to 1 if it returns HIGH (with pullup)
#define AWAKE_INTERWAL 12000 // in milliseconds
#define DECIMALS_OF_TEMPERATURE 2
#define OUTPUT_VOLTAGE 3.3 // in volts
#define OUTPUT_PIN 4
#define ADDICTION_FIRST_TEMP -.5 // it can be less then 0 if you want to substract the value
#define ADDICTION_SECOND_TEMP 0 // it can be less then 0 if you want to substract the value
bool wokeup = true; // helper
long int wakeup_start_time = -1; // helper
bool isCelsius = false;
void setup()
{
lcd.init();
// lcd.backlight(); //Turns backlight on
// sensors.begin();
pinMode(MOTION_SENSOR_READ_PIN, INPUT);
pinMode(SWITCH_READ_PIN, INPUT_PULLUP);
pinMode(OUTPUT_PIN, OUTPUT);
attachInterrupt(digitalPinToInterrupt(MOTION_SENSOR_READ_PIN), onMovementDetected, MOTION_SENSOR_DEFAULT == 1 ? FALLING : RISING);
// attachInterrupt(digitalPinToInterrupt(SWITCH_READ_PIN), onSwitchPressed, SWITCH_DEFAULT == 1 ? FALLING : RISING);
Serial.begin(9600);
sleep();
}
void onMovementDetected() {
wokeup = false;
wakeup_start_time = millis();
wakeup();
}
int prev_state = 0;
void updateSwitch() {
if (digitalRead(SWITCH_READ_PIN) < prev_state) {
isCelsius = !isCelsius;
}
prev_state = digitalRead(SWITCH_READ_PIN);
}
void updateTimer() {
delay(100);
if (millis() - wakeup_start_time >= AWAKE_INTERWAL) {
sleep();
wakeup_start_time = -1;
wokeup = true;
}
}
void sleep() {
analogWrite(OUTPUT_PIN, 0);
lcd.clear();
// lcd.noBacklight();
Serial.println("Backlight off");
}
void wakeup() {
analogWrite(OUTPUT_PIN, int(map(OUTPUT_VOLTAGE, 0, 5, 0, 255)));
// lcd.backlight();
Serial.println("Backlight on");
}
float celToFar(float temp) {
float p = pow(10, DECIMALS_OF_TEMPERATURE);
return round(((temp * 1.8) + 32) * p) / p;
}
void showFirstSensor() {
float temp = sensors.getTempCByIndex(0) + ADDICTION_FIRST_TEMP;
String smb = "*C";
if (!isCelsius) {
temp = celToFar(temp);
smb = "*F";
}
lcd.setCursor (0, 0 );
lcd.print("OutsideTemp:");
lcd.print(temp);
Serial.print("Outside Temp: " + (String)temp + smb);
}
void showSecondSensor() {
float temp = sensors.getTempCByIndex(1) + ADDICTION_SECOND_TEMP;
String smb = "*C";
if (!isCelsius) {
temp = celToFar(temp);
smb = "*F";
}
lcd.setCursor (0, 1 );
lcd.print("Pool Temp :");
lcd.print(temp);
Serial.println("\tPool Temp: " + (String)temp + smb);
}
void loop() {
updateSwitch();
if (!wokeup) {
lcd.backlight();
sensors.requestTemperatures();
showFirstSensor();
showSecondSensor();
updateTimer();
} else {
lcd.noBacklight();
}
}