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;
#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.