Translate

Monitor Suhu DHT11 Interface Blynk dan 7Segment WEMOS D1 ARDUINO

Monitor Suhu DHT11 Interface Blynk dan 7Segment WEMOS D1 ARDUINO


       Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang berbasis IOT dengan menggunakan interface Blynk dan 7segment untuk memonitor suhu secara realtime dan juga alat ini bisa dipantau secara online melalui aplikasi Blynk. alat ini menggunakan sensor DHT11 yang mana dapat mendeteksi 2 parameter sekaligus yaitu suhu dan kelembaban. untuk lebih jelasnya berikut adalah program dan daftar komponennya.




a. Wemos D1




b. Sensor Suhu dan Kelembaban DHT11





c. Interface 7Segment






d. Program Arduino IDE

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <DHT.h>

byte zero  = B00000011;
byte one   = B10011111;
byte two   = B00100101;
byte three = B00001101;
byte four  = B10011001;
byte five  = B01001001;
byte six   = B01000001;
byte seven = B00011111;
byte eight = B00000001;
byte nine  = B00001001;


int latchPin = D4;  //Pin connected to STR(pin 1) of HEF4094
int clockPin = D5; //Pin connected to CP(pin 3) of HEF4094
int dataPin = D6;  //Pin connected to D(pin 2) of HEF4094
int oe = D7;  //Pin connected to OE(pin 2) of HEF4094

int temp;
int x = 5;
int y;

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "jhgjhGJHGJHGJhgjhgjhgggdgfdfFGDG";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Hotspotku";
char pass[] = "123456789";

#define DHTPIN 0          // D3 dan led di D4

// Uncomment whatever type you're using!
#define DHTTYPE DHT11     // DHT 11
//#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21   // DHT 21, AM2301

DHT dht(DHTPIN, DHTTYPE);
SimpleTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
{
 
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
 
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, t);

  temp = t;
  int ribuan = temp / 1000;
  temp = temp % 1000;
  int ratusan = temp / 100;
  temp = temp % 100;
  int puluhan = temp / 10;
  int satuan = temp % 10;

 switch(ribuan){
   case 0:
   ribuan = zero;
   break;
   case 1:
   ribuan = one;
   break;
   case 2:
   ribuan = two;
   break;
   case 3:
   ribuan = three;
   break;
   case 4:
   ribuan = four;
   break;
   case 5:
   ribuan = five;
   break;
   case 6:
   ribuan = six;
   break;
   case 7:
   ribuan = seven;
   break;
   case 8:
   ribuan = eight;
   break;
   case 9:
   ribuan = nine;
   break; 
 }

 switch(ratusan){
   case 0:
   ratusan = zero;
   break;
   case 1:
   ratusan = one;
   break;
   case 2:
   ratusan = two;
   break;
   case 3:
   ratusan = three;
   break;
   case 4:
   ratusan = four;
   break;
   case 5:
   ratusan = five;
   break;
   case 6:
   ratusan = six;
   break;
   case 7:
   ratusan = seven;
   break;
   case 8:
   ratusan = eight;
   break;
   case 9:
   ratusan = nine;
   break; 
 }
 
 switch(puluhan){
   case 0:
   puluhan = zero;
   break;
   case 1:
   puluhan = one;
   break;
   case 2:
   puluhan = two;
   break;
   case 3:
   puluhan = three;
   break;
   case 4:
   puluhan = four;
   break;
   case 5:
   puluhan = five;
   break;
   case 6:
   puluhan = six;
   break;
   case 7:
   puluhan = seven;
   break;
   case 8:
   puluhan = eight;
   break;
   case 9:
   puluhan = nine;
   break; 
 }

 switch(satuan){
   case 0:
   satuan = zero;
   break;
   case 1:
   satuan = one;
   break;
   case 2:
   satuan = two;
   break;
   case 3:
   satuan = three;
   break;
   case 4:
   satuan = four;
   break;
   case 5:
   satuan = five;
   break;
   case 6:
   satuan = six;
   break;
   case 7:
   satuan = seven;
   break;
   case 8:
   satuan = eight;
   break;
   case 9:
   satuan = nine;
   break;
 }

 digitalWrite(latchPin, HIGH); //Pull latch HIGH to send data
 shiftOut(dataPin, clockPin, LSBFIRST, satuan);
 shiftOut(dataPin, clockPin, LSBFIRST, puluhan);
 shiftOut(dataPin, clockPin, LSBFIRST, ratusan);
 digitalWrite(latchPin, LOW); //Pull latch HIGH to send data
 delay(1000);

}


void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);

  dht.begin();

 pinMode(latchPin, OUTPUT);
 pinMode(clockPin, OUTPUT);
 pinMode(dataPin, OUTPUT);
 pinMode(oe, OUTPUT);
 //digitalWrite(oe,LOW);
         
 digitalWrite(oe,HIGH);

  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);
}

void loop()
{
  Blynk.run();
  timer.run();
}




e. VIDEO HASILNYA








No comments:

Post a Comment