Malý repozitář pro ukládáni programu pro práci s ESP32
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.
 
 
 
 

34 lines
781 B

#include "BluetoothSerial.h"
#include <DHT11.h>
String device_name = "ESP32-DHT-VasePrijmeni";
BluetoothSerial SerialBT;
DHT11 dht11(5);
void setup() {
Serial.begin(115200);
SerialBT.begin(device_name);
//SerialBT.deleteAllBondedDevices();
Serial.printf("Zarizeni \"%s\" je zapnuto. \n Bluetooth se brzy zobrazí",device_name.c_str());
}
void loop() {
int teplota = 0;
int vlhkost = 0;
int result = dht11.readTemperatureHumidity(teplota, vlhkost);
String senzorData;
if (result == 0) {
senzorData = "Teplota: " + String(teplota) + "°C, Vlhkost: " + String(vlhkost) + "%";
} else {
senzorData = "Chyba pri cteni DHT11: " + String(DHT11::getErrorString(result));
}
Serial.println(senzorData);
SerialBT.println(senzorData);
delay(2000);
}