Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "DHT.h"
- #define DHTPIN 32
- #define DHTTYPE DHT22
- DHT dht(DHTPIN, DHTTYPE);
- unsigned long cur_time, old_time;
- int ledState = LOW;
- const byte pin_set = 18;
- const byte pin_pln = 33;
- const byte pin_key = 12;
- #define BLYNK_PRINT Serial
- #include <WiFi.h>
- #include <WiFiClient.h>
- #include <BlynkSimpleEsp32.h>
- char auth[] = "ll9Ckm9Q3hQFzqA3sVlNFtuZFZ91qXKw";
- char ssid[] = "your_wifi_ssid";
- char pass[] = "your_pass_wifi";
- void setup() {
- pinMode(16, OUTPUT);
- pinMode(17, OUTPUT);
- pinMode(pin_key, OUTPUT);
- digitalWrite(pin_key, HIGH);
- pinMode(pin_set, INPUT_PULLUP);
- pinMode(pin_pln, INPUT_PULLUP);
- Serial.begin(115200);
- Serial.println();
- dht.begin();
- Blynk.begin(auth, ssid, pass);
- }
- void loop() {
- Blynk.run();
- cur_time = millis();
- if (cur_time - old_time >= 1000) {
- if (ledState == LOW) {
- ledState = HIGH;
- } else {
- ledState = LOW;
- }
- digitalWrite(16,ledState);
- digitalWrite(17,!ledState);
- float h = dht.readHumidity();
- float t = dht.readTemperature();
- Blynk.virtualWrite(V0, h);
- Blynk.virtualWrite(V1, t);
- Serial.print("suhu: ");
- Serial.println(t);
- Serial.print("humiity: ");
- Serial.println(h);
- Serial.print("set: ");
- Serial.println(digitalRead(pin_set));
- Serial.print("pln status: ");
- Serial.println(digitalRead(pin_pln));
- Blynk.virtualWrite(V3, digitalRead(pin_pln));
- old_time = millis();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement