Created
March 27, 2021 13:10
-
-
Save elktros/9ce440f6ce1ce53574044f566f122351 to your computer and use it in GitHub Desktop.
Code for ESP32 DS18B20 Interface with results on Serial.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <OneWire.h> | |
#include <DallasTemperature.h> | |
#define DS18B20PIN 16 | |
/* Create an instance of OneWire */ | |
OneWire oneWire(DS18B20PIN); | |
DallasTemperature sensor(&oneWire); | |
void setup() | |
{ | |
Serial.begin(115200); | |
/* Start the DS18B20 Sensor */ | |
sensor.begin(); | |
} | |
void loop() | |
{ | |
sensor.requestTemperatures(); | |
float tempinC = sensor.getTempCByIndex(0); | |
Serial.print("Temperature = "); | |
Serial.print(tempinC); | |
Serial.println("ºC"); | |
delay(3000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment