Translate

Monitor 6 Telur Bagus atau Jelek IOT BLYNK 2.0 Output Suara

Monitor 6 Telur Bagus atau Jelek IOT BLYNK 2.0 Output Suara


           Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat memonitor 6 buahtelur bagus atau jelek dengan fitur yaitu IOT Blynk sehingga bisa dimonitor secara jaak jauh dan juga terdapat fitur suara sehingga output dari 6 buah telut yang dicek akan di outputkan menggunakan suara. untuk lebih jelasnya berikut adalah kodingnya.



a. Komponen




b. Program Arduino IDE

#include <Wire.h>
#include <DFPlayer_Mini_Mp3.h>
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

SoftwareSerial mySerial(2, 3); // RX, TX

int x;
int telur1;
int telur2;
int telur3;
int telur4;
int telur5;
int telur6;
int tombol = 4;
int tombolx;
int batastelur = 960;

void setup() {

  Serial.begin(9600);
  mySerial.begin (9600);
  mp3_set_serial (mySerial);  //set softwareSerial for DFPlayer-mini mp3 module
  delay(1);  //wait 1ms for mp3 module to set volume
  mp3_set_volume (30);  //volume 0-30
  
  lcd.begin();
  lcd.clear();
  lcd.noCursor();
  pinMode(tombol,INPUT_PULLUP);
}

void loop() {
  
  //jika telur jelek adc 1023
  //jika telur bagus adc kurang dari 1023
  
  telur1 = analogRead(A0);
  telur2 = analogRead(A1);
  telur3 = analogRead(A2);
  telur4 = analogRead(A3);
  telur5 = analogRead(A6);
  telur6 = analogRead(A7);
 
   lcd.setCursor(0,0);
   lcd.print(telur1);
   lcd.print(" ");
   lcd.print(telur2);
   lcd.print(" ");
   lcd.print(telur3);
   lcd.print(" ");

   lcd.setCursor(0,1);
   lcd.print(telur4);
   lcd.print(" ");
   lcd.print(telur5);
   lcd.print(" ");
   lcd.print(telur6);
   lcd.print("    ");

tombolx = digitalRead(tombol);

if(tombolx == 0){
  
if((telur2 < batastelur)&&(telur3 < batastelur)&&(telur4 < batastelur)&&(telur5 < batastelur)&&(telur6 < batastelur)){
mp3_play(7);  //play music file 0007.mp3
delay(10000);
mp3_stop();
}

if((telur1 > batastelur)||(telur2 > batastelur)||(telur3 > batastelur)||(telur4 > batastelur)||(telur5 > batastelur)||(telur6 > batastelur)){
mp3_play(8);  
delay(5000);

if(telur1 > batastelur){
mp3_play(1);
delay(5000);
}

if(telur2 > batastelur){
mp3_play(2);
delay(5000);
}

if(telur3 > batastelur){
mp3_play(3);
delay(5000);
}

if(telur4 > batastelur){
mp3_play(4);
delay(5000);
}

if(telur5 > batastelur){
mp3_play(5);
delay(5000);
}

if(telur6 > batastelur){
mp3_play(6);
delay(5000);
}

}

}

Serial.print("*");
Serial.print(telur1);
Serial.print(",");
Serial.print(telur2);
Serial.print(",");
Serial.print(telur3);
Serial.print(",");
Serial.print(telur4);
Serial.print(",");
Serial.print(telur5);
Serial.print(",");
Serial.print(telur6);
Serial.println("#");
                                                                         
delay(1000);
}



c. Program Nodemcu ESP8266

#define BLYNK_TEMPLATE_ID "TMPL6CsQfbxxx"
#define BLYNK_TEMPLATE_NAME "monitor flow presure"
#define BLYNK_AUTH_TOKEN "aSUiRpTncCpKkoXfLqIM4Gq2ISlxxxxx"
#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 value3;
int value4;
int value5;
int value6;
int berat;

int telur1;
int telur2;
int telur3;
int telur4;
int telur5;
int telur6;

int datain1;
int datain2;
int datain3;
int datain4;
int datain5;
int datain6;
int datain7;

String dataIn;
String dt[10];
int i;
boolean parsing = false;

BlynkTimer timer;
char ssid[] = "hotspothpku";
char pass[] = "123456789";

void sendSensor()
{
 Blynk.virtualWrite(V0, telur1);
 Blynk.virtualWrite(V1, telur2);
 Blynk.virtualWrite(V2, telur3);
 Blynk.virtualWrite(V3, telur4);
 Blynk.virtualWrite(V4, telur5);
 Blynk.virtualWrite(V5, telur6);
 delay(1000);
}


void setup()
{
 
  dataIn="";
  Serial.begin(9600);
  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
  timer.setInterval(1000L, sendSensor);

}

void loop()
{

while(Serial.available()>0) {
//   dataIn="";
    char inChar = (char)Serial.read();
    dataIn += inChar;
    if (inChar == '\n') {
    parsing = true;
  }
}

if(parsing){
   parsingData();
   Blynk.run();
   timer.run();
}
}

void parsingData(){
int j=0;

//kirim data yang telah diterima sebelumnya
//Serial.print("data masuk : ");
//Serial.print(dataIn);
//Serial.print("\n");

//inisialisasi variabel, (reset isi variabel)
dt[j]="";
//proses parsing data
for(i=1;i<dataIn.length();i++){
//pengecekan tiap karakter dengan karakter (#) dan (,)
if ((dataIn[i] == '#') || (dataIn[i] == ','))
{
//increment variabel j, digunakan untuk merubah index array penampung
j++;
dt[j]="";       //inisialisasi variabel array dt[j]
}
else
{
//proses tampung data saat pengecekan karakter selesai.
dt[j] = dt[j] + dataIn[i];
}
}

 datain1 = dt[0].toInt();
 datain2 = dt[1].toInt();
 datain3 = dt[2].toInt();
 datain4 = dt[3].toInt();
 datain5 = dt[3].toInt();
 datain6 = dt[3].toInt();

 telur1 = datain1 / 1;
 telur2 = datain2 / 1;
 telur3 = datain3 / 1;
 telur4 = datain4 / 1;
 telur5 = datain5 / 1;
 telur6 = datain6 / 1;
 
}



d. VIDEO HASILNYA




Monitor Gula Darah Non Invasive Nofif Telegram

Monitor Gula Darah Non Invasive Nofif Telegram


          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana membuat sebuah alat yang menggunakan fitur notifikasi telegram untuk monitor gula darah secara non invasive. jadi alat ini konsepnya setelah melakukan pengukuran lalu akan mengirimkan notifikasi berupa data yang didapat ke telegram berupa chat. untuk lebih jelasnya berikut adalah koding dan skemanya.



a. Skema Alat



b. Program Arduino IDE

#include <Wire.h>
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <UniversalTelegramBot.h>
#include <ArduinoJson.h>

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

char ssid[ ] = "hotspothpku";
char pass[ ] = "123456789";//password wifi

#define BOTtoken "6479039xxx:AAEewLE_SoxTckygc_A1EgP8lXxxxxxxxxx" //token bot telegram
#define idChat "1234567899" //idbot

WiFiClientSecure client;
UniversalTelegramBot bot(BOTtoken, client);

int bt = D4;
int btx = 0;
int adcsensor;
float fix;
int datafix;
int cacah = 0;
float kalibrasi;
int tanda = 0;

void setup() {
 
  Serial.begin(9600);
  lcd.begin();
  lcd.clear();
  lcd.noCursor();
  
  pinMode(bt,INPUT);
  digitalWrite(bt,HIGH);

  client.setInsecure();
  Serial.print("Connecting Wifi: ");
  Serial.println(ssid);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, pass);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
}

void loop(){
 delay(100);
   
 btx = digitalRead(bt);

 if(btx == 0){
   delay(200); 
   tanda = 1; 
   cacah = 0;
   lcd.clear();
   delay(1000);
 }

if(tanda == 0){ 
 lcd.setCursor(0,0);
 lcd.print("TEKAN MULAI");
 lcd.setCursor(0,1);
 lcd.print("mg/dl= ");
 lcd.print(fix);
 lcd.print("      "); 
}

if(tanda == 1){  
 datafix = 0;
 fix = 0;

adcsensor = analogRead(A0);

 lcd.setCursor(0,0);
 lcd.print("ADC= ");
 lcd.print(adcsensor);
 lcd.print("      ");

 cacah++;

 datafix = adcsensor + datafix;

 delay(100);

 if(cacah >= 20){
  fix = datafix / 20.0;
  //kalibrasi = (fix - 1022.1) / 0.0967;
  cacah = 0;
  lcd.clear(); 

    bot.sendChatAction(idChat, "Sedang mengetik...");
    Serial.print("Mg/dl : ");
    Serial.println(fix);
    delay(2000);
    
    String suhu = " Gula Darah : ";
    suhu += float(fix);
    suhu += " mg/dl\n";
    suhu += "Informasi Kesehatan Penyakit Tidak Menular Diabetes Militus, bisa akses di:https://drive.google.com/drive/folders/xxxxxxxxxxxxxxxx \n";
    bot.sendMessage(idChat, suhu, "");
    Serial.print("Mengirim data sensor ke telegram");
   
  tanda = 0;
  }

}

}


c. Hasil Notif Telegram




d. VIDEO HASILNYA




e. Tutorial Kalibrasi







Monitor Kualitas Udara ( AIR QUALITY ) MICS-6814 dan DEBU (DUST) Winsen ZH03 ARDUINO IOT BLYNK 2.0

Monitor Kualitas Udara ( AIR QUALITY ) MICS-6814 dan DEBU (DUST) Winsen ZH03 ARDUINO IOT BLYNK 2.0


             Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat memonitor kualitas udara meliputi CO, NH3, NO2, dan Debu. alat ini menggunakan fitur IOT Blynk sehingga dapat memonitor udara dengan jarak jauh baik itu melalui handphone atau website. untuk lebih jelasnya berikut adalah koding skemanya.


a. Skema Alat


b. Program Arduino IDE

#include <Arduino.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <SD.h>
#include <WinsenZH03.h>
WinsenZH03 sensorZH;
#define DS3231_I2C_ADDRESS 0x68
LiquidCrystal_I2C lcd(0x27, 20, 4);
//mics-6814

const float max_volts = 5.0;
const float max_analog_steps = 1023.0;
int co, nh3, no2;  
int cox, nh3x, no2x;
int debu;
int cacah;
File myFile;

byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;

// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
  return( (val/10*16) + (val%10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
  return( (val/16*10) + (val%16) );
}

void setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte
dayOfMonth, byte month, byte year)
{
  // sets time and date data to DS3231
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set next input to start at the seconds register
  Wire.write(decToBcd(second)); // set seconds
  Wire.write(decToBcd(minute)); // set minutes
  Wire.write(decToBcd(hour)); // set hours
  Wire.write(decToBcd(dayOfWeek)); // set day of week (1=Sunday, 7=Saturday)
  Wire.write(decToBcd(dayOfMonth)); // set date (1 to 31)
  Wire.write(decToBcd(month)); // set month
  Wire.write(decToBcd(year)); // set year (0 to 99)
  Wire.endTransmission();
}

void readDS3231time(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set DS3231 register pointer to 00h
  Wire.endTransmission();
  Wire.requestFrom(DS3231_I2C_ADDRESS, 7);
  // request seven bytes of data from DS3231 starting from register 00h
  *second = bcdToDec(Wire.read() & 0x7f);
  *minute = bcdToDec(Wire.read());
  *hour = bcdToDec(Wire.read() & 0x3f);
  *dayOfWeek = bcdToDec(Wire.read());
  *dayOfMonth = bcdToDec(Wire.read());
  *month = bcdToDec(Wire.read());
  *year = bcdToDec(Wire.read());
}

void displayTime()
{
 
  // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,
  &year);
 /*
  lcd.setCursor(0,0);
  // send it to the serial monitor
  lcd.print(hour, DEC);
  // convert the byte variable to a decimal number when displayed
  lcd.print(":");
  if (minute<10)
  {
    lcd.print("0");
  }
  lcd.print(minute, DEC);
  lcd.print(":");
  if (second<10)
  {
    lcd.print("0");
  }
  lcd.print(second, DEC);
 */   
}

void setup() {
  
  Serial.begin(9600);  //UART to pc
  Serial1.begin(9600); //UART to sensor
  sensorZH.begin(&Serial1);//configure the serial that the sensor will use
  sensorZH.setAs(QA);//configure the sensor QA mode 
  
  delay(1000);
  //Serial.println("Setup initializing");
  Wire.begin();
  Serial.begin(9600);
  // DS3231 seconds, minutes, hours, day, date, month, year
  // setDS3231time(0,1,18,6,19,4,24);
  
  lcd.begin();
  lcd.clear();
  lcd.noCursor();
}

void loop() {
 displayTime();
    
  co = analogRead(A0);
  nh3 = analogRead(A1);
  no2 = analogRead(A2);

  cox = map (analogRead(A0), 0, 1023, 1, 1000); // Calcolo Monossido di Carbonio
  nh3x = map (analogRead(A1), 0, 1023, 1, 500); // Calcolo Ammoniaca
  no2x = (map (analogRead(A2), 0, 1023, 5, 1000)) / 100.0 ; // Calcolo Dios

  sensorZH.readOnce();//Every time a sample is taken, this function should be set, only in QA.
  debu = sensorZH.readPM2_5();

  /*
    Serial.print("PM1.0: ");
    Serial.print(sensorZH.readPM1_0());//
    Serial.println("  ug/m3");
    Serial.print("PM2.5: ");
    Serial.print(sensorZH.readPM2_5());
    Serial.println("  ug/m3");
    Serial.print("PM10: ");
    Serial.print(sensorZH.readPM10());
    Serial.println("  ug/m3");
    delay(1000);
  */
    
  lcd.setCursor(0,0);
  lcd.print("CO: ");
  lcd.print(cox);
  lcd.print(" ppm  ");
  lcd.setCursor(0,1);
  lcd.print("NH3: ");
  lcd.print(nh3x);
  lcd.print(" ppm  ");
  lcd.setCursor(0,2);
  lcd.print("NO2: ");
  lcd.print(no2x);
  lcd.print(" ppm  ");
  lcd.setCursor(0,3);
  lcd.print("PM2.5: ");
  lcd.print(debu);
  lcd.print(" ug/m3 ");

Serial.print("*");
Serial.print(cox);
Serial.print(",");
Serial.print(nh3x);
Serial.print(",");
Serial.print(no2x);
Serial.print(",");
Serial.print(debu);
Serial.println("#");  

delay(1000);

cacah++;
 
if(cacah >= 3){
  simpan();
  cacah = 0;
}
  
}

void simpan(){

  Serial.print("Initializing SD card...");
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin 
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output 
  // or the SD library functions will not work. 
  pinMode(53, OUTPUT); 
  
  if (!SD.begin(53)) {
    Serial.println("initialization failed!");
    return;
  }
  
  Serial.println("initialization done.");

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  myFile = SD.open("test.txt", FILE_WRITE);

  // if the file opened okay, write to it:
  if (myFile) {

    myFile.print("Tanggal:");
    myFile.print(dayOfMonth);
    myFile.print("/");
    myFile.print(month);
    myFile.print("/");
    myFile.println(year);
   
    myFile.print("Jam:");
    myFile.print(hour);
    myFile.print(":");
    myFile.print(minute);
    myFile.print(":");   
    myFile.println(second);
      
    myFile.print("CO: ");
    myFile.println(cox);
    myFile.print("NH3: ");
    myFile.println(nh3x);
    myFile.print("NO2: ");
    myFile.println(no2x);
    myFile.print("PM2.5: ");
    myFile.println(debu);
   
    // close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }

  // re-open the file for reading:
  myFile = SD.open("test.txt");
  if (myFile) {
    Serial.println("test.txt:");

    // read from the file until there's nothing else in it:
    while (myFile.available()) {
      Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }

}



c. Program NODEMCU ESP8266

#define BLYNK_TEMPLATE_ID "TMPL6wOC--xxx"
#define BLYNK_TEMPLATE_NAME "monitor daya"
#define BLYNK_AUTH_TOKEN "VOK0cWiFN5ycHj3SV_snEDXTfTfeixxx"

#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 co = 0;
int nh3 = 0;
int no2 = 0;
int ppm = 0;

float datain1;
float datain2;
float datain3;
float datain4;
float datain5;
float datain6;

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, co);
 Blynk.virtualWrite(V1, nh3);
 Blynk.virtualWrite(V2, no2);
 Blynk.virtualWrite(V3, ppm);
 delay(1000);
}


void setup()
{
  dataIn=""; 
  // Debug console
 Serial.begin(9600);
 Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
 timer.setInterval(1000L, sendSensor);
 pinMode(D6,OUTPUT);
 pinMode(D7,OUTPUT);
 pinMode(D8,OUTPUT);
}

void loop()
{

while(Serial.available()>0) {
//   dataIn="";
    char inChar = (char)Serial.read();
    dataIn += inChar;
    if (inChar == '\n') {
    parsing = true;
  }
}

if(parsing){
  parsingData();
    
  Blynk.run();
  timer.run();
}

}

void parsingData(){
int j=0;

//kirim data yang telah diterima sebelumnya
//Serial.print("data masuk : ");
//Serial.print(dataIn);
//Serial.print("\n");

//inisialisasi variabel, (reset isi variabel)
dt[j]="";
//proses parsing data
for(i=1;i<dataIn.length();i++){
//pengecekan tiap karakter dengan karakter (#) dan (,)
if ((dataIn[i] == '#') || (dataIn[i] == ','))
{
//increment variabel j, digunakan untuk merubah index array penampung
j++;
dt[j]="";       //inisialisasi variabel array dt[j]
}
else
{
//proses tampung data saat pengecekan karakter selesai.
dt[j] = dt[j] + dataIn[i];
}
}

datain1 = dt[0].toInt();
datain2 = dt[1].toInt();
datain3 = dt[2].toInt();
datain4 = dt[3].toInt();

//kirim data hasil parsing
Serial.print("data 1 : ");
Serial.print(datain1);
Serial.print("\n");
Serial.print("data 2 : ");
Serial.print(datain2);
Serial.print("\n");
Serial.print("data 3 : ");
Serial.print(datain3);
Serial.print("\n");
Serial.print("data 4 : ");
Serial.print(datain4);
Serial.print("\n");

//Serial.print("data 3 : ");
//Serial.print(dt[2].toInt());
//Serial.print("\n\n");

 co = datain1 / 1;
 nh3 = datain2 / 1;
 no2 = datain3 / 1;
 ppm = datain4 / 1;

}



d. VIDEO HASILNYA



Monitor Tekanan Udara (Pressure) IOT Blynk 2.0 ARduino

Monitor Tekanan Udara (Pressure) IOT Blynk 2.0 Arduino


          Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat memonitor tekana udara dengan menggunakan IOT Blynk dan sensor tekanan udara. alat ini menggunakan Arduino Wifi sehingga butuh pengetahuan tentang SWITCH untuk upload kodingnya. untuk lebih jelasnya berikut adalah koding dan skmanya.

 
a. Skema


sumber: https://blog.devgenius.io/programming-arduino-uno-clone-with-built-in-wifi-module-uno-r3-wifi-atmega328p-esp8266-9494d9a90cfa



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);  
}



c. Program Nodemcu ESP8266

#define BLYNK_TEMPLATE_ID "TMPL6L8avXxxx"
#define BLYNK_TEMPLATE_NAME "Tekanan Udara"
#define BLYNK_AUTH_TOKEN "sFgOefS8bicoSISZMh6L3swAykGdxxxx"
#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[] = "hotspotwifi";
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






Monitor Kecepatan Angin ( Wind Speed ) Anemometer IOT BLYNK

Monitor Kecepatan Angin ( Wind Speed ) Anemometer IOT BLYNK


            Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat memonitor kecepatan angin atau anemometer dengan menggunakan IOT Blynk 2.0 sehingga bisa dimonitor secara jarak jauh menggunakan handphone atau website. untuk lebih jelasnya berikut adalah koding dan skemanya.



a. Skema




b. Program Arduino IDE

#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPL6CsQfbxxx"
#define BLYNK_TEMPLATE_NAME "monitor flow presure"
#define BLYNK_AUTH_TOKEN "aSUiRpTncCpKkoXfLqIM4Gq2ISlYPxxx"

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
WidgetLED led1(V1);
WidgetLED led2(V2);
WidgetLED led3(V3);
// anemometer parameters
volatile byte rpmcount; // count signals
volatile unsigned long last_micros;
unsigned long timeold;
unsigned long timemeasure = 10.00; // seconds
int timetoSleep = 1;               // minutes
unsigned long sleepTime = 15;      // minutes
unsigned long timeNow;
int countThing = 0;
int GPIO_pulse = 14; // Arduino = D5
float rpm, rps;     // frequencies
float velocity_kmh; // km/h
float velocity_ms;  //m/s
float calibration_value = 5.0; //This value is obtained from comparing with the manufacturer's anemometer sensor
volatile boolean flag = false;
float kec;

void ICACHE_RAM_ATTR rpm_anemometer()
{
  flag = true;
}

BlynkTimer timer;

char ssid[] = "hotspothpku";
char pass[] = "123456789";

void kirimdata()
{
  Blynk.virtualWrite(V0,kec);
}

void setup()
{
  pinMode(GPIO_pulse, INPUT_PULLUP);
  digitalWrite(GPIO_pulse, LOW);

  Serial.begin(9600);
  lcd.begin();
  lcd.backlight();
  lcd.clear();

  detachInterrupt(digitalPinToInterrupt(GPIO_pulse));                         // force to initiate Interrupt on zero
  attachInterrupt(digitalPinToInterrupt(GPIO_pulse), rpm_anemometer, RISING); //Initialize the intterrupt pin
  rpmcount = 0;
  rpm = 0;
  timeold = 0;
  timeNow = 0;

  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
  timer.setInterval(1000L, kirimdata);


void loop()
{
  if (flag == true) // don't really need the == true but makes intent clear for new users
  {
    if (long(micros() - last_micros) >= 1000)
    { // time to debounce measures
      rpmcount++;
      last_micros = micros();
    }
    flag = false; // reset flag
  }
  //Measure RPM
  if ((millis() - timeold) >= timemeasure * 1000)
  {
    countThing++;
    detachInterrupt(digitalPinToInterrupt(GPIO_pulse)); // Disable interrupt when calculating
    rps = float(rpmcount) / float(timemeasure); // rotations per second
   //velocity_ms = rps * calibration_value; // m/s
    velocity_ms = rps; // m/s
    velocity_kmh = velocity_ms * 3.6; // km/h
    lcd.setCursor(0, 0);
    lcd.print("v= ");
    lcd.print(kec);
    lcd.print(" knot ");
    kec = velocity_ms * 0.514;
    timeold = millis();
    rpmcount = 0;
    attachInterrupt(digitalPinToInterrupt(GPIO_pulse), rpm_anemometer, RISING); // enable interrupt
  }

if((velocity_ms >= 0)&&(velocity_ms < 1)){
  led1.on();
  led2.off();
  led3.off();
  lcd.setCursor(0, 1);
  lcd.print("NORMAL      ");
}

if((velocity_ms >= 1)&&(velocity_ms < 2)){
  led1.off();
  led2.on();
  led3.off();
  lcd.setCursor(0, 1);
  lcd.print("MODERATE    ");
}

if((velocity_ms >= 2)&&(velocity_ms < 3)){
  led1.off();
  led2.off();
  led3.on();
  lcd.setCursor(0, 1);
  lcd.print("UNSAFE    ");
  Blynk.logEvent("alarmx");
}

Blynk.run();
timer.run(); // Initiates BlynkTimer



c. Interface Blynk 2.0




d. VIDEO HASILNYA



Monitor Berat dan Tinggi serta Lebar Badan Arduino

Monitor Berat dan Tinggi serta Lebar Badan Arduino 


           Pada kesempatan kali ini saya akan menjelaskan mengenai sebuah alat yang dapat mengukur berat badan dan tinggi badan serta lebar badan secara bersamaan. alat ini menggunakan sensor loadcell dan ampli hx711 dan juga HC-SRF04 serta rotary encoder. untuk lebih jelasnya berikut adalah kodingnya.


a. Komponen




b. Program Arduino IDE

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#include "HX711.h"

#define outputA 4     //CLK pada pin 4
#define outputB 5     //DT pada pin 5
#define button 6      //SW pada pin 6

#define outputA2 7     //CLK pada pin 4
#define outputB2 8     //DT pada pin 5
#define button2 9     //SW pada pin 6

// HX711.DOUT    - pin #2
// HX711.PD_SCK    - pin #3

#define trigPin 11
#define echoPin 10

//int buttonup = A0;
//int buttondown = A1;
//int buttonok = A2;
//int buttonset = A3;

int buttonupx;
int buttondownx;
int buttonokx;
int buttonsetx;

int counter = 0;      //Variabel penghitung nilai
int aState;           //Variabel kondisi
int aLastState;       //Variabel kondisi terakhir

int counter2 = 0;      //Variabel penghitung nilai
int aState2;           //Variabel kondisi
int aLastState2;       //Variabel kondisi terakhir

HX711 scale(2, 3);       

long duration, distance;
float tera = 0;
int berat;
float fix;
int x;
int jarak;
int sp = 30;
float bbmedian;
float hasil;
float hasilnya;

void setup() {

  Serial.begin(9600);
  lcd.begin();
  lcd.clear();
  lcd.noCursor();

  //pinMode (buttonup,INPUT_PULLUP); 
  //pinMode (buttondown,INPUT_PULLUP);
  //pinMode (buttonok,INPUT_PULLUP);
  //pinMode (buttonset,INPUT_PULLUP);

  pinMode (outputA,INPUT_PULLUP); //Sertting sebagai input pullup
  pinMode (outputB,INPUT_PULLUP);
  pinMode (button,INPUT_PULLUP);

  pinMode (outputA2,INPUT_PULLUP); //Sertting sebagai input pullup
  pinMode (outputB2,INPUT_PULLUP);
  pinMode (button2,INPUT_PULLUP);
               
  aLastState = digitalRead(outputA);  //Baca kondisi terakhir CLK
  aLastState2 = digitalRead(outputA2);  //Baca kondisi terakhir CLK

  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
 
  scale.set_scale(2280.f);       // this value is obtained by calibrating the scale with known weights; see the README for details
  scale.tare();                  // reset the scale to 0

   lcd.setCursor (0,0);
   lcd.print ("LOADING... ");
   delay(5000);
   lcd.clear();
}

void loop() {

//buttonupx = digitalRead(buttonup);
//buttondownx = digitalRead(buttondown);
//buttonokx = digitalRead(buttonok);
//buttonsetx = digitalRead(buttonset);

  digitalWrite(trigPin, LOW);  // Added this line
  delayMicroseconds(2); // Added this line
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10); // Added this line
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;
  jarak = sp - distance;
 
  berat = scale.get_units(10) * -1;
  fix = (berat - 0.4233)/0.1586;
  fix = fix / 1000.0;

 if (fix < 0 ) {
  fix = 0;
  }

if(jarak < 0){
  jarak = 0;
 }  

if(jarak == 45){
bbmedian = 2.4;  
hasil = fix - 2.4;
}

if(jarak == 46){
bbmedian = 2.6;    
hasil = fix - 2.6;
}

if(jarak == 47){
bbmedian = 2.8; 
hasil = fix - 2.8;
}

if(jarak == 48){
bbmedian = 2.9; 
hasil = fix - 2.9;
}

if(jarak == 49){
bbmedian = 3.1;   
hasil = fix - 3.1;
}

if(jarak == 50){
bbmedian = 3.3; 
hasil = fix - 3.3;
}

if(jarak == 51){
bbmedian = 3.5; 
hasil = fix - 3.5;
}

if(jarak == 52){
hasil = fix - 3.8;
}

if(jarak == 53){
bbmedian = 4.0;   
hasil = fix - 4.0;
}

if(jarak == 54){
bbmedian = 4.3;   
hasil = fix - 4.3;
}

if(jarak == 55){
bbmedian = 4.5;   
hasil = fix - 4.5;
}

if(hasil < 0){
  hasilnya = ((fix - bbmedian) / bbmedian - (bbmedian - 0.2));
}

if(hasil > 0){
  hasilnya = ((fix - bbmedian) / (bbmedian + 0.3) - bbmedian);
}

lingkarkepala();
lingkarlengan();
 
   lcd.setCursor (0,0);
   lcd.print ("W= ");
   lcd.print (fix );
   lcd.print (" Kg  ");
   lcd.print (hasilnya );
   lcd.print ("  ");
    
   lcd.setCursor (0,1);
   lcd.print ("H= ");
   lcd.print (distance);
   lcd.print (" /");   
   lcd.print (counter);
   lcd.print ("/");
   lcd.print (counter2);
   lcd.print ("   ");
      
  scale.power_down();                  
  delay(100);
  scale.power_up();

}

void lingkarkepala(){
  
    aState = digitalRead(outputA);          //Baca kondisi CLK
    
  if (aState != aLastState){              //Jika ada perubahan kondisi, maka
    if (digitalRead(outputB) != aState) { //Jika berputar ke kiri, maka
      counter ++;                         //Nilai bertambah
    } else {                              //Jika berputar ke kanan, maka
      counter ++;                         //Nilai berkurang
    }
    //Serial.print("Position: ");
    //Serial.println(counter);              //Tampilkan nilai
  } 
  aLastState = aState;                    //Rekam kondisi

  if(digitalRead(button) == LOW){         //Jika tombol ditekan, maka
    counter = 0;                      //Jeda pembacaan 200ms
  }
    
}

void lingkarlengan(){
  
    aState2 = digitalRead(outputA2);          //Baca kondisi CLK
    
  if (aState2 != aLastState2){              //Jika ada perubahan kondisi, maka
    if (digitalRead(outputB2) != aState2) { //Jika berputar ke kiri, maka
      counter2 ++;                         //Nilai bertambah
    } else {                              //Jika berputar ke kanan, maka
      counter2 ++;                         //Nilai berkurang
    }
    //Serial.print("Position: ");
    //Serial.println(counter);              //Tampilkan nilai
  } 
  aLastState2 = aState2;                    //Rekam kondisi

  if(digitalRead(button2) == LOW){         //Jika tombol ditekan, maka
    counter2 = 0;                      //Jeda pembacaan 200ms
  }
    
}



c. VIDEO HASILNYA