Hi all, this is my first sketch (I'm sure you can tell), after looking at many projects I decided that I had to write my own if i really wanted to understand what is going on, plus i am looking for something a little simpler than most of what was out there. No buttons or inputs really, just an LCD to print out relevant info, i have most of that code worked out but am having an issue with one timer not firing off when called,, specifically the timer for -- void HID_ON()
here is my code
i have removed all the LCD stuff to simplify trying to figure out the problem. All other events work correctly,, please give a look at my code, any and all help would be appreciated, for my current problem, or any other things you can spot
Thanks,
Matt
#include <Time.h>
#include <TimeAlarms.h>
#include <Wire.h>
#include <DS1307RTC.h>
#include <DallasTemperature.h>
#include <OneWire.h>
#include <DHT.h>
#define DS1307_I2C_ADDRESS 0x68
#define ONE_WIRE_BUS 2
#define DHTPIN 4
#define DHTTYPE DHT22
#define relay1 5
#define relay2 6
#define relay3 7
#define relay4 8
#define led1 9
#define led2 10
DHT dht(DHTPIN, DHTTYPE);
OneWire ourWire(ONE_WIRE_BUS);
DallasTemperature sensors(&ourWire);
DeviceAddress Probe1 = { 0x28, 0x85, 0x0A, 0xAC, 0x4, 0x0, 0x0, 0x87 }; // Address of my ds18b20
void setup()
{
Serial.begin(9600);
Serial.println("In setup....");
setSyncProvider(RTC.get); // the function to get the time from the RTC
if (timeStatus() != timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");
////////////////////////////// create the alarms
Alarm.alarmRepeat(13,18,30,ledON); // 11:30am
Alarm.alarmRepeat(23,35,30,ledOFF); // 9:30pm
Alarm.alarmRepeat(13,18,00,BledON); // 6:30pm
Alarm.alarmRepeat(23,35,40,BledOFF); // 6:30am
Alarm.alarmRepeat(12,35,05,fanON); // 8:30a
Alarm.alarmRepeat(12,35,50,fanOFF); // 1:30am
Alarm.alarmRepeat(12,37,10,HID_ON); // 9:30am
Alarm.alarmRepeat(12,37,30,HID_OFF); // 11:30pm
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
pinMode(relay3, OUTPUT);
pinMode(relay4, OUTPUT);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
digitalWrite(relay1, HIGH); // Wired as normally closed //
digitalWrite(relay2, HIGH);
digitalWrite(relay3, HIGH);
digitalWrite(relay4, HIGH);
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalClockDisplay();
sensors.begin();
sensors.setResolution(Probe1, 12);
Wire.begin();
dht.begin();
airON();
Serial.print("AIR RELAY 1 ON ");
Serial.println("Startup Completed");
} //end setup
void loop()
// ACTIONS
{
digitalClockDisplay();
Alarm.delay(1000);
sensors.requestTemperatures(); // Send the command to get temperatures
float temperature0 = sensors.getTempFByIndex(0); // TANK Temp
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
// TEMP CONTROLLED RELAY 4 - HEATER
{ if(temperature0 < 79.00) {
digitalWrite(relay4, LOW); // heater relay
Serial.print("Heater RELAY 4 ON ");
}
else if (temperature0 > 80.01)
digitalWrite(relay4, HIGH);
Serial.print("Heater RELAY 4 OFF ");
}
}
// functions to be called when an alarm triggers:
void ledON(){
digitalClockDisplay();
digitalWrite(led1, LOW);
Serial.print("White Lights Pin 9 ON ");
}
void ledOFF(){
digitalClockDisplay();
digitalWrite(led1, HIGH);
Serial.print("White Lights Pin 9 OFF ");
}
void BledON(){
digitalClockDisplay();
digitalWrite(led2, LOW);
Serial.print("Blue Lights Pin 10 ON ");
}
void BledOFF(){
digitalClockDisplay();
digitalWrite(led2, HIGH);
Serial.print("Blue Lights Pin 10 OFF ");
}
void HID_ON(){
digitalClockDisplay();
digitalWrite(relay3, LOW);
Serial.print("FAN RELAY ON ");
}
void HID_OFF(){
digitalClockDisplay();
digitalWrite(relay3, HIGH);
Serial.print("FAN RELAY OFF ");
}
void fanON(){
digitalClockDisplay();
digitalWrite(relay2, LOW);
Serial.print("FAN RELAY ON ");
}
void fanOFF(){
digitalClockDisplay();
digitalWrite(relay2, HIGH);
Serial.print("FAN RELAY OFF ");
}
void airON(){
digitalClockDisplay();
digitalWrite(relay1, LOW);
Serial.print("AIR RELAY 1 ON ");
}
//void airOFF()
//{ /////// FUTURE USE ///////////////
// digitalClockDisplay();
// digitalWrite(relay1, HIGH);
// Serial.print("AIR RELAY 1 OFF ");
//}
void digitalClockDisplay() /////// CLOCK //////////
{
Serial.print(hour()); // digital clock display of the time
printDigits(minute());
printDigits(second());
Serial.println();
}
void printDigits(int digits)
{
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}