Monitor Tekanan Udara via BLYNK (IOT)
Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat memonitor tekanan udara dalam satuan MPa. jika ingin merubah ke satuan lain bisa diubah sesuai rumusnya. untuk lebih jelasnya berikut adalah komponen dan kodingnya.
a. Komponen
b. Program Arduino IDE
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
float pressure_pascal;
float pressure_bar;
int dataadc;
int x;
float v;
float kpa;
float mpa;
void setup() {
Serial.begin(9600);
lcd.begin();
lcd.clear();
lcd.noCursor();
}
void loop() {
x = analogRead(A0);
v = x*(5.0/1023.0);
pressure_pascal = (3.0*(v-0.47))*1000000.0;
pressure_bar = pressure_pascal/10e5;
mpa = pressure_bar / 10.0;
lcd.setCursor(0, 0);
lcd.print("MPA= ");
lcd.print(mpa);
lcd.print(" ");
Serial.println(mpa * 1000);
delay(200);
}
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
float pressure_pascal;
float pressure_bar;
int dataadc;
int x;
float v;
float kpa;
float mpa;
void setup() {
Serial.begin(9600);
lcd.begin();
lcd.clear();
lcd.noCursor();
}
void loop() {
x = analogRead(A0);
v = x*(5.0/1023.0);
pressure_pascal = (3.0*(v-0.47))*1000000.0;
pressure_bar = pressure_pascal/10e5;
mpa = pressure_bar / 10.0;
lcd.setCursor(0, 0);
lcd.print("MPA= ");
lcd.print(mpa);
lcd.print(" ");
Serial.println(mpa * 1000);
delay(200);
}
c. Program ESP8266
#define BLYNK_TEMPLATE_ID "TMPL6fx_xxxxx"
#define BLYNK_TEMPLATE_NAME "Monitor Pressure"
#define BLYNK_AUTH_TOKEN "Vk4temfJ0R3jIhakzOxuTeCC2aIxxxxx"
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
int temp;
int x = 5;
int y;
int value1;
int value2;
int tekanan = 0;
float fix;
float datain1;
String dataIn;
String dt[10];
int i;
boolean parsing=false;
int pinValue;
int pinValue2;
int pinValue3;
BlynkTimer timer;
char ssid[] = "hotspothpku";
char pass[] = "123456789";
void sendSensor()
{
Blynk.virtualWrite(V0, fix);
delay(1000);
}
void setup()
{
dataIn="";
// Debug console
Serial.begin(9600);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
timer.setInterval(1000L, sendSensor);
}
void loop()
{
tekanan = Serial.parseInt();;
fix = tekanan / 1000.0;
Blynk.run();
timer.run();
}
#define BLYNK_TEMPLATE_NAME "Monitor Pressure"
#define BLYNK_AUTH_TOKEN "Vk4temfJ0R3jIhakzOxuTeCC2aIxxxxx"
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
int temp;
int x = 5;
int y;
int value1;
int value2;
int tekanan = 0;
float fix;
float datain1;
String dataIn;
String dt[10];
int i;
boolean parsing=false;
int pinValue;
int pinValue2;
int pinValue3;
BlynkTimer timer;
char ssid[] = "hotspothpku";
char pass[] = "123456789";
void sendSensor()
{
Blynk.virtualWrite(V0, fix);
delay(1000);
}
void setup()
{
dataIn="";
// Debug console
Serial.begin(9600);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
timer.setInterval(1000L, sendSensor);
}
void loop()
{
tekanan = Serial.parseInt();;
fix = tekanan / 1000.0;
Blynk.run();
timer.run();
}
d VIDEO HASILNYA
No comments:
Post a Comment