katchupoy
New member
Mike check my code....
My temp does not freezes. I believe most people here has the same problem, but I think I found a way and I am running it right now.
I took the concept of blink without delay. Also used it on my RELAY1 and RELAY2 function. I just duplicated it and created a THEMISTOR function.
Take a look here.
Maybe you can do the same with your DS18B20???
I first created and defined the function PRINTTEMP outside of the loop...
Then i just inserted the function and call it out inside the loop for the FADE IN, MAX, and FADE OUT. Together with other functions that need to run while fading in and out.
Hope this helps.
My temp does not freezes. I believe most people here has the same problem, but I think I found a way and I am running it right now.
I took the concept of blink without delay. Also used it on my RELAY1 and RELAY2 function. I just duplicated it and created a THEMISTOR function.
Take a look here.
Maybe you can do the same with your DS18B20???
I first created and defined the function PRINTTEMP outside of the loop...
PHP:
/* ******************************************************************************************************************** */
/* * * */
/* * D E F I N E : T H E R M I S T O R * */
/* * * */
/* ******************************************************************************************************************** */
double Thermistor(int RawADC) {
double Temp;
// See 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
Temp = (Temp * 1.8) + 32.0; // Convert to Fahrenheit
return Temp;
}
void printTemp()
{
double temp = Thermistor(analogRead(3)); // Read sensor on Pin 3
lcd.setCursor(9,0);
lcd.print(" ");
lcd.print(temp, 0); // Prints out Temp, 0 converts it to real numbers, no decimal
lcd.print((char)223); // Prints degree character
lcd.print("F ");
unsigned long currenttempMillis = millis(); // Use blink without delay to set temp sampling frequency
if(currenttempMillis - tempMillis > 30000) // 30 seconds delay between sampling. We do not want
{ // for our fan to be ON and off too fast.
tempMillis = currenttempMillis;
if (temp > 80)
{
digitalWrite(tempPin1, HIGH); // If temp is greater than 80, fan is on
lcd.setCursor(10,0);
lcd.print("Fan:On ");
}
else
{
digitalWrite(tempPin1, LOW); // If temp is less than 80, fan is off
lcd.setCursor(9,0);
lcd.print("Fan:Off ");
}
}
} // End printTemp
Then i just inserted the function and call it out inside the loop for the FADE IN, MAX, and FADE OUT. Together with other functions that need to run while fading in and out.
PHP:
{
onesecond(); // updates clock once per second
countdown--;
relay2();
relay1();
printTemp();
}
Hope this helps.
