add tehtmal reader
This commit is contained in:
parent
ff4c370bab
commit
8398fcde8d
1 changed files with 42 additions and 0 deletions
42
sketch_oct2a/sketch_oct2a.ino
Normal file
42
sketch_oct2a/sketch_oct2a.ino
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
DS18B20 Basic Code
|
||||
Temperatur auslesen mit einem DS18B20 Temperaturfühlers
|
||||
Created by cooper.bin, 2020
|
||||
https://makesmart.net/
|
||||
*/
|
||||
|
||||
#include <OneWire.h>
|
||||
#include <DallasTemperature.h>
|
||||
|
||||
// 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 );
|
||||
|
||||
}
|
Loading…
Reference in a new issue