I am using one of the Thermistor codes from this website that basically measures temperature and prints that to the serial monitor.
If the temperature comes to freezing point, I want the program to take some action. For testing I want to switch on 'Led13'
The code in question is below.
However, it does not work. The serial monitor prints "Celsius: 0.0", but whatever value I try, I do not get the Led to go on, wether I use: "temp <=0", "temp<= 0.0", "temp <1", it just won't work and I have no idea what I am doing wrong
void loop() {
float temp;
temp=Thermistor(analogRead(ThermistorPIN)); // read ADC and convert it to Celsius
Serial.print("Celsius: ");
Serial.print(temp,1); // display Celsius
Serial.println("");
if (temp <= 0) {
digitalWrite(outPin, HIGH); // I added this but it does not work
}
ed1000:
I am using one of the Thermistor codes from this website that basically measures temperature and prints that to the serial monitor.
If the temperature comes to freezing point, I want the program to take some action. For testing I want to switch on 'Led13'
The code in question is below.
However, it does not work. The serial monitor prints "Celsius: 0.0", but whatever value I try, I do not get the Led to go on, wether I use: "temp <=0", "temp<= 0.0", "temp <1", it just won't work and I have no idea what I am doing wrong
void loop() {
float temp;
temp=Thermistor(analogRead(ThermistorPIN)); // read ADC and convert it to Celsius
Serial.print("Celsius: ");
Serial.print(temp,1); // display Celsius
Serial.println("");
if (temp <= 0) {
digitalWrite(outPin, HIGH); // I added this but it does not work
}
delay(5000); // Delay a bit...
}
In if (temp <= 0) { , 0 is type integer unless typcast to a float
Where is your setup() code? You have to open serial communication before making serial calls eg Serial.begin(9600);
Thanks all for your quick input. Yes I did all these things you suggest, but I already found the culprit (ofcourse immediately after I placed my help request). The thermistor had come loose, The print out kept giving me a steady 0.0 celsius which seemed OK as i had it in icewater, but after reconnecting the thermistor, it all worked as it shld.
Still a bit odd as the "o.o" value that was printed was the 'temp variable' but who cares, it got fixed.
This is good to know, seems the ADC is center biased at 1/2Vref, typically and ADC is 0 to Vref in nRes bits. I have not fully read the mpu spec sheets from Amtel yet.