update: I found one of my sensors wires to have been possibly shorting out due to improper insulation around the connections. I replaced the sensor entirely and my problems were cut in half, however, after a few minutes of running the program, the temperatures being displayed on my LCD just froze at something like 65 and 75 even though the actual temperature was still climbing. I proceeded to reset the device and it kept displaying 000 and then 185 again. After a few more resets it suddenly started working again.
My #1 sensor may be shorting out like the #2 sensor, so I may replace it as well, however I noticed that even though the temps were not being displayed on the lcd screen, the controller was still flipping relays accordingly to the actual temperatures. I avoided posting my complete code until now because I assumed this was some kind of a hardware issue.
Here's my complete code, is there any hang-up in how I'm sending the sensor data to the screen that I missed?
#define CHANNEL1 8 //LowSpeed RELAY
#define CHANNEL2 9 //HighSpeed RELAY
#include <genieArduino.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2 //DALLAS serial sensors go into input 3
// 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);
DeviceAddress coolant = { 0x28, 0x1F, 0x70, 0x66, 0x04, 0x00, 0x00, 0x0B };//LEDDIGITS0 and LEDDIGITS7 RED/BLUE/BLACK
DeviceAddress cooly = { 0x28, 0xB3, 0x58, 0x66, 0x04, 0x00, 0x00, 0xEC };//LEDDIGITS9 RED/GREEN/BLACK
int sliderVal = 170;
int sliderVal2 = 190;
int slider0_val = 190;//Set point for high speed radiator fan
int slider1_val = 170;//Set point for low speed radiator fan
int humidity, t, temp;
void setup()
{
pinMode(CHANNEL1, OUTPUT);
pinMode(CHANNEL2, OUTPUT);
digitalWrite(CHANNEL1, LOW);
digitalWrite(CHANNEL2, LOW);
sensors.begin();
sensors.setResolution(coolant, 10);
sensors.setResolution(cooly, 10);
genieBegin (GENIE_SERIAL, 56000); //Serial0 for 4D Display
genieAttachEventHandler(myGenieEventHandler);
//Reset the Display (change D4 to D2 if you have original 4D Arduino Adaptor)
pinMode(4, OUTPUT); // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
digitalWrite(4, 1); // Reset the Display via D4
delay(100);
digitalWrite(4, 0); // unReset the Display via D4
delay (3500); //let the display start up
genieWriteObject(GENIE_OBJ_LED_DIGITS, 6, sliderVal2);//preset value
genieWriteObject(GENIE_OBJ_SLIDER, 0, sliderVal2);//preset value
genieWriteObject(GENIE_OBJ_LED_DIGITS, 8, sliderVal);//preset value
genieWriteObject(GENIE_OBJ_SLIDER, 1, sliderVal);//Preset value
}
void loop()
{
static long waitPeriod = millis();
genieDoEvents(); // Do this every loop, checks the input buffer for data from the display and runs myGenieEventHandler()
//Read from sensor every 100ms and write to the display
if (millis() >= waitPeriod)
{
temp = (t * 1.8) + 32; //Convert *C to *F.
float inside = sensors.getTempF(coolant);
float outside = sensors.getTempF(cooly);
//float tempC = sensors.getTempC(insideThermometer);
//insideThermometer = sensors.requestTemperatures(); // Send the command to get DALLAS temperatures
float tempF;
sensors.requestTemperatures();
Serial.println (inside);////////GOOOD CODE
Serial.println (outside);///////GOOD CODE AGAIN... YAY!
genieWriteObject(GENIE_OBJ_LED_DIGITS, 0, inside);//The first line of code in the section gets ignored for some reason...?? copy and paste
genieWriteObject(GENIE_OBJ_ANGULAR_METER, 0, inside);//HOME SCREEN TEMP GAUGE.........FORM 0
genieWriteObject(GENIE_OBJ_LED_DIGITS, 0, inside);//HOME SCREEN TEMP..................FORM 0
genieWriteObject(GENIE_OBJ_LED_DIGITS, 1, outside);//LOW.............FORM 1
genieWriteObject(GENIE_OBJ_LED_DIGITS, 7, outside);//HIGH............FORM 5
genieWriteObject(GENIE_OBJ_LED_DIGITS, 9, outside); //HOME SCREEN SENSOR DISPLAY........FORM 0
genieWriteObject(GENIE_OBJ_ANGULAR_METER, 1, outside);//HOME SCREEN SENSOR OUTPUT GAUGE.......FORM 0
waitPeriod = millis() + 10; // rerun this code in another 100ms time.
///////////////////////////
if (slider0_val > outside)
{
digitalWrite(CHANNEL1, HIGH);
}
else
{
digitalWrite(CHANNEL1, LOW);
}
/////////////////////////////////////////////////////
if (slider1_val > outside)
{
digitalWrite(CHANNEL2, HIGH);
}
else
{
digitalWrite(CHANNEL2, LOW);
}
}
}
void myGenieEventHandler(void)
{
genieFrame Event;
genieDequeueEvent(&Event);
//If the cmd received is from a Reported Event
if (Event.reportObject.cmd == GENIE_REPORT_EVENT)
{
if (Event.reportObject.object == GENIE_OBJ_SLIDER) // If the Reported Message was from a Slider
{
if (Event.reportObject.index == 0) // If Slider0
{
slider0_val = genieGetEventData(&Event); // Receive the event data from the Slider0
}
}
}
//If the cmd received is from a Reported Event
if (Event.reportObject.cmd == GENIE_REPORT_EVENT)
{
if (Event.reportObject.object == GENIE_OBJ_SLIDER) // If the Reported Message was from a Slider
{
if (Event.reportObject.index == 1) // If Slider1
{
slider1_val = genieGetEventData(&Event); // Receive the event data from the Slider1
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////
//If the cmd received is from a Reported Object, which occurs if a Read Object is requested in the main code, reply processed here.
if (Event.reportObject.cmd == GENIE_REPORT_OBJ)
{
//Put code in here, like the above, if you want to process data when you have used a genieReadObject in your main loop
//Currently there are none, so this section has no code.
//Filter out the Object and the Index like above, and then same the data into a variable as required.
}
}
Hopefully my comment lines aren't too confusing, it's still a work in progress somewhat, but I tried my best to keep it clear and simple.