Arduino Uno and ESP8266 won't Ping with Blynk App

Hi there. I am making an automated horse feeder fro my senior design capstone class. Two weeks ago, this code allowed me to connect to the Blynk app and it was working properly. Now, I can’t get it to grab an IP address and ping with the Blynk app. Here is the screenshot of the serial port and my code. Any suggestions?

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#define RELAY_ON 0
#define RELAY_OFF 1
/*-----( Declare objects )-----*/
/*-----( Declare Variables )-----*/
#define Relay_1  2  // Arduino Digital I/O pin number
#define Relay_2  3
#define Relay_3  4
#define Relay_4  5
#define Relay_5  6
#define Relay_6  7

#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <SimpleTimer.h>
#include <TimeLib.h>
#include <WidgetRTC.h>

char auth[] = "726bf57d1f4747b5b3161cacc3b27257";
char ssid[] = "Verizon-MiFi-MSU";
char pass[] = "723cb993";

#include <SoftwareSerial.h>
SoftwareSerial EspSerial(8, 9); // RX, TX

#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);

SimpleTimer timer;
WidgetRTC rtc;

void clockDisplay()
{
  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.virtualWrite(V1, currentTime);
  Blynk.virtualWrite(V2, currentDate);
}

void setup()
{
 
  Serial.begin(9600);
  delay(10);
  EspSerial.begin(ESP8266_BAUD);
  delay(10);
  
  Blynk.begin(auth, wifi, ssid, pass);

  Serial.begin(9600);

  rtc.begin();

  timer.setInterval(10000L, clockDisplay);
  
  digitalWrite(Relay_1, RELAY_OFF);
  digitalWrite(Relay_2, RELAY_OFF);
  digitalWrite(Relay_3, RELAY_OFF);
  digitalWrite(Relay_4, RELAY_OFF);  
  digitalWrite(Relay_5, RELAY_OFF); 
  digitalWrite(Relay_6, RELAY_OFF);

  pinMode(Relay_1, OUTPUT);   
  pinMode(Relay_2, OUTPUT);  
  pinMode(Relay_3, OUTPUT);  
  pinMode(Relay_4, OUTPUT);  
  pinMode(Relay_5, OUTPUT); 
  pinMode(Relay_6, OUTPUT);   
  delay(4000); //Check that all relays are inactive at Reset

}

void loop()
{

  Blynk.run();
  timer.run();

  digitalWrite(Relay_1, RELAY_ON);// set the Relay ON
  delay(1000);              // wait for a second
  digitalWrite(Relay_2, RELAY_ON);// set the Relay ON
  delay(1000);              // wait for a second  
  digitalWrite(Relay_1, RELAY_OFF);// set the Relay OFF
  delay(1000);              // wait for a second
  digitalWrite(Relay_2, RELAY_OFF);// set the Relay OFF
  delay(28800000);              // wait for 8 hrs 

  
  digitalWrite(Relay_3, RELAY_ON);// set the Relay ON
  delay(1000);              // wait for a second
  digitalWrite(Relay_4, RELAY_ON);// set the Relay ON
  delay(1000);              // wait for a second
  digitalWrite(Relay_3, RELAY_OFF);// set the Relay OFF
  delay(1000);              // wait for a second
  digitalWrite(Relay_4, RELAY_OFF);// set the Relay OFF
  delay(28800000);              // wait for 8 hours

  
  digitalWrite(Relay_5, RELAY_ON);// set the Relay ON
  delay(1000);              // wait for a second
  digitalWrite(Relay_6, RELAY_ON);// set the Relay ON
  delay(4000);              // wait see all relays ON
  digitalWrite(Relay_5, RELAY_OFF);// set the Relay OFF
  delay(1000);              // wait for a second
  digitalWrite(Relay_6, RELAY_OFF);// set the Relay OFF
  delay(43200000);              // wait 12 hours

}

Assuming you haven’t changed any hardware connections or code, then I would suspect that while you can connect to it, you are not getting Internet access (thus not connecting to Blynk’s Cloud Server) via your Verizon-MiFi-MSU.

@kelly.walls34 what kind of loop() is that, wait for 8 hours, wait for 12 hours !!!

Even wait for a second is not recommended in loops associated with ESP’s.

Study the SimpleTimer library that Blynk provides in the zip file you downloaded.

@Costas blew a fuse :smile:

it’s because of delay(); in your loop. The code get stuck and Blynk.run(); never been executed until all delay(); has been executed.
you must change the code by using SimpleTImer to write the relay instead of using delay();

Wow… I know I was tired yesterday, but how did I miss noticing all of this when responding? :confounded: I must have delays in my own mental loop somewhere :stuck_out_tongue:

A post was split to a new topic: Arduino Mega 2560 and ESP8266