// DS18B20 Temperature Sensor using ESP32
/*
i. -55 to 125
ii Uses 1 Wire Communication (1 data line (must be pulled HIGH) and 1 gnd wire)
iii. user configurable resolution between 9 to 12-bits
iv. 64-bit Serial Code whihc is unique to each sensor
GND, DQ (must be pulled HIGH), VDD
*/
#include <DallasTemperature.h>
#include <OneWire.h>
// GPIO where the DS18B20 is connected to
const int oneWireBus = TX;
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(oneWireBus);
// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensor(&oneWire);
void setup() {
// put your setup code here, to run once:
Serial.begin (115200);
sensor.begin ();
}
void loop() {
// put your main code here, to run repeatedly:
sensor.requestTemperatures ();
float temp = sensor.getTempCByIndex (0);
Serial.print ("Temperature: ");
Serial.print (temp);
Serial.println ("ºC");
delay (3000);
}
Loading
aitewinrobot-esp32c3-supermini
aitewinrobot-esp32c3-supermini