Hi to everyone. i have a project with nodemcu with blynk platform . i used a blynk lcd widget in my blynk app that shows some data such as date and time …
now, i want to add one 1602 physical LCD in my project and want to show same data (blynk lcd widget content) on my LCD too.
i tried to add many of liquidcrystal library budt it shows a conflict error with the blynk lcd!
what i should to do in my sketch?
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <WidgetRTC.h>
#define triggerPort D1 //pin NodeMCU
#define echoPort D2 //pin NodeMCU
long r ; //variabile distanza
/******* delcare functions****/
void clockDisplay();
void schedulechecker();
/********************* WIDGET SETUP **********************/
//LCDs
WidgetLCD lcd(V3);
WidgetLCD lcd1(V4);
// RTC
BlynkTimer timer;
WidgetRTC rtc;
/********************* WifiSettings **********************/
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "SNsdOqKQSlEieUVLTMGQmTdRnBF1GH8u";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "wrdsid";
char pass[] = "dslfhadjfaaf";
/****numbers***/
int motorPin = 12;
int scheduler=0;
int timeornot=0; //initialize feed timer to be off
int motorturns=10000; //default time to dispense 10 s
/******** CLOCK DISPLAY *******/
void clockDisplay() //not sure if I really need this but it updates the serial monitor
{
// You can call hour(), minute(), ... at any time
// Please see Time library examples for details
String currentTime = String(hour()) + ":" + minute() + ":" + second();
String currentDate = String(day()) + " " + month() + " " + year();
Serial.print("Current time: ");
Serial.print(currentTime);
Serial.print(" ");
Serial.print(currentDate);
Serial.println();
}
BLYNK_CONNECTED() {
// Synchronize time on connection
rtc.begin();
}
/************** SETUP SETUP SETUP SETUP SETUP *****************/
void setup()
{
Serial.begin(9600); //baude rate of monitor
pinMode(motorPin, OUTPUT); // digital pin (12) on huzzah
digitalWrite(motorPin, HIGH);
pinMode( triggerPort, OUTPUT );
pinMode( echoPort, INPUT );
/******** Connect Blynk ***********/
Blynk.begin(auth, ssid, pass);
rtc.begin();
setSyncInterval(10 * 60); // Sync interval in seconds (10 min)
timer.setInterval(100L, clockDisplay);
}
BLYNK_WRITE(V1) //Button Widget is writing to pin V1, manual feed
{
int food = param.asInt();
String currentTime = String(hour()) + ":" + minute() + ":" + second();
String currentDate = String(month()) + "/" + day() + "/" + year();
if (food==LOW){
digitalWrite(motorPin, LOW);
Serial.println("Feeding");
delay(motorturns);
Blynk.virtualWrite(V1, HIGH);
lcd.clear();
lcd1.clear();
lcd.print(0,0, "Time Last Fed: ");
lcd.print(0,1, currentTime);
lcd1.print(0,0, "Date Last Fed: ");
lcd1.print(0,1, currentDate);
//turn of motor
digitalWrite(motorPin, HIGH); //stop feeding
Serial.println("Fed");
}
}
///****Scheduler****/
BLYNK_WRITE(V6) //morning pin
{ if (param.asInt() == 1)
{timeornot=1;
}
if (param.asInt()==0)
{timeornot=0;
}
}
BLYNK_WRITE(V7) //evening pin
{ if (param.asInt() == 1)
{timeornot=1;
}
if (param.asInt()==0)
{timeornot=0;
}
}
BLYNK_WRITE(V8) // scheduler on or off
{
if (param.asInt() == 1) {
scheduler=1;
timeornot=0;
Serial.println("Scheduler is ON");
}
if (param.asInt() == 0){
scheduler=0;
Serial.println("Scheduler is Off");
}
}
void schedulerchecker()
{
String currentTime = String(hour()) + ":" + minute() + ":" + second();
String currentDate = String(month()) + "/" + day() + "/" + year();
if (scheduler==1 && timeornot==1) //autofeed times
{ Blynk.notify("Auto Fed @"+ currentTime);
digitalWrite(motorPin, LOW);
Serial.println("Scheduled Feeding");
delay(motorturns);
Blynk.virtualWrite(V1, HIGH);
lcd.clear();
lcd1.clear();
lcd.print(0,0, "Time Auto Fed: ");
lcd.print(0,1, currentTime);
lcd1.print(0,0, "Date Auto Fed: ");
lcd1.print(0,1, currentDate);
//turn of motor
digitalWrite(motorPin, HIGH); //stop feeding
Serial.println("Fed");
}
timeornot=0;
}
/****FOR DEMO ONLY (dispense candy; not needed to feed dog)***/
BLYNK_WRITE(V5)
{ int cup_slider= param.asInt(); //percentage of 1 cup (e.g. 100=1cup)
motorturns=15*(cup_slider)*10; //cup_slider/100*15*1000 for milliseconds, cancels out to *10 for integers
}
/************ LOOP LOOP LOOP LOOP LOOP********/
void loop() {
digitalWrite( triggerPort, LOW ); //porta bassa l'uscita del trigger
digitalWrite( triggerPort, HIGH ); //invia un impulso di 10microsec su trigger
delayMicroseconds( 10 );
digitalWrite( triggerPort, LOW );
long duration = pulseIn( echoPort, HIGH , 10000 ); // 10000 µS = max circa 1,7 metri
r = 0.034 * duration / 2;
Blynk.virtualWrite(V9, r); //Virtual Pin Label
Blynk.run(); //runs all Blynk functions
timer.run(); // Initiates Timer
schedulerchecker(); //looks for the button for using the schedules times and if the timers get pinged
}