You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
816 B
31 lines
816 B
#include <Arduino.h>
|
|
#include <DHT.h>
|
|
#include <BluetoothSerial.h>
|
|
|
|
String device_name = "ESP32-Skrabanek";
|
|
DHT dht;
|
|
BluetoothSerial SerialBT;
|
|
|
|
void setup() {
|
|
// put your setup code here, to run once:
|
|
Serial.begin(115200);
|
|
SerialBT.begin(device_name);
|
|
dht.setup(36); //zaleží na zapojení
|
|
Serial.printf("ESP32 DTH11 Zarizeni \"%s\"", device_name.c_str());
|
|
}
|
|
|
|
void loop() {
|
|
delay(dht.getMinimumSamplingPeriod());
|
|
float teplota = dht.getTemperature();
|
|
float vlhkost = dht.getHumidity();
|
|
String senzorData;
|
|
if (dht.getStatus() == DHT::ERROR_NONE){
|
|
senzorData = "Teplota:" + String(teplota,1)+"°C, Vlhkost"
|
|
+ String(vlhkost,1) + "%";
|
|
} else {
|
|
senzorData = "Chyba:" + String(dht.getStatusString());
|
|
}
|
|
Serial.println(senzorData);
|
|
SerialBT.println(senzorData);
|
|
delay(1000);
|
|
}
|
|
|