Translate

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



No comments:

Post a Comment