Hi all.
I need your help. I am building a thermostat that has a fan. The fan starts working when the temprature is too high as well as a red led lights. The problem is that when the red led lights the temprature increases a lot. Why that happens?
Hi all.
I need your help. I am building a thermostat that has a fan. The fan starts working when the temprature is too high as well as a red led lights. The problem is that when the red led lights the temprature increases a lot. Why that happens?
My project is displaying the temprature of a room on a LCD and according the temprature lighting some leds and a fan. For instance when the temprature is 30 celsius a green led will light when the temprature is 35 a yellow led will light and when the temprature is 40 a red led will light and the fan will start working only in 40 temprature. Thats all.
However when the temprature is 30 and the the green led lights, suddenly it bacomes 70 . Thats the problem that I face.
My project is displaying the temprature of a room on a LCD and according the temprature lighting some leds and a fan. For instance when the temprature is 30 celsius a green led will light when the temprature is 35 a yellow led will light and when the temprature is 40 a red led will light and the fan will start working only in 40 temprature. Thats all.
However when the temprature is 30 and the the green led lights, suddenly it bacomes 70 . Thats the problem that I face.
OK, pretty sure the descriptions I provided of how you drive things and the effect on the 5V supply will be the problem then, what kind of fan is it ?
Selim Kigitzi wrote:
My project is displaying the temperature of a room on a LCD and according the temperature lighting some leds and a fan. For instance when the temperature is 30 Celsius a green led will light when the temperature is 35 a yellow led will light and when the temperature is 40 a red led will light and the fan will start working only in 40 temperature. Thats all.
However when the temperature is 30 and the the green led lights, suddenly it becomes 70 . Thats the problem that I face.
By "suddenly it becomes 70" I assume you mean that the display shows 70 instead of 30, not that the temperature in the room suddenly jumps to 70C
I didn't see anything in the code that would cause this to happen. However, I did notice this in your code:
temprature = readTemprature();
if(temprature > minTemprature){
digitalWrite(greenLed, HIGH); ...
}
else if(temprature > midTemprature){
digitalWrite(yellowLed, HIGH); ...
}
else if (temprature > maxTemprature){
digitalWrite(redLed, HIGH);...
}
else{
lcd.setCursor(12,1);
lcd.print("OFF");
}
Arduino will execute the if-then-else expressions in the order you have written them. Since minTemp < midTemp < maxTemp, as soon as temprature is greater than minTemp Arduino will execute the code that sets greenLed high. It will never get to the midTemp or maxTemp tests. You need to change the order of the ifs so that it check maxTemp first, then midTemp, then minTemp.
I would suggest getting the software running first. Instead of setting temprature to readTemprature(), set it to various constants to make sure the LCD is displaying the correct values. When that's working, add in the LEDs. At some point add in the thermometer. When testing the motor, first use an LED so that you can be sure the control software is working. Then hook up the actual motor driver.
The beauty of Arduino is that it's really easy to make changes and recompile, so you can get things working one step at a time, That way when it stops working it's probably (but not always) because of the change you just made, which makes finding the problem so much easier.
JMO/YMMV
It sounds like the analog-to-digital converter in the CPU is being affected by power supply fluctuations as Peter implies.
Using a separate power supply for the power devices might also help.
Good catch John, I did not look at this from the perspective of the code, I covered off the hardware and wiring problems and why the temp could be jumping
between us we got this covered lol.
nice.