I have an interesting problem when using A Liquid I2C library and Blynk. Particularly when using the WidgetLCD lcd widget . the “lcd” in the widget command conflicts with the lcd in the Liquid Crystal command ‘LiquidCrystal_I2C lcd(0x27,16,2);’ both libraries want to use ‘lcd’ hence the problem. I got around the problem by using a different widget.
Has anyone had the same problem? Is there a work around?
Thanks.
Do you mean that you’re declaring an object called lcd
for the Blynk LCD widget like this:
WidgetLCD lcd(vPin);
If so then it’s not a case of the library wanting to use ‘lcd’, it simply a case that you’ve chosen to use ‘lcd’ as your object name for both the Blynk LCD widget and your physical LCD widget.
The sensible approach would be to use object names such as blynk_lcd
and physical_lcd
.
Pete.
Thanks for that super fast reply, Pete.
I’m still fairly new at this, but my limited understanding is the object name ‘WidgetLCD lcd (Vpin). Is a defined term designated by the library and not subject for me to arbitrarily change it unless I go into the library and change it there as well. I never considered that ‘lcd’ in the WidgetLCD lcd (Vpin) might be an arbitrary name that I might change to any name I want…. Such as WidgetLCD screen (Vpin) without having to make changes in the library… Am I correct?
Jeff
further…
Okay, I tried changing the name to WidgetLCD screen (VPin); but on further investigation the Blynk widget WANTS to be called lcd. Changing the name to screen does not transmit any data to the device (although it is connected.) As I said I have a work around, but I’m curious about the problem and maybe solving it will help someone else wishing to use the LCD widget along with and LCD display.
Jeff
Are you sure you changed ALL the iterations of “lcd” in your code?
Again thanks for taking the time to respond. Yes, The program compiles fine and connects to the app. But no data is displayed on the lcd widget. (the program works fine on my OLED display where there is no other LCD device so I know it works.) I note that the widget is displayed as lcd (not LCD). While the computer program will except me changing the name or even capitalizing lcd to LCD it appears the android program will not…
Jeff
Can you post your sketch (correctly formatted with triple backticks of course).
Pete.
Will do so shortly. Thanks for reminding me that formatting of code with ``` is different than formatting on arduino forum.
Jeff
Okay, I’ve simplified the program down to it’s bare essentials. It it works then on the android blynk app you should see WAITING on the green LCD screen. One important note is that I’m using the following Liquid Crystal library:
Arduino-LiquidCrystal-I2C lbrary- Master fdebrander
I’ve tried about four or five other I2C libraries and they don’t work with this configuration. This is the only one so changing the I2C library is not a viable option.
If you change line 11:
WidgetLCD lcd(V1); to WidgetLCD LCD(V1); or something else it WILL compile, but not transfer data.
I’ve x’d out personal dats.
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "xxxxxxxxxxxxxxxxxx"; //Enter the Auth code which was send by Blink
char ssid[] = "xxxxxxxxxxxx"; //Enter your WIFI Name
char pass[] = "xxxxxx"; //Enter your WIFI Password
LiquidCrystal_I2C lcd(0x27,16,2);
WidgetLCD lcd(V1);
void setup()
{
Serial.begin(115200); // See the connection status in Serial Monitor
Blynk.begin(auth, ssid, pass);
lcd.begin();
lcd.backlight();
lcd.clear();
lcd.print("Waiting 2");
}
void loop()
{
Blynk.run(); // Initiates Blynk
}
Let me know if you have any thoughts.
Thanks.
Jeff
I’m confused.
You’re not writing any data to the LCD widget. Is this a victim of your ‘simplification’?
Pete.
No! It is a because the program can’t talk to the Widget!! the program connects to the Android app. It says it’s connected. On the OLED program I can use WidgetLCD lcd(V1). It connects to the program and the Widget. If I change the lcd in the widget to anything else the widget doesn’t recognize it. Right now I’m connected happily to a gauge and the program runs perfectly.
Jeff
Difficult to help you if you don’t post the problematic code, with the changes I suggested earlier, and details of what you see on the OLED screen and in the app.
Pete.
Hi Pete:
FYI
Here is the code of the Receiver end of the project that works fine. I can live with it. As I said I was curious about why the LCDWIdget didn’t work…
* For this example you'll need the following library:
* *
* 1) Arduino-LiquidCrystal-I2C-library: https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library
*
* 2) Blynk Library: https://github.com/blynkkk/blynk-library
*
* Connections::
* D1 -> SCL of I2C LCD
* D2 -> SDA of I2C LCD
*D5-> Low Water LED
*
*/
#include <LoRa.h>
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#define I2C_SDA D3 //redefining I2C pins as D1 is needed by LoRa unit
#define I2C_SCL D4
#define ss 15
#define rst 16
#define dio0 2
int ledPin = 5; //warning light that water has dropped beyond preset level
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxx"; //Enter the Auth code which was send by Blink
char ssid[] = "xxxxxxxxxx"; //Enter your WIFI Name
char pass[] = "xxxxxxxx"; //Enter your WIFI Password
void setup()
{
Wire.pins(D3, D4);
//Serial.begin(9600);
lcd.begin(); // iInit the LCD for 16 chars 2 lines
lcd.backlight(); // Turn on the backligt (try lcd.noBaklight() to turn it off)
delay (1000);
Blynk.begin(auth, ssid, pass);
Serial.println("LoRa Sender");
LoRa.setPins(ss, rst, dio0);
if (!LoRa.begin(433E6))
{
Serial.println("Starting LoRa failed!");
delay(100);
while (1);
}
Serial.println("LoRa Started");
lcd.clear();
lcd.print("Waiting");
LoRa.setSpreadingFactor(10);
LoRa.setSignalBandwidth(62.5E3);
LoRa.crc();
}
void loop()
{
// try to parse packet
int packetSize = LoRa.parsePacket();
int targetDistance = LoRa.parseInt();
if (packetSize)
{
//Serial.print("distance is ");
// Serial.print(targetDistance);
// Serial.print(" inches ");
// Serial.println(" ");
lcd.setCursor(0,0); //First line
lcd.print("water is down");
lcd.setCursor(0,1); //Second line
lcd.print(targetDistance);
lcd.print(" inches");
Blynk.run(); // Initiates Blynk
Blynk.virtualWrite(V1,targetDistance);
delay(1000);
{
if (targetDistance <= 25 )
{
digitalWrite(ledPin,LOW);
}
else
{
digitalWrite(ledPin,HIGH);
}
}
}
}
Okay, we’re going around in circles here so I’ll bow-out for a while.
Once I’m in a position to be back in front of my PC with some hardware to play around with then I’ll try using a different object name for the WidgetLCD and see what happens.
Pete.
Okay, Me too. As I said, it’s no biggie. THis code works and I’m happy to share it. I’ll slowly improve it and try and figure out how to add a graphing to it. The Ra-02. is quite robust. I tried NRF24L01, but it couldn’t cut through the trees. This will work up to km through rough territory and you can still read the data inside the house.
Thanks again.
Jeff
Okay, I finally have my home office/workshop up and running again and am catching-up on a few things that were on my to-do list - including my promise to test-out the Blynk LCD widget not responding to aliases other than 'lcd`.
I created a Blynk project with three LCD widgets, all configured in ‘Advanced’ mode and attached to different virtual pins (V1, V2 & V3). I’ve changed the background colours to Blue, Green and Red to distinguish them.
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "REDACTED";
char ssid[] = "REDACTED";
char pass[] = "REDACTED";
WidgetLCD BlynkBlueLCD(V1);
WidgetLCD BlynkGreenLCD(V2);
WidgetLCD BlynkRedLCD(V3);
void setup()
{
Serial.begin(74880);
Blynk.begin(auth, ssid, pass);
BlynkBlueLCD.print(0,0,"Blue LCD");
BlynkGreenLCD.print(0,0,"Green LCD");
BlynkRedLCD.print(0,0,"Red LCD");
}
void loop()
{
Blynk.run();
}
As you can see, Blynk has no problem writing data to LCD widgets with object names such as BlynkBlueLCD
, BlynkGreenLCD
and BlynkRedLCD
As you’ve not so far included any full sketch which uses a Blynk LCD widget with an object name other than lcd
along with code wo write data to that widget object, I can only assume that the issue is with the way that you’ve attempted to write data to the Blynk LCD widget object.
Pete.
i experienced the same thing. did you find the solution sir?
Solution to which issue?
Pete.