Do you see what this is? This is data being captured from the UNIX command Screen, which reads and buffers serial data in a nice clean happy way WHILE NOTHING ELSE DOES. This is just dummy data for now, from another arduino being sent from an xBee wireless interface ($30 ebay!) for testing purposes, it’s pretty useful for figuring out how to get that data to load into a webpage.

So have I figured out the web interface for displaying data yet? No. I’ve been looking into a lot of options, such as the php-serial class that can read serial data, although that doens’t buffer the data nicely and you get a handful of characters at random. I’m currently thinking of having Screen dump its output into a text file, and then just reading the last few lines with a php script. Should be pretty easy, although not the most kind to my server. Ever since it got cold out, I haven’t been paying much attention to this project as the current system has still been operating without faults for quite some time now. The 2nd Arduino I bought for testing will probably go to use in an RFID lock system using electronic door strikes.
If you’re curious, here’s the revised code. It’s a lot easier to understand whats going on (really, its not much) You’ll noticed I removed a couple of useless things like the RGB LED code which used up a lot of memory. Oh, and no pinouts are designated yet until I draw up some cleaner schematics.
//Lots of example code used from Sparkfun provided libraries, etc.
//NOTES
//Reserved Pins
//D2, D3, Xbee
#include//Arduino pinouts
int maxTempPin; //TBD This is for the potentiometer, setting max temp
int heaterOverridePin; //This is a manual on/off switch
int heaterRelayPin; //
int waterPressurePin; //
int thermistorPin = 0; //Analog pin 0
uint8_t pinRx = 2 , pinTx = 3; // xBee Serial pins 2 and 3. This is an option for the sparkfun XBee shields to switch the serial port pins
//Temperature control
double maxTemp;
double temperature;//Flow Control
//TBD, this is for Jet control, which will be added in the future. Requires rather powerful relays.//Heater & Heater Overrides
String heaterstatus; //ON or OFF, set in the heaterOn and heaterOff functions.
boolean waterPressure; //Checks to see if heater has water pressure
boolean heaterOverride; //Checks to see if heater manual switch is on or off//xBee
NewSoftSerial xBeeSerial( pinRx , pinTx );
int sendcounter = 0;void setup()
{
xBeeSerial.begin(9600);
Serial.begin(9600);
}void loop()
{
/*
SETTING MAX TEMPERATURE
*/
//Read maximum temperature value set by a 10k pot
maxTemp = analogRead(maxTempPin);
//This formula turns the number into a useable range of around 70-120
maxTemp = sqrt(maxTemp)*4-10;
//No hot tub should ever go above 110, so this changes the above (if greater than 110) to 110
if (maxTemp>=110)
{
maxTemp=110;
}/*
READING CURRENT WATER TEMPERATURE FROM THERMISTOR
*/
temperature = Thermister(analogRead(thermistorPin));
//Convert temperature to Fahrenheit
temperature = (temperature * 1.8) + 32;/*
HEATER CONTROL
*/
//
if (temperature<=maxTemp && waterPressure==true && heaterOverride==false)
{
heaterOn();
}
// We add +3 to maxTemp so that the heater is not constantly cycling on/off, it must drop 3 degrees first.
if (temperature>maxTemp +3 || waterPressure==false || heaterOverride==true)
{
heaterOff();
}/*
SERIAL MESSAGE OUTPUT FOR LCD DISPLAY. Set up for a 4 line display which I am yet to obtain.
*/Serial.print("Temperature: ");
Serial.println(temperature);Serial.print("Temperature Max: ");
Serial.println(maxTemp);Serial.print("Heater Status: ");
Serial.println(heaterstatus);Serial.print("Water Pressure: ");
Serial.println(waterPressure);if (sendcounter == 100) //So that we don't have a flood of data, a counter delay is used. This makes the delay around 7 seconds.
{
xBeeSerial.print("Temperature: ");
xBeeSerial.println(temperature);
xBeeSerial.print("Temperature Max: ");
xBeeSerial.println(maxTemp);
xBeeSerial.print("Heater Status: ");
xBeeSerial.println(heaterstatus);
xBeeSerial.print("Water Pressure: ");
xBeeSerial.println(waterPressure);
Serial.println(sendcounter);
sendcounter=0;
}
else
{
sendcounter=sendcounter+1;
}}
void heaterOn() //Turns the heater ON
{
analogWrite(heaterRelayPin,255);
heaterstatus="ON";
}
void heaterOff() //Turns the heater OFF
{
analogWrite(heaterRelayPin,0);
heaterstatus="OFF";
}
double Thermister(int RawADC) //Code to get value from Thermister in a CELCIUS. It is converted in the code above.
{
double Temp;
// See http://en.wikipedia.org/wiki/Thermistor for explanation of formula
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
return Temp;
}



