ESP is not responding after adding wifimanager

i was having arduino mega connected with esp8266 module and i had successfully uploaded the sketch by IDE software on the mega and the relays were working properly from the blynk app on mobile, but after some times, the esp8266 lost connectivity and i have to restart the power for the mega to get it back connected again, so i decided to install wifimanager but i was not able while connecting it to arduino mega so i put the sketch on the esp8266 itself standalone and after installing the libraries needed, but when i plug the esp8266 back again on the mega (which has it own sketch uploaded and was working before unplugging the esp8266) and try to connect with blynk app it doesn’t work, and on the serial monitor it said:
[1527] ESP is not responding
AT+CIPCLOSE=1
AT+CIPCLOSE=1
AT+CIPSTART=1,“TCP”,“blynk-cloud.com”,80

so i think i did something wrong, can i install a program in the esp8266 then connect it to mega (which has its own program) so i can get use of both, normal program of mega for my lights synced with blynk app + wifimanager installed on the esp8266?

sorry for the long story but am still new in the IOT and do not know exactly what to do, i have been trying for more than 4 hours without any clue.

For the ESP-01 to successfully act as a Wi-Fi modem for the Arduino, it has to be running the factory ‘AT’ firmware.
You’ve overwritten this firmware with your WifiManager sketch, so to get it working again you’ll need to download a new copy of the factory firmware and upload it. I don’t think this can be done with the Arduino IDE, but a bit of googling should show you how.

WiFiManager doesn’t work with the ESP-01/Arduino combination.
Also, WiFiManager won’t solve connectivity problems, it’s a method of allowing you to enter different Wi-Fi credentials without having to re-flash the device with new code that has hard-coded credentials.

Your connection issues are probably caused by badly written code.

If you’re new to IOT you might find it easier to start with a different type of board, especially if you do have a need for WiFiManager…

Pete.

1 Like

Thank you PereKnight for your reply, i have reviewed your post about which board and it is really good, which made me to be sure that mega is the best choice for me, as i am planning to make a new home and i need alot of I/O pins to be able to control most of the devices in my new home.
So coming back to my issue for now, i will search for factory firmware to upload it so i can come back to my first status (mega+esp8266) working on wifi.
but regarding connection issues, i put a very simple code from IDE examples for blynk libraries, but how i can solve this later + adding the feature of re connecting to wifi if lost connectivity and entering deifferent wifi credentials?
is it by making a new sketch that can do this?
at the end i need a reliable & stable system to be attached in my new home without connectivity issues and taking all devices in consideration.

Thank you so much for your helpful reply, and here you can find my code below.

#define BLYNK_PRINT Serial

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

char auth[] = "********";

char ssid[] = "Ayman33";
char pass[] = "braveheart333";

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

// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200

ESP8266 wifi(&EspSerial);

WidgetLED led1(V1);

BlynkTimer timer;

// V1 LED Widget is blinking
void blinkLedWidget()
{
  if (led1.getValue()) {
    led1.off();
    Serial.println("LED on V1: off");
  } else {
    led1.on();
    Serial.println("LED on V1: on");
  }
}

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

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

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

  timer.setInterval(1000L, blinkLedWidget);
}

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

@Aymanokail 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:
```

Pete.

done

You’re using the same serial port for both debug output and communication with your ESP-01
You can’t do this.

You should use one of the Mega’s other serial ports for connecting your ESP-01

I’d doubt very much if that is the case. Having everything connected into a single centralised board is not normally a good topology.
Also, if you were going to take this approach then an ESP32 or an ESP8266 with a port expander is a much better board to use.

Having said that, I think whole house home automation systems are best based around a Node-Red system using Blynk as a plug-in, but you need to make the right choices for your specific needs.

Pete.

1 Like

you are my hero :smiley: it worked , i flashed the ESP8266 with firmware and connected it again to the arduino mega and changed the serial for the ESP to serial1 and after it is connected to wifi and my relays were working, i plugged off my wifi router and plugged it on again, then the esp is connected automatically.

Last thing, is there is any way to include a hard coding in my sketch to allow the ESP to act as an access point if it is not able to connect the wifi credentials mentioned in the sketch after 3 trials for example, so to allow me to login on the ESP and change it and after i save it rebot automatic (same function of WIFIManager but hard coded)?

and Regarding the nodeMCU, do you think that it is better than the arduino mega which worth having 2 boards nodeMCU connected together (to have more I/O pins) instead of 1 mega for example?

No, the ESP is simply acting as a Wi-Fi modem, not an access point serving-up a web config portal.

No, don’t go down the route of physically connecting two ESPs.
Either use an ESP32 or a port expander on the NodeMCU. The ESP32 is the easier solution.

Pete.

ok thank you bro, since last post it was working good, but now i found the blynk is offline and i had to restart power for my mega board to connect again, now i have same problem as before, i thought it was solved but apparently not yet, do u have any clue why it didn’t connect automatically again? totally depressed for this issue and do not know why it is offline again.

i tried to enhance my sketch as shown below (am afraid that i made the opposite :upside_down_face:), but i sometimes get the below message in serial monitor for example when i change the RGB color from the Blynk app on mobile.

[29394] Buffer overflow

and here is the code

#define BLYNK_PRINT Serial // Enables Serial Monitor

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

char auth[] = "********";
char ssid[] = "Ayman33";
char pass[] = "braveheart333";

#define EspSerial Serial1
#define ESP8266_BAUD 115200
ESP8266 wifi(&EspSerial);


BlynkTimer timer;

void myTimerEvent()
{
  Blynk.virtualWrite(V5, millis() / 1000);
}


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

  Blynk.begin(auth, wifi, ssid, pass);
  timer.setInterval(1000L, myTimerEvent);

}

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

Try reducing this to 9600 and changing your IDE serial monitor to the same.

What version of the Blynk library are you using? This prints in the serial monitor below the large Blynk logo.

Reconnect routines are much harder to implement when using an ESP-01 as s Wi-Fi modem, as you don’t have access to the native Wi-Fi library. Another reason to choose better hardware.
Try searching the forum for reconnect routines for Arduino and ESP-01.

Pete

i tried 9600 but also the same happens
you can find the version of Blynk shown below

i will give this a search on google on the reconnect routines, anyway i went today to the market and i bought ESP32 & ESP8266 (nodemcu)
i need to finalize the mega issue first to keep it at current home for the moment for test, then i will start to check the new pieces.

[610] Connecting to Ayman33
[3658] AT version:1.1.0.0(May 11 2016 18:09:56)
SDK version:1.5.4(baaeaebb)
Ai-Thinker Technology Co. Ltd.
Jun 13 2016 11:29:20
OK

That’s not the Blynk version, it’s the firmware version for the ESP-01.

The Blynk version is show at the bottom of the logo like this:

    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ vx.x.x on [Board Type]

Pete.

ah sorry for that
here you are V0.6.1

Blynk version

1 Like

thank you PeteKnight for your help above, i just want to know how i can control RGB led with the zeRGBa button in Blynk app as i find only virtual pins when i choose ESP32 device in the app (not the same like arduino mega where i was able to choose directly the GPIO number or digital I/O), so i think i need to add it in the sketch but i have no idea how to do it, can u help me with a sketch suggestion for such issue.

Yes, when the value of a virtual pin changes it triggers the BLYNK_WRITE(vPin) function.
You then use the param.asInt() or param.asFloat() function to extract the value or array of values from the widget.
You can then write these values directly or transform them as you wish, to GPIOs using digital.Write or analog.Write commands.
Don’t forget to include pinMode declarations for these GPIOs in your void setup.

Blynk.syncVirtual(vPin) can be used to force the server to send the latest virtual pin values, and these can be triggered each time the device connects or reconnects to the server using the BLYNK_CONNECTED() function.

This sounds complicated, but believe me, you wouldn’t get such good results using digital pin manipulation.

There are many examples of how to achieve what you’re looking for in the forum. Just take care not to exceed the rated current values of your board when driving RGB LEDs.

Pete.

Regarding the rated current, am only using 1 rgb led then after i setup everything properly i will install transistors and relays to connect external 12v strip light, so for the wiring it is ok for me as i am mainly electrical engineer, but the only problem is that am not so good in writing codes in blynk with c++
So can you help me by providing this sketch for me or tell me what exactly i should search for in the forums here to achieve that as am trying since yesterday to search for it but with no good results

I’m not going to write your code for you.
If you search for zeRGBa and RGB LEDs then you’ll find lots to be getting on with.
You are okay using a single RGB LED directly, but you should use MOSFETs to if you plan to use RGB strips.
I like the IRLB8721 as it has a suitable gate thresh voltage.

If you use code that is written for the Arduino then beware that the Arduino’s PWM output is only capable of 255 levels, whereas the ESP devices can output 1023 levels. This means that if you do an analogWrite of 255 on an ESP then you’ll only be getting 1/4 brightness so adjust the code to use 1023 as the maximum.

This is the design I was using in the past:

Although I now use these:

Pete.

First am very sorry for annoying you everytime with my noob messages,
Second very big thank you for your real support
Third i finally succeeded after some searches to make it work fine with zeRGBa
here the code worked for me
if you see something can be improved please let me know if possible
i was wondering if i can put 1 button to make the RGB totally on or off, then if it is on, so i can control the colors through zeRGBa, i will search for this i think it is possible and i will try it.

regarding the IRLB8721 if i understand correctly, i will use three MOSFETs and connect their 3 gates with three PWM GPIO of the ESP32 for the control of 12V RGB Strip light (and accordingly drains connected to the led and source connected to negative of the 12V supply), the wiring is ok like this i think

i really appreciate so much your help, do not know what i would do without your help.

#define BLYNK_PRINT Serial
//#define BLYNK_PRINT Serial // This prints to Serial Monitor

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

#include <ESPmDNS.h>  // For OTA - ESP32
#include <WiFiUdp.h>  // For OTA
#include <ArduinoOTA.h>  // For OTA

#include "esp32-hal-ledc.h" // For Servo & RGB PWM control


char auth[] = "*******";
char ssid[] = "Ayman33";
char pass[] = "braveheart333";
char server[] = "blynk-cloud.com";  // URL for Blynk Cloud Server
int port = 8080;

int rrr, ggg, bbb;  // Set RED BLUE GREEN channe

BlynkTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, millis() / 1000);
}

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

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

  // Setup a function to be called every second
  timer.setInterval(1000L, myTimerEvent);
   //Serial.begin(115200);  // BLYNK_PRINT data

   //===== RGB LED pin setup for ESP32 =====
  ledcSetup(2, 5000, 8); // For RGB-Red - channel 2, 5000 Hz, 8-bit width
  ledcAttachPin(25, 2);   // For RGB-Red - GPIO 25 assigned to channel 2

  ledcSetup(3, 5000, 8); // For RGB-Green - channel 3, 5000 Hz, 8-bit width
  ledcAttachPin(27, 3);   // For RGB-Green - GPIO 27 assigned to channel 3

  ledcSetup(4, 5000, 8); // For RGB-Blue - channel 4, 5000 Hz, 8-bit width
  ledcAttachPin(26, 4);   // For RGB-Blue - GPIO 26 assigned to channel 4

  WiFi.begin(ssid, pass);
  Blynk.config(auth, server, port);
  Blynk.connect();

  ArduinoOTA.setHostname("ESP32 Servo RGB");  // For OTA - Use your own device identifying name
  ArduinoOTA.begin();  // For OTA
}

//===== zeRGBa Widget =====
BLYNK_WRITE(V4) { // START Blynk Function
  rrr = param[0].asInt(); // get a RED channel value
  ggg = param[1].asInt(); // get a GREEN channel value
  bbb = param[2].asInt(); // get a BLUE channel value
  RGBprocess(); // Run Arduino funtion
}  // END Blynk Function

//===== Physical RGB LED Control and HEX conversion =====
void RGBprocess() {  // START Arduino funtion

  // For Common Anode+ RGB LED
  //ledcWrite(2, 256 - rrr); // Write to RED RGB pin
 // ledcWrite(3, 256 - ggg); // Write to GREEN RGB pin
  //ledcWrite(4, 256 - bbb); // Write to BLUE RGB pin

  // For Common Cathode- RGB LED
  ledcWrite(2, rrr); // Write to RED RGB pin
  ledcWrite(3, ggg); // Write to GREEN RGB pin
  ledcWrite(4, bbb); // Write to BLUE RGB pin

  // zeRGBa pin to #HEX conversion
  String strRED = String(rrr, HEX);  // Convert RED DEC to HEX
  if (rrr < 16) {
    strRED = String("0" + strRED);  // Buffer with 0 if required
  }  // END if
  String strGRN = String(ggg, HEX);  // Convert GREEN DEC to HEX
  if (ggg < 16)  {
    strGRN = String("0" + strGRN);  // Buffer with 0 if required
  }  // END if
  String strBLU = String(bbb, HEX);  // Convert BLUE DEC to HEX
  if (bbb < 16)  {
    strBLU = String("0" + strBLU);  // Buffer with 0 if required
  }  // END if
  String HEXstring = String("#" + strRED + strGRN + strBLU);  // Combine HEX fragments
  HEXstring.toUpperCase();  // Change HEX value to all upper case for ease of visuals.
  Blynk.setProperty(V3, "color", HEXstring);  // Change background colour of HEX Data Label
  Blynk.virtualWrite(V3, HEXstring);  // Display HEX data
}  // END Arduino Function

void loop()
{
  Blynk.run();
  ArduinoOTA.handle();  // For OTA
  timer.run(); // Initiates BlynkTimer
}

I’m not familiar with the ledcSetup or ledcAttachPin commands, so I can’t really comment on this, but if it works for you then stick with it.

Add a button widget in Switch mode and attach it to a virtual pin (lets say pin V1). This code will be triggered when the switch is operated and will either use the zeRGBa RGB values if the switch is On, or set RGB to 0 if its off…

BLYNK_WRITE(V1)
{
  int switch_value = param.asInt();

  if (switch_value)
  {
    Blynk.syncVirtual(V4); // Get the current RGB values from the zeRGBa widget
  }
  else
  {  
    rrr = 0;
    ggg = 0;
    bbb = 0;
    RGBprocess(); // process the RGB change    
  }
}

The circuit is explained in the Adafruit tutorial, which is a link from one of the topics I linked to earlier.

Pete.