0% found this document useful (0 votes)
110 views6 pages

Source Code Project Monitoring Suhu Dan Kelembaban Dengan Blynk

1) The document describes an IOT project to monitor temperature and humidity using Blynk. It includes the source code and setup instructions. 2) The code defines sensors to measure temperature and humidity and outputs the readings to virtual pins in Blynk. 3) It also controls LEDs and a buzzer based on temperature thresholds to indicate different temperature conditions.

Uploaded by

aris febriansyah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
110 views6 pages

Source Code Project Monitoring Suhu Dan Kelembaban Dengan Blynk

1) The document describes an IOT project to monitor temperature and humidity using Blynk. It includes the source code and setup instructions. 2) The code defines sensors to measure temperature and humidity and outputs the readings to virtual pins in Blynk. 3) It also controls LEDs and a buzzer based on temperature thresholds to indicate different temperature conditions.

Uploaded by

aris febriansyah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Nama : Aris Febriansyah

Nim : 2015344033
Kelas : 6A TO

IOT
Latihan 2: Project Monitoring Suhu dan Kelembaban dengan Blynk

Source Code :
#define BLYNK_TEMPLATE_ID "TMPLpyUoamqd"
#define BLYNK_TEMPLATE_NAME "IOT Projek 2"
#define BLYNK_AUTH_TOKEN "wQPLS8YlkZHgc1l8X_ty64IqMXtL9yIe"

#define BLYNK_PRINT Serial

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

#include <DHT.h>

char auth[] = BLYNK_AUTH_TOKEN;

char ssid[] = "Wokwi-GUEST"; //nama hotspot yang digunakan


char pass[] = ""; //password hotspot yang digunakan

#define DHTPIN 15 // Mention the digital pin where you


connected
#define DHTTYPE DHT22 // DHT 11
#define GREEN_LED 13
#define BLUE_LED 12
#define YELLOW_LED 14
#define RED_LED 27
#define BUZZER 2

DHT dht(DHTPIN, DHTTYPE);


BlynkTimer timer;

void setup(){
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
dht.begin();
pinMode(GREEN_LED, OUTPUT);
pinMode(BLUE_LED, OUTPUT);
pinMode(YELLOW_LED, OUTPUT);
pinMode(RED_LED, OUTPUT);
pinMode(BUZZER, OUTPUT);
timer.setInterval(2500L, sendSensor);
}

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

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;
}
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C");
Blynk.virtualWrite(V1, t);
Blynk.virtualWrite(V2, h);

if (t <= 20 ){
digitalWrite(GREEN_LED, HIGH);
digitalWrite(BLUE_LED, LOW);
digitalWrite(YELLOW_LED, LOW);
digitalWrite(RED_LED, LOW);
noTone(BUZZER);
Blynk.virtualWrite(V3, 255);
Blynk.virtualWrite(V4, 0);
Blynk.virtualWrite(V5, 0);
Blynk.virtualWrite(V6, 0);
}

else if (t >= 20 && t < 30) {


digitalWrite(GREEN_LED, LOW);
digitalWrite(BLUE_LED, HIGH);
digitalWrite(YELLOW_LED, LOW);
digitalWrite(RED_LED, LOW);
tone(BUZZER, 100, 2000);
Blynk.virtualWrite(V3, 0);
Blynk.virtualWrite(V4, 255*(t-20)/5);
Blynk.virtualWrite(V5, 0);
Blynk.virtualWrite(V6, 0);
}
else if (t >= 30 && t < 40) {
digitalWrite(GREEN_LED, LOW);
digitalWrite(BLUE_LED, LOW);
digitalWrite(YELLOW_LED, HIGH);
digitalWrite(RED_LED, LOW);
tone(BUZZER, 500, 1000);
Blynk.virtualWrite(V3, 0);
Blynk.virtualWrite(V4, 0);
Blynk.virtualWrite(V5, 255*(t-30)/5);
Blynk.virtualWrite(V6, 0);
}
else {
digitalWrite(GREEN_LED, LOW);
digitalWrite(BLUE_LED, LOW);
digitalWrite(YELLOW_LED, LOW);
digitalWrite(RED_LED, HIGH);
tone(BUZZER, 1000, 100);
Blynk.virtualWrite(V3, 0);
Blynk.virtualWrite(V4, 0);
Blynk.virtualWrite(V5, 0);
Blynk.virtualWrite(V6, 255*(t-30)/5);
}

if(t > 30){


Blynk.logEvent("temp_alert","Temp above 30 degrees");
}
}

Hasil Dari Web wokwi.com


● Keadaan Dingin :

● Keadaan Normal :

● Keadaan Hangat :

● Keadaan Panas :

Hasil Blynk By Dekstop


● Keadaan Dingin

● Keadaan Normal :

● Keadaan Hangat :

● Keadaan Panas :

Hasil Dari Blynk By Phone :

> Kadaan Dingin : > Keadaan Normal :


> Keadaan Hangat : > Keadaan Panas :

You might also like