const float BETA = 3950;// should match the Beta Coefficient of the thermistor
void setup() { //Analog temperature sensor: NTC (negative temperature coefficient) thermistor.
pinMode(2,INPUT);
Serial.begin(9600);
}
void loop() {
if(Serial.available()>0){
String command = Serial.readStringUntil('\n');
if (command=="temp2"){
sensor_ntc();
}
}
delay(1000); // Erwärmen sich die Bauteile, lockern sich Elektronen aus den Gitteratomen. Sie verlassen ihren Platz im Gefüge und transportieren Strom deutlich besser
}
void sensor_ntc(){ //???
int analogValue = analogRead(2);
analogValue = map(analogValue, 0, 4096, 0, 1024);
float celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
Serial.print("Temperature: ");
Serial.print(celsius);
Serial.println(" ℃");
delay(1000);
}