September 24, 2022
Home »
diklatbimtekws
» PELATIHAN IoT BERSAMA SEAMOLEC (ESP 32 SUHU,KELEMBAPAN)
PELATIHAN IoT BERSAMA SEAMOLEC (ESP 32 SUHU,KELEMBAPAN)
#define THINGER_SERIAL_DEBUG
#include
#define username "dinaalfaruq"
#define device_id "IoT1"
#define credential "12345678"
#include "DHTesp.h"
const int DHT_PIN = 15;
DHTesp dhtSensor;
#define SSID "Wokwi-GUEST"
#define password ""
#define Lampu 21
#define trig 13
#define echo 12
ThingerESP32 thing(username, device_id,credential);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
pinMode(Lampu, OUTPUT);
thing.add_wifi(SSID,password);
thing["Lampu"]<>[](pson& out)
{
digitalWrite(trig, HIGH);
delayMicroseconds(1000);
digitalWrite(trig, LOW);
Serial.begin(115200);
dhtSensor.setup(DHT_PIN, DHTesp::DHT22);
long waktu = pulseIn(echo,HIGH);
double jarak = waktu/58;
out = jarak;
};
}
void loop() {
// put your main code here, to run repeatedly:
thing.handle();
TempAndHumidity data = dhtSensor.getTempAndHumidity();
Serial.println("Temp: " + String(data.temperature, 2) + "°C");
Serial.println("Humidity: " + String(data.humidity, 1) + "%");
Serial.println("---");
delay(1000);
}
my name is Dina I'm a teacher at a private high school in Bondowoso Indonesia loves education and likes education development
0 comments:
Post a Comment