degrees output

This commit is contained in:
Manuel Weiser 2018-05-10 19:02:04 +02:00
parent 3b9688979d
commit 40f7e29a62

View File

@ -4,7 +4,20 @@ int sensorPin = A7;
int PWM = 7; // Fan int PWM = 7; // Fan
int sensorVal; int sensorVal;
int PWMVal; int PWMVal;
bool fanRunning = false;
// Vars für Temp Umrechnung
float R1 = 10000;
float logR2, R2, T, Tc, raw, temp;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
float calculateTemp(float raw) {
R2 = R1 * (1023.0 / (float)raw - 1.0);
logR2 = log(R2);
T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
Tc = T - 273.15;
return Tc;
}
void setup() { void setup() {
pinMode(sensorPin, INPUT); pinMode(sensorPin, INPUT);
@ -14,13 +27,15 @@ void setup() {
} }
void loop() { void loop() {
Serial.println(sensorVal);
delay(1000);
//read sensor value and set upper limit cap //read sensor value and set upper limit cap
sensorVal = analogRead(sensorPin); sensorVal = analogRead(sensorPin);
temp = calculateTemp(sensorVal);
Serial.println(String(temp) + " C");
delay(1000);
// Fan an // Fan an
if (sensorVal > 700) { if (sensorVal > 587) {
digitalWrite(PWM, HIGH); digitalWrite(PWM, HIGH);
} }
if (sensorVal < 500) { if (sensorVal < 500) {