hi all,
everything here is doing what it must, but the temp is incorrect.
as a result, when I 'settemp', the difference between 'test' 'settemp' and 'alarm' is no good
lets say I 'settemp' @ 80deg. then 'test' must be 75deg and alarm 90deg
#include <C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\EEPROM\EEPROM.h>
#include "DigiKeyboard.h"
int counter = 0;
int Vo;
float R1 = 10000;
float logR2, R2, T, Tc;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
float settemp;
void setup() {
pinMode (1, OUTPUT);
pinMode (0, INPUT); //0
pinMode (2, INPUT);
EEPROM.read (1);
digitalWrite(1, HIGH);
delay(500);
digitalWrite(1, LOW);
}
void loop() {
Vo = analogRead(2); //2
R2 = R1 * (1023.0 / (float)Vo - 1.0);
logR2 = log(R2);
T = (1.0 / (c1 + c2 * logR2 + c3 * logR2 * logR2 * logR2));
Tc = T - 273.15;
DigiKeyboard.println(Tc);
settemp = EEPROM.read(1);
if
(digitalRead(0) == HIGH ) //0
{
settemp = Tc;
EEPROM.write (1, settemp);
digitalWrite(1, HIGH);
delay(500);
digitalWrite(1, LOW);
DigiKeyboard.println(" set; ");
}
else
{
}
if
( (Tc > settemp - 5) && (counter < 1) )
{
digitalWrite(1, HIGH);
delay(250);
digitalWrite(1, LOW);
DigiKeyboard.println(" test; ");
counter++;
}
else
{
}
if
(Tc > settemp + 10)
{
digitalWrite(1, HIGH);
DigiKeyboard.println(" alarm; ");
}
else
{
digitalWrite(1, LOW);
}
delay (500);
}
some examples of the temp diff(+/-):
tester ATtiny
15 7.68
30 18.2
50 28.8
60 33.5
so as you can see 'test' would be about 24deg and 'alarm' 50deg if 'settemp' was @ 30deg
that's a difference of +/- 25deg between 'test' and 'alarm' and it should be 15deg