Hallo, hab hier mal einen BMW temperatur Sensor angeschlossen und den jurs code mal hochgeladen, die werte natürlich entsprechend geändert, jetzt bekom ich gut 20 grad weniger angezeigt als es tatsächlich ist, kann mir eventuell jemmand sagen wo der fehler liegt, anbei mal der code, die Temperaturtabele und anschlußschema
#define ABSZERO 273.15
#define MAXANALOGREAD 1023.0
#define ANALOGPIN A0
float temperature_NTCB(float T0, float R0, float B, float RV, float VA_VB)
{
T0 += ABSZERO; // umwandeln Celsius in absolute Temperatur
float RN = RV * VA_VB / (1 - VA_VB); // aktueller Widerstand des NTC
return T0 * B / (B + T0 * log(RN / R0)) - ABSZERO;
}
float temperature_NTC(float T0, float R0, float T1, float R1, float RV, float VA_VB)
{
T0 += ABSZERO; // umwandeln Celsius in absolute Temperatur
T1 += ABSZERO; // umwandeln Celsius in absolute Temperatur
float B = (T0 * T1) / (T1 - T0) * log(R0 / R1); // Materialkonstante B
float RN = RV * VA_VB / (1 - VA_VB); // aktueller Widerstand des NTC
return T0 * B / (B + T0 * log(RN / R0)) - ABSZERO;
}
void setup()
{
Serial.begin(115200);
}
void loop()
{
float T0 = 20; // Nenntemperatur des NTC-Widerstands in °C
float R0 = 2500; // Nennwiderstand des NTC-Sensors in Ohm
float T1 = 120; // erhöhte Temperatur des NTC-Widerstands in °C
float R1 = 113; // Widerstand des NTC-Sensors bei erhöhter Temperatur in Ohm
float Vorwiderstand = 2490; // Vorwiderstand in Ohm
float temp;
int aValue = analogRead(ANALOGPIN);
temp = temperature_NTC(T0, R0, T1, R1, Vorwiderstand, aValue / MAXANALOGREAD);
Serial.println(temp);
delay(1000);
}
T [°C] R [Ω]
-40 45,313
-30 26,114
-20 15,462
-10 9,397
0 5,896
10 3,792
20 2,500
30 1,707
40 1,175
50 834
60 596
70 436
80 323
90 243
100 187
110 144
120 113
130 89
Connectors