LCD blank after upload blynk coding

Hi, right now im doing AC current monitoring, Im using Arduino Uno, esp8266, LCD and HSTS016L . I wanted to display the current on the LCD and also in Blynk apps. I run the ac current coding and upload it to the arduino, the sensor successfully detect the AC current. But after Im uploading the Blynk coding the LCD become blynk. There are no error shown in the arduino IDE so can someone help me since im new with the blynk apps. Thank you.

#define BLYNK_DEVICE_NAME "Current Monitoring"
#define BLYNK_AUTH_TOKEN "BeOfUSHroBmU0UItZFpfCVLHqYnIX3nH"


#define BLYNK_PRINT Serial

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;

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

// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial

// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200

ESP8266 wifi(&Serial);

// Declaring a global variabl for sensor data
int sensorVal; 

// This function creates the timer object. It's part of Blynk library 
BlynkTimer timer; 
        
        
        /* 0- General */

        int decimalPrecision = 2;                   // decimal places for all values shown in LED Display & Serial Monitor

        /* 1- AC Current Measurement */

        int currentAnalogInputPin = A1;             // Which pin to measure Current Value (A0 is reserved for LCD Display Shield Button function)
        int calibrationPin = A2;                    // Which pin to calibrate offset middle value
        float manualOffset = 0.00;                  // Key in value to manually offset the initial value
        float mVperAmpValue = 31.25;                 // If using "Hall-Effect" Current Transformer, key in value using this formula: mVperAmp = maximum voltage range (in milli volt) / current rating of CT
                                                    // For example, a 20A Hall-Effect Current Transformer rated at 20A, 2.5V +/- 0.625V, mVperAmp will be 625 mV / 20A = 31.25mV/A 
                                                    // For example, a 50A Hall-Effect Current Transformer rated at 50A, 2.5V +/- 0.625V, mVperAmp will be 625 mV / 50A = 12.5 mV/A
        float supplyVoltage = 5000;                 // Analog input pin maximum supply voltage, Arduino Uno or Mega is 5000mV while Arduino Nano or Node MCU is 3300mV
        float offsetSampleRead = 0;                 /* to read the value of a sample for offset purpose later */
        float currentSampleRead  = 0;               /* to read the value of a sample including currentOffset1 value*/
        float currentLastSample  = 0;               /* to count time for each sample. Technically 1 milli second 1 sample is taken */
        float currentSampleSum   = 0;               /* accumulation of sample readings */
        float currentSampleCount = 0;               /* to count number of sample. */
        float currentMean ;                         /* to calculate the average value from all samples, in analog values*/ 
        float RMSCurrentMean ;                      /* square roof of currentMean, in analog values */   
        float FinalRMSCurrent ;                     /* the final RMS current reading*/
        
        /* 2 - LCD Display  */

        #include<LiquidCrystal.h>                       /* Load the liquid Crystal Library (by default already built-it with arduino solftware)*/
        LiquidCrystal LCD(8,9,4,5,6,7);                 /* Creating the LiquidCrystal object named LCD. The pin may be varies based on LCD module that you use*/
        unsigned long startMicrosLCD;                   /* start counting time for LCD Display */
        unsigned long currentMicrosLCD;                 /* current counting time for LCD Display */
        const unsigned long periodLCD = 1000000;        // refresh every X seconds (in seconds) in LED Display. Default 1000000 = 1 second 

void myTimer() 
{
  // This function describes what will happen with each timer tick
  // e.g. writing sensor value to datastream V5
  Blynk.virtualWrite(V5, sensorVal);  
}




void setup()                                              /*codes to run once */

{                                      

        /* 0- General */
        
        Serial.begin(9600);                               /* to display readings in Serial Monitor at 9600 baud rates */
        //delay(10);
        /*Set ESP8266 baud rate */
       // Serial.begin(ESP8266_BAUD);
        //delay(10);
        /* 2 - LCD Display  */

        LCD.begin(16,2);                                  /* Tell Arduino that our LCD has 16 columns and 2 rows*/
        LCD.setCursor(0,0);                               /* Set LCD to start with upper left corner of display*/  
        startMicrosLCD = micros();                        /* Start counting time for LCD display*/
        
        //Connecting to Blynk Cloud
        Blynk.begin(auth, wifi, ssid, pass); 
        // Setting interval to send data to Blynk Cloud to 1000ms. 
        // It means that data will be sent every second
        timer.setInterval(1000L, myTimer); 

}


void loop()                                                                                                   /*codes to run again and again */
{                                      

        /* 1- AC & DC Current Measurement */

        if(micros() >= currentLastSample + 200)                                                               /* every 0.2 milli second taking 1 reading */
          { 
           currentSampleRead = analogRead(currentAnalogInputPin)-analogRead(calibrationPin);                  /* read the sample value including offset value*/
           currentSampleSum = currentSampleSum + sq(currentSampleRead) ;                                      /* accumulate total analog values for each sample readings*/
           currentSampleCount = currentSampleCount + 1;                                                       /* to count and move on to the next following count */  
           currentLastSample = micros();                                                                      /* to reset the time again so that next cycle can start again*/ 
          }
        
        if(currentSampleCount == 4000)                                                                        /* after 4000 count or 800 milli seconds (0.8 second), do this following codes*/
          { 
            currentMean = currentSampleSum/currentSampleCount;                                                /* average accumulated analog values*/
            RMSCurrentMean = sqrt(currentMean);                                                               /* square root of the average value*/
            FinalRMSCurrent = (((RMSCurrentMean /1023) *supplyVoltage) /mVperAmpValue)- manualOffset;         /* calculate the final RMS current*/
            if(FinalRMSCurrent <= (625/mVperAmpValue/100))                                                    /* if the current detected is less than or up to 1%, set current value to 0A*/
            { FinalRMSCurrent =0; }
            Serial.print(" The Current RMS value is: ");
            Serial.print(FinalRMSCurrent,decimalPrecision);
            Serial.println(" A ");
            currentSampleSum =0;                                                                              /* to reset accumulate sample values for the next cycle */
            currentSampleCount=0;                                                                             /* to reset number of sample for the next cycle */
          }

        /* 2 - LCD Display  */
        
        currentMicrosLCD = micros();                                                                          /* Set counting time for LCD Display*/
        if (currentMicrosLCD - startMicrosLCD >= periodLCD)                                                   /* for every x seconds, run the codes below*/
          {
            LCD.setCursor(0,0);                                                                               /* Set cursor to first colum 0 and second row 1  */
            LCD.print("I=");
            LCD.print(FinalRMSCurrent,decimalPrecision);                                                      /* display current value in LCD in first row  */
            LCD.print("A                  ");
            LCD.setCursor(0,1); 
            LCD.print("                   ");                                                                 /* display nothing in LCD in second row */
            startMicrosLCD = currentMicrosLCD ;                                                               /* Set the starting point again for next counting time */
          }

         // Reading sensor from hardware analog pin A0
         sensorVal = analogRead(A0); 
  
         // Runs all Blynk stuff
         Blynk.run(); 
  
        // runs BlynkTimer
        timer.run(); 
   
}```

@Adlin Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Copy and paste these if you can’t find the correct symbol on your keyboard.

Pete.

Thanks. Done edit the coding.

Okay, well there are so many things wrong with this sketch it’s difficult to know where to begin.

Because you are using an Uno and have connected your ESP-01 to pins 0 and 1 rather than using SoftwareSerial to create a virtual serial port on different pins, I’ll start by pointing you in this direction…

Once you’ve fixed that issue you’ll then be able to use your hardware serial port for debugging, and will be able to understand what is happening when you attempt to connect to Blynk.

Then you need to clean-up your void loop…

Pete.

I already edited my arduino code. when I want to upload the code, there was an error.
This are the error:


Sketch uses 21258 bytes (65%) of program storage space. Maximum is 32256 bytes.

Global variables use 1325 bytes (64%) of dynamic memory, leaving 723 bytes for local variables. Maximum is 2048 bytes.

D:\Users\alinam01\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CD:\Users\alinam01\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -patmega328p -carduino -PCOM3 -b115200 -D -Uflash:w:D:\Users\alinam01\AppData\Local\Temp\arduino_build_637463/Current_Monitor___Blynk.ino.hex:i 



avrdude: Version 6.3-20190619

         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

         Copyright (c) 2007-2014 Joerg Wunsch



         System wide configuration file is "D:\Users\alinam01\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"



         Using Port                    : COM3

         Using Programmer              : arduino

         Overriding Baud Rate          : 115200

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00



avrdude done.  Thank you.



An error occurred while uploading the sketch



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

and here is my code:

#define BLYNK_TEMPLATE_ID "TMPLoFs1X9h2"
#define BLYNK_DEVICE_NAME "Current Monitoring"
#define BLYNK_AUTH_TOKEN "t2mNXgaihR6jWxN5QR1puGf1KVm2P0mS"


#define BLYNK_PRINT Serial

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;

char ssid[] = "88888";
char pass[] = "888888";

#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX,TX

#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);

int decimalPrecision = 2;                   
int currentAnalogInputPin = A1;             
int calibrationPin = A2;                    
float manualOffset = 0.00; 
float mVperAmpValue = 31.25;                 
float supplyVoltage = 5000;                
float offsetSampleRead = 0;                
float currentSampleRead  = 0;               
float currentLastSample  = 0;              
float currentSampleSum   = 0;              
float currentSampleCount = 0;              
float currentMean ;                          
float RMSCurrentMean ;                        
float FinalRMSCurrent ;                    
        
#include<LiquidCrystal.h>                       
LiquidCrystal LCD(8,9,4,5,6,7);                 
unsigned long startMicrosLCD;                  
unsigned long currentMicrosLCD;                
const unsigned long periodLCD = 1000000;        

BlynkTimer timer;
int sensorValue;

void setup()                                              
{                                      
        Serial.begin(115200);                               
        
        EspSerial.begin(ESP8266_BAUD);
        delay(10);

        LCD.begin(16,2);                                  
        LCD.setCursor(0,0);                                 
        startMicrosLCD = micros();                        
        timer.setInterval(1000L, sensorDataSend);
        Blynk.begin(auth, wifi, ssid, pass, "blynk.cloud", 80); 
}
void sensorDataSend()
{
  sensorValue = analogRead(A1);
  Blynk.virtualWrite(V10, sensorValue);
}

void loop()                                                                                                   
{                                      

        /* 1- AC & DC Current Measurement */

        if(micros() >= currentLastSample + 200)                                                               
          { 
           currentSampleRead = analogRead(currentAnalogInputPin)-analogRead(calibrationPin);                  
           currentSampleSum = currentSampleSum + sq(currentSampleRead) ;                                      
           currentSampleCount = currentSampleCount + 1;                                                        
           currentLastSample = micros();                                                                       
          }
        
        if(currentSampleCount == 4000)                                                                        
          { 
            currentMean = currentSampleSum/currentSampleCount;                                                
            RMSCurrentMean = sqrt(currentMean);                                                               
            FinalRMSCurrent = (((RMSCurrentMean /1023) *supplyVoltage) /mVperAmpValue)- manualOffset;        
            if(FinalRMSCurrent <= (625/mVperAmpValue/100))                                                    
            { FinalRMSCurrent =0; }
            Serial.print(" The Current RMS value is: ");
            Serial.print(FinalRMSCurrent,decimalPrecision);
            Serial.println(" A ");
            currentSampleSum =0;                                                                              
            currentSampleCount=0;                                                                             
          }

        /* 2 - LCD Display  */
        
        currentMicrosLCD = micros();                                                                          
        if (currentMicrosLCD - startMicrosLCD >= periodLCD)                                                   
          {
            LCD.setCursor(0,0);                                                                               
            LCD.print("I=");
            LCD.print(FinalRMSCurrent,decimalPrecision);                                                      
            LCD.print("A                  ");
            LCD.setCursor(0,1); 
            LCD.print("                   ");                                                                 
            startMicrosLCD = currentMicrosLCD ;                                                               
          }
          
         Blynk.run();
         timer.run();    
}```

Which pins are your ESP-01 connected to now?
Is anything connected to pins 0 and 1 on your Uno?

You clearly didn’t take any notice of this piece of advice…

although that’s not what’s causing your current issue.

Pete.

Sorry I have made some changes to the coding

#include <SoftwareSerial.h>
SoftwareSerial EspSerial(0, 1)  //RX,TX

and I already read how to clean-up the void loop and do some changes for the void loop. Rn the code can be upload but the serial monitor shows the esp is not responding.

I’d suggest that you go back and re-read the tutorial I linked to in post #4 as you haven’t understood why you are using the SoftwareSerial library and which pins should NOT be used when using SoftwareSerial with the Uno.

Your changes will be complete when your void loop looks like this:

void loop()                                                                                                   
{ 
  Blynk.run();
  timer.run();    
}

Pete.