From 8398fcde8db253d383bc76600aaf0d534e861027 Mon Sep 17 00:00:00 2001 From: Schnitzel Date: Wed, 2 Oct 2024 16:25:22 +0200 Subject: [PATCH] add tehtmal reader --- sketch_oct2a/sketch_oct2a.ino | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 sketch_oct2a/sketch_oct2a.ino diff --git a/sketch_oct2a/sketch_oct2a.ino b/sketch_oct2a/sketch_oct2a.ino new file mode 100644 index 0000000..7edeaf7 --- /dev/null +++ b/sketch_oct2a/sketch_oct2a.ino @@ -0,0 +1,42 @@ +/* + DS18B20 Basic Code + Temperatur auslesen mit einem DS18B20 Temperaturfühlers + Created by cooper.bin, 2020 + https://makesmart.net/ +*/ + +#include +#include + +// Der PIN D4 wird als Daten-Pin verwendet +#define ONE_WIRE_BUS 2 + +OneWire oneWire( ONE_WIRE_BUS ); +DallasTemperature DS18B20( &oneWire ); + +// In dieser Variable wird die Temperatur gespeichert +float temperature; + + +void setup(){ + // Seriellen Monitor initialisieren + Serial.begin(115200); + + // DS18B20 initialisieren + DS18B20.begin(); +} + +void loop(){ + + // Temperatur auslesen + DS18B20.requestTemperatures( ); + // Temperatur in einer Variable speichern + temperature = DS18B20.getTempCByIndex( 0 ); + + // Die Ausgabe über den seriellen Monitor + Serial.println( String( temperature ) + " °C"); + + // 5 Sekunden Pause + delay( 5000 ); + +} \ No newline at end of file