Need help with ESP-01s and Arduino Nano

is there any way (method) to check if connection to wifi is succesfuly established from code?

You can enable debug by use :

#define BLYNK_DEBUG // Optional, this enables lots of prints
#define BLYNK_PRINT Serial

Verify all this points :

Troubleshooting
Connection

If you experience connection problems, follow these steps:

    Check that your hardware, wires, cables and power supply are good quality, not harmed or damaged, etc.
    Use high power USB cables and USB ports.
    Check your wiring using the examples (TCP/HTTP Client or similar) provided with your shield and hardware.
        Once you understand how to manage connection, it’s much easier to use Blynk.
    Try running command telnet blynk-cloud.com 8442 from your PC, connected to the same network as your hardware. You should see something like: Connected to blynk-cloud.com..
    Try running Blynk default examples for your platform without modifications to see if it is working.
        Double-check that you have selected the right example for your connection type and hardware model.
        Our examples come with comments and explanations. Read them carefully.
        Check that your Auth Token is valid (copied from the App and doesn’t contain spaces, etc.)
        If it doesn’t work, try looking into serial debug prints.
    Done! Add your modifications and functionality. Enjoy Blynk!

Note: when you have multiple devices connected to your network, they should all have different MAC and IP addresses. For example, when using 2 Arduino UNO with Ethernet shields, flashing default example to both of them will cause connection problems. You should use manual ethernet configuration example.
WiFi network connection

If you encounter WiFi connection problems, please check these pitfalls:

    You’re trying to connect to “WPA & WPA2 Enterprise” network (often used in offices), and your shield does not support this security method
    Your WiFi network has a login page that requests entering an access token (often used in restaurants)
    Your WiFi network security disallows connecting alien devices completely (MAC filtering, etc)
    There is a firewall running. Default port for hardware connections is 8442. Make sure it’s open.

Can you paste your code here and give your GATEWAY. I think is a problem with your network.

Aklain you did not understand it works i sad this in earlier post.

I asked only if is it possible to check if connection to wifi is succesfuly established from code…

Sorry, I understand that you still have problems.

You can use “Blynk.connected()” like exemple :

if (Blynk.connected()) {
  //do what you want 
}
else {
  //do what you want 
}

You can find all you want in the Blynk documentation :

http://docs.blynk.cc/

No, you do not need to be sorry, you have been very helpfull.

Yes “[4915] Failed to enable MUX” is still there but it works even with that…i am not sure if this is serius problem.

And i still wondering Is there any way that IP,Gateway and Mask can be obtained automatically.

Yes the default is for an ESP to get all the details automatically even when used as a shield for an Arduino Nano.

Costas - and why mine is not capable to do that?

OR how to make it to do it automaticaly?

At home i use actually 4 esp-01 and my DHCP don’t work very well with us (give IP when he want). I think there are problem with some router.

I see that lots of examples are using ESP8266WiFi.h library but i am missing one, i can’t compile.

So what library is that? Who wrote it,where i canfind it? in Arduino library manager the list is long with diferent ESP8266 libraries, which is the right one?

In reference to Blynk Libraries (seeing how this is a Blynk forum :stuck_out_tongue_winking_eye: ) It depends on what hardware you use, and in what configuration…

http://help.blynk.cc/how-to-connect-different-hardware-with-blynk/arduino/esp8266-standalone

http://help.blynk.cc/how-to-connect-different-hardware-with-blynk/arduino/esp8266-with-at-firmware

I like to pick and chose my hardware and connection type in the Sketch Builder and see that Blynk Libraries are used in the examples.

U did not explain too much…

For example i will try to be more specific, on this link:

How to compile example!??
Costas wrote some code…but i can not compile it, Where,HOW, which library for my setup?
ESP8266 - (ESP-01) - Arduino (Nano)?

I answered the specific question you asked… basically “it depends” :stuck_out_tongue_winking_eye:

That particular example is for ESP as a standalone, using actual Blynk library and code (aka firmware) uploaded on the ESP itself. No Arduino.

But when an ESP is used with AT firmware (not Blynk code, just simple AT command code) then it simply acts as a WiFi to serial adapter for the Arduino… and the Arduino runs the Blynk library and code… but a different Blynk library, one that is not compatible with some of the files required for that example; ESP8266WiFi.h library Blynk.connectWiFi() & Blynk.config() commands, etc.

hehe… so that code in example is impossibe torun in my setup…

Ok… so how i can achieve same result as written in this example?
is there any blynk. methods?

Well, I haven’t been following this topic in detail… so start by telling me exactly what you want to accomplish… using the ESP linked to Arduino.

ok. i will try…

To run Blynk.run(); only when wifi connection is established…
Check if wifi connection is established and if not try to establish it manually (with some timeout).
Check if blynk is connected to cloud…

some methods used there:

Blynk.connectWiFi(ssid, pass);
Blynk.config(auth, server, port);
Blynk.connect() ;
Blynk.connected()

For my Mega and ESP-01, I use the following… It may not be perfect, but it works (I think I got it all here… :slight_smile: … very tired :sleeping: )

char auth[] = "xxxxxxxxxx";
char ssid[] = "xxxxxxxxxx";
char pass[] = "xxxxxxxxxx";
//char server[] = "xxx.xxx.xxx.xxx"; // For Local Server
//Blynk.begin(auth, wifi, ssid, pass, server, 8442);  // For Local Server
Blynk.begin(auth, wifi, ssid, pass, "blynk-cloud.com", 8442);  // For Cloud Server
BLYNK_CONNECTED() {
Blynk.syncAll();  // runs whenever Blynk reconnects to server.
}


void loop()
{
  timer.run();
  if (Blynk.connected()) {
    Blynk.run();
  } else {  // if not connected
    reconnectBlynk();
  }
}


void reconnectBlynk() {
  Blynk.connect(60);  // reconnect to server
  if (Blynk.connected()) {
  } else {
    softReset(); // Should? work with most Arduinos.
  }
}


void softReset() {
  asm volatile ("  jmp 0");  // resets Arduino
}

I also tie my Arduino reset pin to the ESP reset… not sure how much that is required… but I do it.

common reconnection to wifi and blynk server with reseting arduino!??

Arduino is executing main program, its not sollution to reset whole program only to establish connection to Wifi and blynk…is there any better way!?

What do you expect? This whole IoT thing is predated by the basic Arduino by a few years or so :wink:

In AT mode the WiFi portion is just a simple WiFi to Serial adapter hacked onto the Arduino brains, so any “Am I connected? What do I do?” process happens in the Arduino.

Of course… use an ESP as a standalone device :stuck_out_tongue_winking_eye: Full control over the Wifi interface and running sketch.


There is always the possibility of other hacking methods… someone just sent a car into space, so anything is possible with enough effort :smiley: But I suspect you have only the two Blynk based choices as mentioned before…


Nappy time for me… :sleeping:

sory but in copy paste indentitation is lost…btw how to copycodehere with indentation?

Blynk - FTFC