Hi all,
How are you guys doing? I’m DIni am working on my school project. I am new to this Blynk IoT architecture. I want to do a rain detector that can be checked from smart phone using Blynk application. Right now I manage to make it work and get the output display on the Blynk app using widget box “value display”. It display output 0 and 1 only. However, I want the app to display “ITS RAINING” and “NOT RAINING”.
Can you please advise me on how to change the Blynk apps output 0 and 1 to wordings like above?
Thank you,
Dini
• Hardware model : NODEMCU ESP8266 with WIFI
• Smartphone : IOS
• Blynk server
• Blynk Library version : 0.6.1.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
LiquidCrystal_I2C lcd(0X27,16,2);
// PIN D1 TO D3
int RAINSENSOR = D3;
int sensorData;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "XXXXXXXX";
char pass[] = "*****";
BlynkTimer timer; // Announcing the timer
void myTimerEvent()
{
sensorData = digitalRead(D3);
Blynk.virtualWrite(V5, sensorData);
}
void setup()
{
pinMode(RAINSENSOR, INPUT);
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
timer.setInterval(1000L, myTimerEvent);
}
void loop()
{
Blynk.run();
lcd.begin();
if (0 == digitalRead(RAINSENSOR))
{
lcd.print("ITS RAINING!!! ");
} else
{
lcd.print("NOT RAINING");
}
timer.run(); // running timer every second
}