Arduino UNO, ESP8266 and BLYNK internet connection not responsive + button not working

I am trying to power on a Motor Driver which will enable a water pump to turn on using a simple application that I created using Blynk. However, the internet connection just stays up for something like 5 seconds, and then it disconnects. It does this continuously, hence the whole system is just not functional. I have tried testing the button during the short period of time that it connects to the internet and it is also not working. The button is the one that I want to use to switch on or off the motor driver.

Here is my code:

    #define BLYNK_PRINT Serial
    #include <SoftwareSerial.h>
    #include <ESP8266_Lib.h>
    #include <BlynkSimpleShieldEsp8266.h>


    int sensor_raw_data;
    int mapped_data;
    int pump;

    SoftwareSerial esdata(3,4);
    #define auth "XXXXXXX"
    #define ssid "XXXXXXX"
    #define pass "XXXXXXX"


    ESP8266 wifi(&esp8266);

     // Send AT commands
     String sendAT(String cmd, const int tmeout) {

       String rsp = "";


       long int time = millis();

      while((time + tmeout) > millis()) {

        while(esdata.available()) {

        char c =;

        rsp += c;

      return rsp;
void setup() {



      Blynk.begin(auth, wifi, ssid, pass);

      sendAT("AT+RST\r\n", 2000);

      sendAT("AT\r\n", 1000);

      sendAT("AT+CWMODE=1\r\n", 1000);

      sendAT("AT+CWJAP=\""said"\",\""pass"\"\r\n", 2000);

      while(!esdata.find("OK")) {

      sendAT("AT+CIFSR\r\n", 1000);

      sendAT("AT+CIPMUX=0\r\n", 1000);

      pinMode(A0, INPUT);

      pinMode(8, OUTPUT);
  void loop() {;

      sensor_raw_data = analogRead(A0);

      mapped_data=map(sensor_raw_data, 0, 1023, 100, 0);

      String sensor_value = String(mapped_data);

      Serial.print("Sensor Data: ");


      // Display the soil moisture on a gauge. // This is working   properly
     Blynk.virtualWrite(V5, prdata); 

      // Send notification if soil moisture is below 80%
      if(mapped_data < 80) {

      Blynk.notify("Soil Moisture Is Below 80%. Turn On Water Pump.");

      } else {

        Blynk.notify("Soil Moisture Is Above 80%. Turn Off Water Pump.");


      String pmp = String(pump);
      updateTS(sensor_value, pmp);


This is the function for the button. In my app, the button is Virtual pin 8. The Motor Driver is connected to Digital pin 8 on the Arduino. Is there something wrong with the function? Or maybe there is actually another way to let the button switch on or off the pump.


         int pinValue = param.asInt();

          if(pinValue == 1) {

            digitalWrite(8, HIGH);
            // This is the value that will be displayed for the pump status in thingspeak API graph.
            pump = 100;

          } else {

            digitalWrite(8, LOW);

            pump = 0;

Have you commented out everything BUT the WIFI connection, does it remain? Then uncomment a few lines of other code. test it, does WiFI remain? Continue to uncomment till issue shows back up. Now you've got an area to ork on.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.