Display lcd widgets same as real lcd

i am doing a project using sensor acs721 ,lcd i2c and node mcu

.The real LCD can display the current.But when i connect it to blynk, the lcd widget dont display any value.

i just want to display on widget the same things as real lcd display

do i need to add value display on blynk?

and im confuse when i need to use sketch of lcd advance or mode reading or mode pushing?

#include <Blynk.h>

#define BLYNK_PRINT Serial

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

LiquidCrystal_I2C lcd(0x27,16,2);

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "";
char pass[] = "";


const int sensorIn = A0;
int mVperAmp = 185; // use 100 for 20A Module and 66 for 30A Module


double Voltage = 0;
double VRMS = 0;
double AmpsRMS = 0;

void setup()
{
  // Debug console
  Serial.begin(152000);

  Blynk.begin(auth, ssid, pass);

  lcd.begin();
  lcd.print("current measure");

  delay(500);
  lcd.clear();
  delay(500);
  

}

void loop()
{

 Voltage = getVPP();
 VRMS = (Voltage/2.0) *0.707; 
 AmpsRMS = (VRMS * 1000)/mVperAmp;

 Serial.print(AmpsRMS);
 Serial.println(" Amps RMS");
 lcd.print(AmpsRMS);
 lcd.println(" Amps RMS");
 
  Blynk.run();
}

float getVPP()
{
  float result;
  
  int readValue;             //value read from the sensor
  int maxValue = 0;          // store max value here
  int minValue = 1024;          // store min value here
  
   uint32_t start_time = millis();
   while((millis()-start_time) < 1000) //sample for 1 Sec
   {
       readValue = analogRead(sensorIn);
       // see if you have a new maxValue
       if (readValue > maxValue) 
       {
           /*record the maximum sensor value*/
           maxValue = readValue;
       }
       if (readValue < minValue) 
       {
           /*record the maximum sensor value*/
           minValue = readValue;
       }
   }
   
   // Subtract min from max
   result = ((maxValue - minValue) * 5.0)/1024.0;
      
   return result;

Yes you can use both LCD Widget and Physical LCD

No you do not need a Display Widget to use the LCD Widget

Advanced mode will work similar to how your physical LCD will work by choosing the line and starting character placement then printing the string.

Just set it up and call it something different than the physical lcd.print()… like vlcd.print(), etc.

https://examples.blynk.cc/?board=NodeMCU&shield=ESP8266%20WiFi&example=Widgets%2FLCD%2FLCD_AdvancedMode

Code formatting in the forum is with backticks, NOT commas, quotes, or apostrophes.

Blynk%20-%20FTFC

But it won’t work if you have the virtual LCD code in your void loop, you’ll flood the Blynk server. Read this:

Pete.

yeah… i have same problem as mention in this article

but my coding need to use loop,

Voltage = getVPP();
VRMS = (Voltage/2.0) *0.707;
AmpsRMS = (VRMS * 1000)/mVperAmp;

and i dont think i can put it at void setup?

No… it does NOT. One rarely needs to read a sensor, and print to a display, hundreds or thousands of times a second.

Please read the article provided… setting up timed functions can work perfectly for your needs

1 Like

this is my coding now

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

#include <BlynkSimpleEsp8266.h>

LiquidCrystal_I2C lcd(0x27,16,2);

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "a";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "";
char pass[] = "";

const int sensorIn = A0;
int mVperAmp = 185; // use 100 for 20A Module and 66 for 30A Module


double Voltage = 0;
double VRMS = 0;
double AmpsRMS = 0;
WidgetLCD vlcd(V1);

BlynkTimer timer;



void setup() {
  // put your setup code here, to run once:

    Serial.begin(115200);
    
  Blynk.begin(auth, ssid, pass);

   timer.setInterval(1000L, sensorDataSend);

}

void sensorDataSend()
{
   Voltage = getVPP();
 VRMS = (Voltage/2.0) *0.707; 
 AmpsRMS = (VRMS * 1000)/mVperAmp;

 Serial.print(AmpsRMS);
 Serial.println(" Amps RMS");
 lcd.print(AmpsRMS);
 lcd.println(" Amps RMS");

  vlcd.clear();
  vlcd.print(4, 0, AmpsRMS);
  vlcd.print(4, 1, "AmpsRMS");
  delay(500);
}

void loop() {
  // put your main code here, to run repeatedly:
 Blynk.run();        // run Blynk magic
  timer.run(); 
  
}


float getVPP()
{
  float result;
  
  int readValue;             //value read from the sensor
  int maxValue = 0;          // store max value here
  int minValue = 1024;          // store min value here
  
   uint32_t start_time = millis();
   while((millis()-start_time) < 1000) //sample for 1 Sec
   {
       readValue = analogRead(sensorIn);
       // see if you have a new maxValue
       if (readValue > maxValue) 
       {
           /*record the maximum sensor value*/
           maxValue = readValue;
       }
       if (readValue < minValue) 
       {
           /*record the maximum sensor value*/
           minValue = readValue;
       }
   }
   
   // Subtract min from max
   result = ((maxValue - minValue) * 5.0)/1024.0;
      
   return result;
 }

thanks to you guys,
finally the data can be displayed at widget lcd,
but now can not be displayed at physical lcd.

why?

where is your lcd.begin in setup?

The OP was last seen over a year ago, 10 days after joining the community, so I guess that he’s moved on to other stuff now…

Pete.

2 Likes

ah, I didnt look at the date. Thanks Pete.

Atikahamdan.