I am new to the forum and to creating anything of this kind, so please be patient and helpful!
Description:
This device is being created to turn the load pump on and off for charging a heat storage tank from a heat source (i.e. wood boiler, solar, etc.) It uses 2 thermistors, one in a well submerged 6" into the storage tank water, and the other strapped to the pipe to determine the temperature of the charging water. There is a set point temperature that the tank is trying to acheive. The pump will be turned on to charge so long as the charging water is higher in temperature by as much as the differential than the tank and the tank has not yet reached its set point temperature.
Componenents:
I plan to use the Arduino Duemilanove USB board.
I plan to use a DPDT 120vac relay to turn the pump on/off and have the digital pin output 5v to trigger the coil. Is 5v sufficient to trigger it?
I plan to use National Semiconductor LM34 thermistors
Code:
I have cobbled together this code from other projects on this forum and on the web. I think it is pretty close to the minimum I would need to run this. When I try to verify it I get this message when it reaches the bottom:
In function [ch8216]void loop()[ch8217]:
error: a function-definition is not allowed here before [ch8216]{[ch8217] token
A fix for the error and any additions or fixes for the hardware or software for this project would be appreciated. Thanks for your help!
int sourcetempPin = 0; // Source thermister connected to analog pin 0
int storagetempPin = 1; // Storage tank thermister connected to analog pin 1
int relayPin = 12; // Relay connected to digital pin 12
int setpoint = 175; // Set the desired storage maximum temp in Fahrenheit here
int differential = 5; // Set the differential between source temp and storage temp in Fahrenheit here
unsigned long last_temperature_check_time = 0;
void setup()
{
pinMode(sourcetempPin, INPUT); // sets the analog pin as input
pinMode(storagetempPin, INPUT); // sets the analog pin as input
pinMode(relayPin, OUTPUT); // sets the digital pin as output
}
void loop() // Checks temperatures and turns pumps on/off
{
unsigned long time = millis();
if (time - last_temperature_check_time > 20000) //has it been 20 seconds?
{
//Check Temperature routine
long tempsource;
long tempstorage;
long temp1;
long temp2;
int source_val=0;
int storage_val=0;
source_val=analogRead(sourcetempPin); //read value of center leg of LM34 on source
storage_val=analogRead(storagetempPin); //read value of center leg of LM34 on storage
tempsource = source_val; //output voltage of LM34, 10mV = 1 Degree Celcius
tempstorage = storage_val; //output voltage of LM34, 10mV = 1 Degree Celcius
temp1=(5tempsource100/1024); //creates true Fahrenheit
temp2=(5tempstorage100/1024); //creates true Fahrenheit
//Turn Relay on/off routine
if ((temp1) > (temp2) + (differential)) //check source temp for differential
{
digitalWrite (relayPin, HIGH); //if temp is above x degrees turn pin "ON"
}
else if ((temp2) > (setpoint)) //check storage temp against setpoint
{
digitalWrite (relayPin, LOW); //if temp is below x degree turn pin "OFF"
}
else
{
digitalWrite (relayPin, LOW); //if temp is below x degree turn pin "OFF"
}
delay(20000); //Check temp every 20 seconds
}