Radio data transfer!

I have been working through some of Robert Faluidi’s excellent book ” Building Wireless Sensor Networks with Zigbee, Xbee and Arduino Processing”  Working with these radios has been a lot of fun.  The book is a great introduction to the basics and gives you a great idea for what can be done with a little imagination.

My plan for the chip boiler is to continue building and testing blocks of code that will be all integrated into the boiler control program at least at some point for some of the testing period.  Last winter the boiler ran for approximately a month and  a half.  In that time there were many starts and stops which made me wish the Arduino could provide better data for the feedback of the program itself, hence the data logging program just tested.

A second desire is the real time temperature monitoring of the boiler water as well as the auger feed pipe temperature.  Hence the need for wireless radio temperature monitoring.    That is what the wireless data transfer will accomplish.  I am picturing a simple box with a LCD screen to display the data running on a 9v battery.  Video to follow soon. Thanks as always for reading.


Milestones, why we need to take a minute.

There is so much to do in life,  so much to to make, test, verify, improve, install etc.   that it is good to look back on goals completed and know that progress is being made.  I think that is why I like programming so much, it is near instant feedback to test and observe the results.  In my outside of night work hobby life I am finally going to get a machine out of my shop that has been there nearly a year.    That is going to free up a lot of physical space, but mentally I know it is going to be huge.  A constant reminder of time and money gone.  YEA!

On the project side I received a package I ordered from Yourduino.com to complete a phase of the OpenLog testing.  My plan has been to create a temperature recorder with a real time clock using a Arduino Uno  logging time and temperature data to OpenLog’s microSD card recorder.  Here is the finished code, that compiles and works.

/*
Temperature and Time recorder test

This code records time and temperature to a microSd card, this is a test program to prove the ability and
allow the code to be used in other programs as part of a larger code development

A thermistors is attached to analog pin 0
The Real time clock SDA pin is attached to analog 4, the RTC SCL pin is attached to analog pin 5

The circuit:
Arduino Digitial Pins
0 RX to MicroSD TX
1 TX to MicroSD RX
2 to MicorSD GRN
3
4
5
6
7
8
9
10
11
12
13

Inputs
* Thermister, Analog in 0
* RTC SDA, Analog pin 4
* RTC SCL, Analog pin 5

Created 9/10/12
http://www.frugaltinker.com

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

RTC_DS1307 RTC;

// define I/O pins

// define constants for clarity

// define variables
int statLED = 13;          //toggles LED
int resetOpenLog = 2;      //reset OpenLog

int hour = 0;              // clock hour
int minute = 0;            // clock minute

// the following variables are long’s because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.

unsigned long prevmillis = 0;     // prevmillis
long DisplayDwell = 7500; // dwell time of 7.5 secs

//define function to calculate the temperature in fahrenheit for Analog pin 0
double Thermister(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 OutsideTempSection() {// outside temp section
Serial.print(Thermister(analogRead(0))); //print to the lcd should be the Outside temp if thermistor is hooked up properly
Serial.print(“, “);
}// end outside temp function

void TimeSection() {//start time function
DateTime now = RTC.now();
hour=now.hour(),DEC;       //get the hour from the RTC chip
minute=now.minute(),DEC;   //get the minute from the RTC chip
if (hour>=13)              //PM Section
hour=hour-12;           //printed hour is the hour
Serial.print (hour);          //prints the hour
Serial.print (“:”);           // prints a colon
if (minute<10)             //adds a “0” if the time is single digit
Serial.print (“0″);
Serial.print(minute);          //prints minuts
hour=now.hour(),DEC;       //get the hour from the RTC chip
if (hour>=12)   // prints pm
Serial.println (” PM”);
if (hour<12)                       // prints am
Serial.println (” AM”);
}// end time function

void setup()
{//Begin Setup section
// pinMode(ledPin, OUTPUT);
pinMode(statLED, OUTPUT);
pinMode(resetOpenLog, OUTPUT);

Wire.begin();
RTC.begin();
RTC.adjust(DateTime(__DATE__, __TIME__));
Serial.begin(9600);             //initiate serial communication and define baud rate
delay (1000);                   //delay 1 sec for the data logger to begin
//Reset OpenLog
digitalWrite(resetOpenLog, LOW);
delay(100);
digitalWrite(resetOpenLog, HIGH);

//Wait for OpenLog to respond with ‘<‘ to indicate it is alive and recording to a file
while(1) {
if(Serial.available())
if(Serial.read() == ‘<‘) break;
}

//Send three control z to enter OpenLog command mode
//Works with Arduino v1.0
Serial.write(26);
Serial.write(26);
Serial.write(26);
//Wait for OpenLog to respond with ‘>’ to indicate we are in command mode
while(1) {
if(Serial.available())
if(Serial.read() == ‘>’) 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(Serial.available())
if(Serial.read() == ‘>’) 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(Serial.available())
if(Serial.read() == ‘<‘) break;
}

} //End setup section

void loop()
{//Begin Loop section
if (millis()-prevmillis> DisplayDwell)
{//start if sections
OutsideTempSection();    //checks and displays the outside temp section
TimeSection();           //displays the time
prevmillis=millis();
}// end if section

}//End loop section

 

 


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 Yourduino.com  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:
Inputs
* Thermister  Analog in 0
* RTC SDA, Analog pin 4
* RTC SCL, Analog pin 5
Outputs
* Arduino digital 0 (rx), OpenLog TX
* Arduino digital 1 (tx), OpenLog Rx
* Arduino digital 2, OpenLog Grn

Created 8/24/12

http://www.frugaltinker.com
*/

#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
RTC_DS1307 RTC;

//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 = RTC.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);
delay(100);
digitalWrite(resetOpenLog, HIGH);
//Wait for OpenLog to respond with ‘<‘ to indicate it is alive and recording to a file
while(1) {
if(Serial.available())
if(Serial.read() == ‘<‘) break;
}
//Send three control z to enter OpenLog command mode
//Works with Arduino v1.0
Serial.write(26);
Serial.write(26);
Serial.write(26);
//Wait for OpenLog to respond with ‘>’ to indicate we are in command mode
while(1) {
if(Serial.available())
if(Serial.read() == ‘>’) 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(Serial.available())
if(Serial.read() == ‘>’) 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(Serial.available())
if(Serial.read() == ‘<‘) break;
}

//start process of setting clock time
Wire.begin();
RTC.begin();
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
prevmillis=millis();
}// 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.


CNC Plasma cutter progress

I  finished the assembly of the two  carriages on the x axes of the CNC machine.  The y axis is mounted and this next week the goal is to assemble the carriage to Acme nut connections and build the linear carriage for the y axis.  So if all goes as planned next weekend or sooner could be the first prototype test of the machine, the z axis will not be workable but I am sure I can find a way to attach a pencil the axis to see movement.    That is a great goal for the week.

My SparkFun package of an FTDI Adapter board and and second board will allow me to reload the firmware on the OpenLog board I ordered in January.  I am dreading this a bit, electronics and computer area things are my weakness so I am a bit nervous but will tackle this job and test in a example sketch this week.  I’ll bet that will take any free time I may have up but will get me that much closer to my goals.  X Axis-CNC Plasma Cutter


Software cuts pellets by third, saving $112/month

Minor changes in the software that force the boiler to maintain a tighter range from the set point has cut the fuel consumption from 3 (40 pound) bags of pellets to 2 daily.    These software improvements and a extension to the pellet hopper mean the boiler will now run 24 hours without needing  additional fuel.    The hopper extension adds at least another 40 lb bag of pellets capacity bringing the total capacity to approx. 2 1/2-3 bags.  I haven’t measured only estimated.

The boiler  set point is currently set at 135°F which seems to work just fine for the temperatures we have been having and the software is consistently running within4 degrees of set point.  This range may seem excessive but seems to run just fine.  The program is becoming more modular in that there is only one number to change,  the set point.  The set point currently  is a variable declared in the setup section of the program but eventually the set point will be self adjusted by the program based on the outside temperature.  Economy and efficiency by software optimization is the goal for this next week.

We have had a very mild winter in my opinion.  The Heating Degree Day total for the month of Dec 2011 was 1091 as measured by the local weather station.  The normal is 1209 HDD a difference of 118 HDD, not as much as I would have thought.  The total for the month of January 2012 so far is 1140 with four days to go, with a normal of 1419.  We’ll see how the month ends but if it continues as the average day it will be short approx the same number of HDD as  last month,December.   My interest in HDD is to see if there is a correlation to HDD and fuel consumption.  There should be and if there is than the fuel economy is starting to improve.  As I told a friend of mine, at this point the boiler is like a truck I used to own, 10 mpg  going uphill loaded, 10 mpg empty going downhill….so seeing fuel consumption changing to track the weather will be the first step to seeing some optimization.

Software work on fuel economy and the  extrapolation of costs for the upcoming remainder of the season is of great interest.    The next step in fuel economy may be better insulation  of the boiler and piping and will not be as simple as software improvements.  But if I can get a correlation between the outside temperature and fuel consumption that is measurable then the software will be nearly optimized and further improvements will have to come from physical changes.  This week sees a 40 pound bag and $4.00 improvement per day, $28/week, $112 per month.  Next week’s goal:  another $60/month.  I am hoping for a total seasonal heating cost of $500 or less using $200/ton pellets.  I will consider that a huge victory for heating a 2300 sq ft house with 3 garage doors.


Feed improvments fix the LCD garbling!

The sprockets have been replaced and improved with key ways cut into the jack shaft and auger.  This allows positive feeding without slippage.  The jack shaft placement was constrained so adjustment of the chains is limited to what linkages can be removed or replaced with half links and adding a slack tension device on the slack side of the roller chain.  With this complete the LCD problems appear to be fixed.  Without proper tension the chain did not ride on the sprockets smoothly and the tension could take up suddenly adding a jerk to the system.  Without this mechanical jerk in the system the motor can work more smoothly allowing the LCD to not get the power fluctuations that garble the display.  The feed problems appear to be fixed but in the last test the unit ran for four days without fail and at this point although there is a marked improvement that time has not been surpassed.  Next on the list is the hopper extension to allow feeding of two bags of pellets.  This will allow 16 hours of run time without any software improvements.

Top view of roller chain drive of auger feed


Remaining Issues

Last night I went over the remaining issues with my girlfriend.  So here is the list and the possible fixes and approaches to each item.

1) Smoke.  There is still some remaining minor smoking issues. Possible fixes, better caulking, stronger fans, a wind baffle, burner redesign?  Pipe cleaning?  I think I will start with a wind baffle and some better caulking, next furnace will have a better gasket design.  I also have ordered a Magnehelic to help determine the normal static pressure so that a baseline can be established and tested against.  The boiler is working so ordering fans without more facts would be a expensive trial and error process.

2) Feed issues.  There continues to be an occasional feed issue.  So much so that today I am  going to take the burner off the boiler and see if I can determine the binding issue.  Possible solutions?  Increase in torque, already ordered more sprockets.

3) LCD issues.  The problem has been traced to the relay and I think needs some old fashioned power regulation, no doubt involving a capacitor to remove the spike when the relay is released.  Possible fixes, ordered an LCD backpack to free up some IO and also allow only one power and ground to go to the LCD.

4) Hopper Extension.  3 bags per day means a bag every 8 hours, no all that conducive to being able to leave for a day long event.

5) Data logging.  Tuning the machine is always the fun part and so dependable data logging needs to happen.  I ordered a SD card writer.  This should allow the internal Arduino software to work with the card independently of Windows XP which seems to have problems with continual or repeated Arduino upload.  I also plan to test the upload and communication with a Linux operating system.

Back to work!  Today I built the wind baffle and so after the auger is clear back to the experiment.


Good test for the boiler with -5°F overnight temperature

I restarted the boiler with a friend on Friday afternoon on the 13th of January.  At present it is Sunday morning at 6:45.  Thirty nine hours since starting, in that time the temperature has dropped to a low of -5°F which is the current temperature and the fuel usage has been a total of 5 bags.  The house is still comfortable and has not shown any dip or problems in maintaining temperature.  The only noticeable differences are two things.  The lack of the oil fired boiler running which I can hear upstairs and always makes me a little twitchy.  The second difference is the temperature of my office.   My office is off the utility room which holds the furnace and so is normally quite warm after a cold night.  Today it is the temperature the thermostat is set to maintain.

A few numbers, I paid $215/ton for the pellets, so the cost per 40 lb bag is $4.30.  The hours per bag is approx. 7.8.  This will need a  longer time average to confirm but is probably a reasonably good number so in rough terms this is 3 bags per day for a cost of $12.90/day.  I looked back to see if I had a furnace run time data which I did have a limited amount.  On October 17, 2007 the furnace ran a total of 4.1 hours on a day that had a high of 51 and a low of 33 for a total Heating Degree Day of 22.7.  (Heating Degree Days are calculated as (in °F) 65-(day’s max temp-day’s min temp)/2 or to restate 65-average temp) .  Taking the furnace run time as 4.1 hours x nozzle rate of 1 gal per hour this translates to 4.1 gals usage for a total cost at $3.85 per gallon of $15.78 for one day relatively mild day.  Yesterday’s HDD calculation using a high of 29 and a low of 11 yeilds and average of 20.  So 65-20=41.  Using a simple ratio of HDD/Furnace Run time would calculate to a furnace run time of 7.4 hours per day for a cost of $28.50 per day.  Contrasting this with the pellet costs yields a savings of $15.60 for that one day.

So is that accurate?  That was a lot of math using some not very exact calculations.  The math was done correctly but Heating Degree Day calculations are notoriously rough.  Many oil companies have moved onto more sophisticated methods and of course this is just a snap shot of one day.  But as an reality check  at this point I am confident 5 tons of pellets would easily get this building through the winter for a total cost of $1075.   If I used 800 gals of oil throughout the heating season this would cost me $3080 at a cost of $3.85 per gallon.  So yeah I think the numbers are reasonably accurate if not conservative.  Wait until I try chips at a cost of $40/ton……too fun.


3rd Configuration

After having the issues described in the last post the decision was made to reconfigure the feed for the third time.  Hopefully the third time is the charm.  The feed is now horizontal again with a reconfigured air box and single fan blowing along with the exhaust fan.  The auger was extended into the burn area to allow the pipe to be mounted flush to the inner surface of the mounting plate and so that the auger will push the burning pile down the burner trough.  After some minor glitches the burner is up and running.  I made some minor changes to the software to allow the burner to run more at a lower temperature and changed the setpoint to 140°F from 135°F.  Minor changes but all part of the tweaking and learning process.

The goal for this coming week will be to  monitor the fuel usage and see if the system can keep up with the predicted below zero temperatures forecast for tonight.

New Airbox and feed