The view from April, Daylight savings time adjustment for your RTC

The boiler has worked flawless all winter, I am happy with the software and hardware but with all things mechanical there is room for improvement. I have just started my 7th ton of pellets. And I really don’t want to get into my 8th and don’t think I will have to, especially if I institute some energy conservation in the software. This is the time of year that I would normally burn what my grandmother called a “trash fire”. In her case it was some cardboard boxes from the trash and maybe an odd shaped piece of wood or two. Just enough for 3-4 hours in the evening, letting it burn out overnight since the days get up to 40°F or 50°F there’s no need for more fire than that. Later in the month most of the nights will be above freezing. But I still want to light the boiler in the evening mostly for the hot water and then turn it off at 2-3 am, so I wrote that into the software and it has gotten the consumption down to 1-2 bags per day. I also added a function in the software to change the real time clock for Daylight savings time and back automatically. It’s not fully tested but I think it will work OK.

void DaylightSavingsSchedule(){//start function
if (Year ==2013 && Month ==11 && Day ==2 && hour ==2&&DaylightTest ==0)//fall back an hour
if (Year ==2013 && Month ==11 && Day ==4 && hour ==2&&DaylightTest ==1)//reset flag
DaylightTest =0;
if (Year ==2014 && Month ==3 && Day ==9 && hour ==2&&DaylightTest ==0)//spring forward an hour
if (Year ==2014 && Month ==3 && Day ==10 && hour ==2&&DaylightTest ==1)//reset flag
DaylightTest =0;
if (Year ==2014 && Month ==11 && Day ==2 && hour ==2&&DaylightTest ==0)//fall back an hour
if (Year ==2014 && Month ==11 && Day ==3 &&DaylightTest ==1)//reset flag
DaylightTest =0;
if (Year ==2015 && Month ==3 && Day ==8 && hour ==2&&DaylightTest ==0)//spring forward an hour
if (Year ==2015 && Month ==3 && Day ==9 && hour ==2&&DaylightTest ==1)//reset flag
DaylightTest =0;
if (Year ==2015 && Month ==11 && Day ==1 && hour ==2&&DaylightTest ==0)//fall back an hour
if (Year ==2015 && Month ==11 && Day ==2 &&DaylightTest ==1)//reset flag
DaylightTest =0;
if (Year ==2016 && Month ==3 && Day ==13 && hour ==2&&DaylightTest ==0)//spring forward an hour
if (Year ==2016 && Month ==3 && Day ==14 && hour ==2&&DaylightTest ==1)//reset flag
DaylightTest =0;
if (Year ==2016 && Month ==11 && Day ==6 && hour ==2&&DaylightTest ==0)//fall back an hour
if (Year ==2016 && Month ==11 && Day ==7 &&DaylightTest ==1)//reset flag
DaylightTest =0;
}//end function

void SpringForward(){//start function
DateTime now =; //get the data from the RTC
now =now.unixtime()+3600; //subtracts an hour from the time
RTC.adjust(DateTime(now.unixtime())); //resets the time to an hour earlier
DaylightTest =1; //flag variable so it won’t go back in time continously
}//end function

void FallBack(){//start function
DateTime now =; //get the data from the RTC
now =now.unixtime()-3600; //subtracts an hour from the time
RTC.adjust(DateTime(now.unixtime())); //resets the time to an hour earlier
DaylightTest =1; //flag variable so it won’t go back in time continously
}//end function

PID works!


After tweaking the Kp and making the Ki work in the software the graph speaks for itself. The software is controlling the temperature to the set point of 140°F within a fraction of a degree for the most part. This was the last difficult piece of puzzle. I did not use the PID function in the Arduino language, instead I wrote my own with a large part of the understanding of the code coming from the excellent description by Brett Bueargard who wrote the PID library, as well as assistance from a friend who helped me understand the problem better in a spreadsheet. I now have a burner that works dependably and is modular so that I can make changes and see if I can further improve the efficiency. I now have software which will hold the temperature without worry. I plan to add a proof of fire sensor next for the mechanical part of the project, and add the ability to set the Real Time clock in the software. Onward, ever onward, but for today I think I will have a beer!

OpenLog partially tested

Well I have to say, I am not particularly impressed with OpenLog’s documentation but I finally got a sketch to work with OpenLog based heavily on the OpenLog command sketch.  I soldered up a  Real time clock kit and am waiting on some male to male jumper wires to breadboard up a thermistor and clock to fully test the OpenLog data logging in a closer to real world trial.  Of course until it is finally mounted in the boiler control box and mounted on the boiler this will only be the next step in testing.

Hard experience has taught me many things work on the desk that do not work in the field due often to poor electronic practice, missing diodes, filtering capacitors, missing resistors….

Here is the code which I intend to run when I get the project bread boarded, it compiles but is untested.

RTC, Thermisoter, OpenLog test

One thermistor attached to analog pins 0
The Real time clock SDA pin is attached to analog 4, the RTC SCL pin is attached to analog pin 5

The circuit:
* Thermister  Analog in 0
* RTC SDA, Analog pin 4
* RTC SCL, Analog pin 5
* Arduino digital 0 (rx), OpenLog TX
* Arduino digital 1 (tx), OpenLog Rx
* Arduino digital 2, OpenLog Grn

Created 8/24/12

#include <math.h> // include the library code for thermsiter functions
#include <Wire.h>
#include “RTClib.h”

//section for time keeping
int hour;                //hour
int minute;              //minute

int Roomtemp;            //room temperature

int statLED = 13;        //flashes LED connected to pin 13 for troubleshooting
int resetOpenLog = 2;    //reset on OpenLog

long DataDwell = 60000;    //seperates the data readings by 1 minute
long prevmillis =0;        // previous millis

//define function to calculate the temperature in fahrenheit for Analog pin 0
double ThermisterRoom(int RawADC) {//beginning of function
double Temp;
Temp = log(((10240000/RawADC) – 10000));
Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
Temp = Temp – 273.15;            // Convert Kelvin to Celcius
Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit
return Temp;
}//end of function

void TimeSection() {//start time function
DateTime now =;
hour=now.hour(),DEC;       //get the hour from the RTC chip
minute=now.minute(),DEC;   //get the minute from the RTC chip
}// end time function

void OpenLogData(){//start OpenLogData function
int RoomTemp = ThermisterRoom(analogRead(0));  //read from the sensor
Serial.print (hour);
Serial.print (“:”);
Serial.print (minute);
Serial.print (“, “);
Serial.println (RoomTemp);
}// end OpenLog Data section

void setup()
{//Begin Setup section
pinMode(statLED, OUTPUT);        //set pin to output
pinMode(resetOpenLog, OUTPUT);   //set pin to output

Serial.begin(9600); // initiate serial communication
//Reset OpenLog
digitalWrite(resetOpenLog, LOW);
digitalWrite(resetOpenLog, HIGH);
//Wait for OpenLog to respond with ‘<‘ to indicate it is alive and recording to a file
while(1) {
if( == ‘<‘) break;
//Send three control z to enter OpenLog command mode
//Works with Arduino v1.0
//Wait for OpenLog to respond with ‘>’ to indicate we are in command mode
while(1) {
if( == ‘>’) break;
//send the open file
Serial.print(“Templog.txt\r”); //\r in string + regular print works with older v2.5 Openlogs

//Wait for OpenLog to return to waiting for a command
while(1) {
if( == ‘>’) break;
// send the command to append the file
Serial.print(“append Templog.txt\r”);

//Wait for OpenLog to indicate file is open and ready for writing
while(1) {
if( == ‘<‘) break;

//start process of setting clock time
RTC.adjust(DateTime(__DATE__, __TIME__));

} //End setup section

void loop()
{//Begin Loop section
if (millis()-prevmillis> DataDwell)
{//start if sections
TimeSection();           //displays the time
OpenLogData();           //saves the time and solar temp to the SD card
}// end if section

}//End loop section



OpenLog Firmware updated and tested

OpenLog is a data logger from SparkFun electronics that is touted as being easy to use and a reliable writer to a microSd card.  I haven’t found that to be true, I think it is a pain in the a** but maybe that’s the experience more than the actual product.  I ordered the data logger in January and got busy and didn’t have the time to use it so I set it aside.

Really the only reason I ordered it was because I could not get GoBetwino, a Freeware Arduino Data logging software program to work.   The GoBetwino program uses a USB connection to a computer connected to the Arduino to log to a file on the PC.  A great concept that I tested and worked fine on the desktop machine.  However on the laptop that I was using to make changes to the Arduino controlling the boiler  in the shop it didn’t work.  It seemed easier to come up with a standalone solution rather than troubleshoot the USB connections, the power managment issues with the Laptop etc.  So I bought the data logger.

As I wrote in an earlier post since the time of my purchase of the OpenLog board it was recommended to update the firmware, this required updating the board with a FTDI board that accepts the USB connection from the PC to update the firmware, after 2-3 hours of frustration this task is finally completed.  The main problem being Windows XP didn’t seem to recognize the FTDI board and assign it a com port but finally was able to find the correct driver and download the firmware.

I ran the test sketch, pulled the micro SD card and reviewed the data.  The board  did log the data correctly so the next step is to write a function that writes temperature data to a file with a time stamp.  Since I have an Arduino on my desk with a real time clock chip that measures the outside temperature  as well as the temperature of a solar hot water storage tank this would seem like a perfect application to test.   After testing the function in that application it will be easy to modify the function for the monitoring of the boiler function.  I prefer to write the code in functions and call the functions from the main body of the loop.  This makes the code modular and easy to reuse.  I comment very carefully and probably over comment, but I personally prefer to make the code painfully simple to understand on the assumption I may not look at the code again for a few years.  I am hoping you will comment as well since your comments will no doubt improve the code.

I will post the function when I complete it.  Thanks for reading.

2nd Burn Test

New exhaust fan configuration

I changed the configuration of the exhaust fan to pull the intake air from the top of the furnace to the exhaust pipe, which continues down the pipe to help create a vacuum to pull more air from the furnace.  I also used hi temp caulking to close up more leaking area making the boiler much tighter.  The positive draft, not quite a vacuum and the caulking allowed the furnace to heat to the set point of 160°F and turn on the circulator pump without filling the shop with smoke.   The shop did eventually get quite smoky so I shut the boiler down to allow addressing the smoke issue.

The boiler water circulated through the oil fired boiler loop.  I turned up the thermostat in the shop to include the shop to be heated and use some of the hot water.  The circulator turned on and off several times in response to the returning cooler water, but eventually managed to maintain the water temp for the most part.  I probably only ran the boiler for 2 hours total and only 1/2 hour to 45 minutes with the circulator pump on.  Great test run though.

The software is still in the prototype stage as well.  I wired a potentiometer into an Analog pin of the Arduino to set the on time of the Auger.  The dwell time (off time) of the Auger is a fixed 50 seconds.  I made the program so that the on time is some percentage of the off time.   So the potentiometer can turn the Auger up to a 50 second on time or down to a 1 or 2 second on time.  After the first burn it was apparent that changing the parameters on the computer, compiling and uploading was a pain so I wired in a hardware solution.  The next iteration of the software needs to have some error checking and data smoothing added into the program to allow the program to make more informed decisions and stop the relay chatter on the circulator pump.    So considering I am babysitting today, actually I was told it was parenting, I think I will stick to software upgrades and maybe go to Aubochon’s to see if they have braided fire insulation to seal the burner unit and lighting doors.  I think I may order some over center latches for the lighting door to allow easy access but tight sealing and of course more caulking.

The LCD stayed perfect all day yesterday, the other change I made was to put the relays on a separate power supply.   I also added back in the clock which does not seem to be a problem to the LCD.  The other thing I can productively do today is order another clock and Uno so that I can build another enclosed box to run the thermostat.  I miss having the outside temp on my desk and last night since the Arduino was tied up on the boiler I had to be the thermostat for the solar tank.  WTF?