[seriesposts name=“Arduino“, orderby=“user_order“]
Der Temperatursensor LM35 CZ ist ein analoger Sensor.
Nähers zur Funktionsweise findet sich auf dem Datenblatt
Schaltplan
Notes: 4
Ein einfacher Code, der die aktuelle Temperatur über die Serielle Schnittstelle ausgibt:
/* Test for the Temperature Sensor LM35CZ */
const unsigned int TEMP_SENSOR_PIN = 0;
const float SUPPLY_VOLTAGE = 5000;
const unsigned int BOUD_RATE = 9600;
void setup() {
Serial.begin(BOUD_RATE);
}
void loop() {
Serial.print(get_temperature());
Serial.println(" C");
}
const float get_temperature() {
const int sensor_volate = analogRead(TEMP_SENSOR_PIN);
const float voltage = sensor_volate *(SUPPLY_VOLTAGE / 1024);
return voltage / 10;
}