Arduino UNO

Hello,

I’ve bought the sparklefun kit for controling the temperature of my boa constrictors (and playing offcource :))

I have some issues conserning the use of a temperature sensor, relay combination.

Everything is hooked up and running smoothly.

BUT

When the temperature raises above desired temperature, when it suposed to switch off, the relay keeps switching on/off every second.

When the temperature decreases below the desired temperature, the relay turns off like it should.

I’ve noticed when it switches on/off/on/off/ect, the temperature readings drops, then goes up again end so on…

I used the circ-11 from sparclefun and just connected my temp sensor to 5V, GND and A0.

My first thought was the diode is draining the accuracy of the sensor, forgive me if i’m wrong haha…

Thanks everyone!!!

EDIT:

Forgot to post the code:

int temperaturePin = 0; 
int klik = 2;


void setup()
{
  Serial.begin(9600);  
  pinMode (klik, OUTPUT);
}
 
void loop()                     
{
 float temperature = getVoltage(temperaturePin);  
 temperature = (temperature - .5) * 100;          
                                                  
 Serial.println(temperature);      

if (temperature > 24.00)			    
  {
    digitalWrite (klik, LOW);
    delay (1000);	
 
  }
if (temperature < 24.00)			    
  {
    digitalWrite (klik, HIGH);	
    delay (1000);	
    	 }
  
 delay(1000);                                    
}


float getVoltage(int pin){
 return (analogRead(pin) * .0048828125); 
                                       
}

Something to try…

Change:

float getVoltage(int pin){
return (analogRead(pin) * .0048828125);
                                       
}

To:

float getVoltage(int pin){
  analogRead(pin);
  delay(500);
  return (analogRead(pin) * .0048828125);                                
}

one or the other of the if statements needs a check for equality, such as <=

Hey,

Thanks for the reply.

After I tried the above suggestions, it remains turning on/off/on/ect. when the

temperature decreases below 24 degrees.

When it increases above 24, it remains “off” like it should.

It looks like every time the relay releases, the temperature readings increase, and stays

untill the relay switches again…

Thanks

What is a “circ-11”? I searched and found nothing.

It would be helpful if you could provide a circuit diagram.

My first thought is that the back emf of the relay may be causing the processor to reboot. I also was wondering if the power rail droops when the relay is on and jumps back up when off and that is causing the temp variation. Have you measured the voltage of the supply when the realy is on and off?

Thanks for the relpy’s.

I’ve found out when I set a 2 degrease difference between on and off temperature setting, it will stop clicking.

The only issue is, why does the switching of the relay creates a conflict on the accuracy of the temp sensor.

I am going to try an external power supply, maybe that will solve things.

@ fll-freak:

This is the circ-11 schematic:

http://img688.imageshack.us/img688/6783/naamloosgpa.jpg

I’ve only added a temp sensor to the 5v, gnd and digital.

fll-freak:
What is a “circ-11”? I searched and found nothing.

It would be helpful if you could provide a circuit diagram.

My first thought is that the back emf of the relay may be causing the processor to reboot. I also was wondering if the power rail droops when the relay is on and jumps back up when off and that is causing the temp variation. Have you measured the voltage of the supply when the realy is on and off?

"CIRC-11" refers to the Experimenter's Guide that comes with the Arduino. Look up [[http://ardx.org/CIRC11/](http://ardx.org/CIRC11/) to get all the juicy details on it.](http://ardx.org/CIRC11/)

you have to either increase the delay or increase the temp range. think about it. as soon as the temp gets to 24.01 degrees it turns off, when you read it again 1 second later it has dropped to 23.99 degrees so turns on and goes back to 24.01. even signal noise could cause this rather than actual temperature changes

i would recommend a 1 degree range rather than a delay change.

yo may also want to do some research on PID control