Need help with ESP-01s and Arduino Nano

Personally I believe this is the fix for router power failure etc.
Fairly straightforward and should be 100% repeatable.
Not something I have much interest in because I prefer ESP8266’s for IOT projects.

@marvin7 do you have the link to the fix by @Gunner ?

The one in this thread? Yea, found that. Read my edits above.

So the last code extract was written by @Gunner, right?

Nope, it was mine, just shared it for comparison :slight_smile:

this is @Gunner’s code:

1 Like

Yes i agree with you,same behavior like mine setup, that’s why i put transistor to switch power on off.

I use blynk 0.5.0 i did not know there is new version,in mean time i will download 0.5.1version and i will check if they change sthing in code and test it.

marvin7 the problem with disconnect is in conn.disconnect(); in BlynkProtocol.h…

For the Gunner code its ok, but i refuse to use blynk.timer because it messes up the timer interrupts which i use in my original code(i check connection manually if some time is passed) another thing for me is not an option to reset arduino together with ESP…the turning only power on ESP (from code) on/of shows better results than resseting only.

I checked thy did not change anything,in this particular case same results,same functions and methods,and sizes of files.

Still works for me if things are set Static,not with DHCP enabled.

I can confirm that Blynk.begin method in this particular setup is not effective and ralible,
mainly because this line while(this->connect() != true) {} because makers use some strange and dirty ways which emulates semaphore programming but for this case and setup not particulary effective. It could be changed but i do not prefer that solution.

Even if Blynk.connectWiFi function calls “AT+CWJAP=” by default and not “AT+CWJAP_DEF=” AT command, it seems that ESP module remembers last joined ap, so on reconnect(power on/off,reset or reboot) it actually trys automatically to connect to the last WiFi network, and sometimes it sucessfully does connect to the last WiFi and then there is problem with Blynk.connectWiFi which trys to connect as already connected and then function wifi->joinAP(ssid, pass) returns False and exites and therefore there is no further execution of code since Blynk.connectWiFi also returns False.

To avoid that i aded this little piece of code in BlynkSimpleShieldEsp8266_h, class BlynkWifi in the beginning of function
bool connectWiFi(const char* ssid, const char* pass)
after BlynkDelay(500);
and rate of succesfully established connections very significally increases.

It is not perfect but it serves its purpose.

now it looks like this:

    bool connectWiFi(const char* ssid, const char* pass)
    {
        BlynkDelay(500);
		
		if(wifi->leaveAP()){ 
			BLYNK_LOG1(BLYNK_F("Disconnect from previous Wifi AP"));
			BlynkDelay(500);
		}
            ...
            ...
1 Like

You did a lot of hard work, analyzing Blynk library code, and you had found a lot more code traps than me. I need to thank you for pointing out the “unattended reconnect after reboot” issue, which I had noticed, but had not dig into code to pinpoint it. :smiley:
Your issue though, seems to be more related to ESP core, than Blynk library in its part where it handles “shield connection”. Have you tried with most recent AT firmware from ESP. Last month when I checked it was 2.1 (or similar, but it is above 2.0 for sure). For me it wasn’t working with Blynk, but as I’m using it in only one test-assembled device, so decided to stick with 1.5.4.
Good luck, I’m watching your attempts closely.

No need to thanks marvin7,as i seen nobody on forum digs in libraries and writes experience, because its pointless because there are developers to do that, but since this is obscure way to connect 2 things which are not ment to be paired (ESP + Arduino)…and another thing is (by my point of view) here are lots of youngsters or just people who wants quick answers like i wanted in the beginnig…

But i had to thoroughly check things inside by myself and as i dig,more things become more unknown to me…

I could just listen to Costas and Gunner and throw all this in garbage and start again completely with another bigger ESP-s or ESP32…

But i just do not want to quit it,but probably it would bethesmart thing to do…

Marvin7 if you can test my setup in your place on another the router and with enabled DHCP on ESP we could eliminate or determinate where is the problem specially if you experience same problems like me.

Yes @Nixon, I will try your code (in it’s part responsible for connection). But to be sure: Your AT firmware version is 1.5.4 or different? And I gonna test it on Blynk 0.5.1 as pointed earlier.

Bite your tongue :open_mouth: I still actively use and like this combo!! :slight_smile: … I just don’t try to turn it into something it is not…

As for @Costas… I think he would dance around the bonfire that burns all old arduinos and ESP-01s :rofl:

Bonkers :slight_smile:

It’s not a system for IOT :slight_smile:

Got the lighter fuel ready :slight_smile:

If you MUST use these 2 MCU’s together do the right thing and flip it on it’s head. Connect the Arduino to the ESP not the ESP to Arduino and then you have a real IOT system. Tried it, wasn’t bad but not as good as a WeMos.

3 Likes

I must admit @Costas, you’re right. But still: I have a bunch of different ESP’s (not ESP32) but made a setup composed just of an old Atmega32 and ESP-01. It is not a “production” device. Just a test setup - mostly a toy, although still providing useful information for my “IOT ecosystem”

@marvin7 ESP with Arduino bridge or the wrong way as Arduino with ESP bridge?

Of course the wrong way! :smile:

2 Likes

Any way, if i do it like that i need to establish some kind of communication between esp01 and arduino and that would be i2c communication and i am back on beginning but just with another interface…this option could be even the worse and real nightmare…

And i just get used to Arduino in my projects and i must admit i like it…before i was working with pic microcontrollers and that was real nightmare assembler + C…
And when i say get used to Arduino i meant learn its internal structure and behavior of Atmel microcontrollers.
:sob::scream::scream:
So i really do not know what to expect from bigger NodeMCU or ESP32…

With “my” way you just run the Arduino as an Arduino and send over the important stuff to ESP to interface with Blynk.

1 Like

For sanity of your own mind - for now keep away from ESP32.

Through serial interface for example (no need to involve I2C, though it is possible)… I think It would be much more stable then shield composition… But… but…but… and again: BUT. :wink:

Yes I used serial and it was rock solid.