Well, after MUCH reading and trying to find the answers myself, I'm still stumped. This is my first project outside of the simple ones that come with the starter kit.
I have 2 DS18B20 waterproof sensors reading two different temperatures in my wood kiln. Wet Bulb and Dry Bulb. I have a relay wired to an outlet I am trying to control based on one of the temperature values. When i manually feed 5v to the switch pin the relay works. I can't get it to work thru the code though. Even when I set the value of it to HIGH it does not come on BUT the red LED lights up faintly. (digitalWrite(heaterpin, HIGH)) I have my temperature settings at 60 for now in the sketch just to test manually. Any pointers on where to look, what to read would be greatly appreciated. Thank you.
#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
// Relay wire is plugged into pin 6 on the Arduino
#define HeaterRelay 6
// 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:
// Arduino 1-Wire Address Finder
DeviceAddress insideThermometer = { 0x28, 0x38, 0xA3, 0x7D, 0x08, 0x00, 0x00, 0x3F };
DeviceAddress outsideThermometer = { 0x28, 0x0F, 0xC6, 0x7D, 0x08, 0x00, 0x00, 0x94 };
void setup(void)
{
// Start up the library
sensors.begin();
// set the resolution to 9 bit
sensors.setResolution(insideThermometer, 9);
sensors.setResolution(outsideThermometer, 9);
pinMode(backLight, OUTPUT);
digitalWrite(backLight, LOW); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
lcd.begin(16,2); // columns, rows. use 16,2 for a 16x2 LCD, etc.
lcd.clear(); // start with a blank screen
}
void printTemperature(DeviceAddress deviceAddress)
{
int tempC = sensors.getTempC(deviceAddress);
int heaterpin = 6;
digitalWrite(heaterpin, LOW);
if (tempC == -127.00) {
lcd.print("Error");
} else {
//lcd.print(tempC);
//lcd.print("/");
lcd.print(DallasTemperature::toFahrenheit(tempC));
if (insideThermometer > 60) digitalWrite(heaterpin, LOW);
if (insideThermometer < 60) digitalWrite(heaterpin, HIGH);
}
}
void loop(void)
{
delay(2000);
sensors.requestTemperatures();
lcd.setCursor(0,0);
lcd.print("DryB: ");
printTemperature(insideThermometer);
lcd.setCursor(0,1);
lcd.print("WetB: ");
printTemperature(outsideThermometer);
//if (insideThermometer > 60) digitalWrite(heaterpin, LOW);
//if (insideThermometer < 60) digitalWrite(heaterpin, HIGH);
}