PERCOBAAN BLYNK 2DHT LM35 ULTRASONIC BUZZER

 

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>

#include <DHT.h>

#include <SimpleTimer.h>

//ult

#define TRIGGER D0

#define ECHO    D2

//buz

#define buzz D1

 

char auth[] = "v_84jMTkQFRiByLrllSN4TeGWVxTgRn4"; // 4sun86.111186@gmail.com

char ssid[] = "asun86.mi";

char pass[] = "asun1186";

SimpleTimer timer;

 

int lm35 = A0; // lm35 PIN A0

int data = 0;

 

#define DHTPIN1 2          // pin d4

#define DHTTYPE DHT11     // DHT 11

DHT dht1(DHTPIN1, DHTTYPE);

 

#define DHTPIN2 15          // pin d6

#define DHTTYPE DHT11     // DHT 11

DHT dht2(DHTPIN2, DHTTYPE);

 

 

void sendSensor1() // dht 1

{

  float h = dht1.readHumidity();

  float t = dht1.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

 

  if (isnan(h) || isnan(t)) {

    Serial.println("Failed to read from DHT sensor!");

    return;

  }

 

  Blynk.virtualWrite(V5, h); //PORT V5 DI APP BLYNK

  Blynk.virtualWrite(V6, t); //PORT V6 DI APP BLYNK

}

 

void sendSensor2() // dht 2

{

  float h = dht2.readHumidity();

  float t = dht2.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

 

  if (isnan(h) || isnan(t)) {

    Serial.println("Failed to read from DHT sensor!");

    return;

  }

 

  Blynk.virtualWrite(V7, h); //PORT V5 DI APP BLYNK

  Blynk.virtualWrite(V8, t); //PORT V6 DI APP BLYNK

}

 

 

void setup()

{

 

  pinMode(buzz, OUTPUT); // buz

  Serial.begin(9600);

 

  Blynk.begin(auth, ssid, pass);

  dht1.begin();

  timer.setInterval(1000L, sendSensor1);

  timer.setInterval(1000L, getSendData);

 

  timer.setInterval(1000L, sendSensor2);

  timer.setInterval(1000L, getSendData);

 

  //ultrasonic

  pinMode(TRIGGER, OUTPUT); //ult

  pinMode(ECHO, INPUT); //ult

  pinMode(BUILTIN_LED, OUTPUT); //ult

}

 

void loop()

{

  long duration, distance;

  digitalWrite(TRIGGER, LOW); 

Popular posts