#include "DHTesp.h"
const int DHT_PIN = 15;
DHTesp dhtSensor;
// Potentiometer is connected to GPIO 34 (Analog ADC1_CH6)
const int potPin = 34;
// variable for storing the potentiometer value
int potValue = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
dhtSensor.setup(DHT_PIN, DHTesp::DHT22);
pinMode(potPin, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
// Reading potentiometer value
potValue = analogRead(potPin);
Serial.println(potValue);
delay(500); // this speeds up the simulation
TempAndHumidity data = dhtSensor.getTempAndHumidity();
Serial.println("Temp: " + String(data.temperature, 2) + "°C");
Serial.println("Humidity: " + String(data.humidity, 1) + "%");
}
Loading
esp32-devkit-c-v4
esp32-devkit-c-v4