3 changed files with 40 additions and 1 deletions
@ -0,0 +1,34 @@ |
|||||
|
#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); |
||||
|
} |
After Width: | Height: | Size: 474 KiB |
Loading…
Reference in new issue