/**
ESP32 + DHT22 Example for Wokwi
https://wokwi.com/arduino/projects/322410731508073042
*/
#include "DHTesp.h"
#include "BluetoothSerial.h"
/*
#define LED 23
BluetoothSerial BT;
*/
const int DHT_PIN = 27;
DHTesp dhtSensor;
void setup() {
Serial.begin(115200);
dhtSensor.setup(DHT_PIN, DHTesp::DHT22);
/*
BT.begin("ESP32_LED_Control"); //name of your bluetooth device
Serial.println("Bluetooth Device is Ready to Pair");
pinMode(LED, OUTPUT);
*/
}
void loop() {
/*
if(BT.available())
{
int incoming = BT.read();
Serial.print("Recived: ");
Serial.println(incoming);
if(incoming == 49) //1 in ascaii so connected
{
digitalWrite(LED, HIGH);
BT.println("Thank you for connecting to The Turbine"); //send the text via BT Serial
BT.println("You're weather statistics are as followed: ");
TempAndHumidity data = dhtSensor.getTempAndHumidity();
BT.println("Temp: " + String(data.temperature, 2) + "°C");
BT.println("Humidity: " + String(data.humidity, 1) + "%");
BT.println("---");
delay(1000);
BT.println("You're energy systems are as followed"); USING THIS SENSOR https://www.ebay.com/itm/255205990070?chn=ps&norover=1&mkevt=1&mkrid=21562-222008-2056-1&mkcid=2&itemid=255205990070&targetid=325425753764&device=c&mktype=pla&googleloc=20706&poi=&campaignid=21384589900&mkgroupid=164552185618&rlsatarget=pla-325425753764&abcId=&merchantid=646499888&gad_source=1&gclid=Cj0KCQiAyc67BhDSARIsAM95Qzu4M6jZBqa2SQTRUucgs6j0RUa16AzslUU7w5YK7wB4oN6ED80il3saAi7JEALw_wcB
DUE TO NO BLUETOOTH OR VOLTAGE SENSOR MODULE IN THIS
I WILL EXCLUDE IT FROM THE CODE
}
if(incoming == 48)
{
digitalWrite(LED, LOW);
BT.println("Thank you for connecting. Goodbyte"); //Send the text via BT Serial
}
}
delay(20);
*/
TempAndHumidity data = dhtSensor.getTempAndHumidity();
Serial.println("Temp: " + String(data.temperature, 2) + "°C");
Serial.println("Humidity: " + String(data.humidity, 1) + "%");
Serial.println("---");
delay(2000); // Wait for a new reading from the sensor (DHT22 has ~0.5Hz sample rate)
}