Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WiFi connect not working; continuous state: 0 -> 2 (b0) and reconnect #4

Open
evaluationevaluation opened this issue Jan 17, 2018 · 8 comments

Comments

@evaluationevaluation
Copy link

Hi,

I would likt to test your precompiled images on my "Wemos D1 mini". Flashing the 2 images and the one with the credentials work fine and Wemos boots. Serial console shows log @ 115200 baud but it seems that connecting to the WiFi access point (Fritz Box 7390; WPA/WPA2) does not work.
Access point is near and SSID is found. Channel = 1
Password has been provided correctly. I tried many variations of SSID and PW, also very simple with only normal and few characters. I also tried to change AP mode from WPA(TKIP) to WPA/WPA2 to WPA2(CCMP).

Do you have any suggestion?

Thanks in advance
Eva

My usual code to connect to WiFi is like this. Your code seem to behave differently...
WiFi.mode(WIFI_STA);
// IPAddress gateway(192, 168, 0, xx); // set gateway to match your network
// Serial.print(F("Setting static ip to : "));
// Serial.println(ip);
// IPAddress subnet(255, 255, 255, 0); // set subnet mask to match your network
// WiFi.config(ip, gateway, subnet);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(1000);
}
ip = WiFi.localIP();

Log:
f 0, scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
reconnect
state: 3 -> 0 (0)
f 0, scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
reconnect
state: 3 -> 0 (0)
f 0, scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
reconnect
state: 3 -> 0 (0)
f 0, scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
reconnect
state: 3 -> 0 (0)
f 0, scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 2 (2a0)
reconnect
state: 2 -> 0 (0)
f 0, scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 2 (2a0)
reconnect
state: 2 -> 0 (0)
f 0, scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 2 (2a0)
reconnect

@evaluationevaluation
Copy link
Author

Connection works with the access point of a second Wemos ESP module. So it is a compatibility issue between the espple image and the Fritz Box access point.

It would be great to slighty change the connection code to be able to connect to Fritz Box access points, too.
In the meanwhile I try to find an access point with routing functionality so that I can connect via telnet to espple...

f 0, scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 2
pm open phy_2,type:2 0 0
cnt
chg_B:-60

connected with Wemos_AP, channel 1
dhcp client start...
chg_B:-120
ip:192.168.4.3,mask:255.255.255.0,gw:192.168.4.1

@hrvach
Copy link
Owner

hrvach commented Jan 18, 2018

Thanks for the feedback and interest, it makes me very happy to see people are experimenting with it.

I had no way of testing it with various access points. Fritz Box has a stellar reputation in the telecom world and I only heard positive things from colleagues about it.

If I manage to borrow one, I'll try to test connectivity and patch any errors I can find. Please keep in mind I'm not very experienced with ESP8266, this is my first project with it but I'll do my best.

There are other people mentioning problems with Fritz <---> esp8266 connection too:

esp8266/esp8266-wiki#66

@evaluationevaluation
Copy link
Author

Hi,

thank you very much for taking my topic into consideration.
I think that my code fragment should/could work also in your environment. So perhaps you give it a try.
Unfortunately I'm completely unfamiliar with the preconditions of compiling the whole thing by myself.
(I usually code in the Arduino IDE, don't know if it is possible to compile your project there?)

Perhaps you can find some time to create an image with my connection code and I will test it immediately here.

Thanks in advance
Eva

@hrvach
Copy link
Owner

hrvach commented Jan 19, 2018

I'm not sure how the Arduino code could fit here easily, but I've decided to try and reduce RAM usage and attempt compiling the project with a newer SDK. Hopefully this would resolve the wi-fi connectivity issues, as well as make it easier for people compile it themselves.

My free time isn't what it used to be, but I'll try to make it work better and resolve some of the issues you are seeing. Please check the repository again in a few days. 👍

@evaluationevaluation
Copy link
Author

Hi,

I found out why espple did not connect to by FRITZBOX.
It is this line of code in user_init:
wifi_set_phy_mode(PHY_MODE_11B);
This seem to force ESP to use 802.11B mode and I deactivated this old mode some years ago.
Don't know if the connection can be tried with all possible modes available (802.11b/g/n) instead of only mode B? Perhaps you simply need to remove this line?!
For testing purposes I reactivated this mode on my FRITZBOX and now I can connect via telnet and see a blinking AT-Sign.

// some time later
IT WORKS :-)
WiFi is very instable and telnet connection very slow but I managed to type in the first BASIC program for years (or tens of years?).

Thank you for this "nostalgic experience".

Greetings
Eva

@hrvach
Copy link
Owner

hrvach commented Jan 21, 2018

I went this 802.11b road because I've found few recommendations online from other esp8266 users about it being the best choice for long range and stability - I'm really sorry this ended up being a problem for you.

I would be much happier if wi-fi worked better, but I haven't been able to figure out why it's so jittery and has some packet loss. I've tried several SDK versions and all behaved pretty much the same. Maybe it's some option or a known ESP bug I have yet to find out about.

Thanks for all the feedback, now I'm waiting to see some cool BASIC program you wrote! 👍

@evaluationevaluation
Copy link
Author

Perhaps you should give the other modes a try. The stability I see with the other modes is much more stable then the one with B. I have half a dozend ESP modules working in my house (2 floors, 2 different APs, some of them are providing own APs while others do connect to the main access points in order to transfer data). And as I did deactivate 802.11B they must have connected with G or N. Never had problems with that.
But all my ESPs are programmed using Arduino IDE - don't know if this can be compared to your approach with the espressif framework. And of course espple has also to do much work for providing the analog TV transmission...

Just one more question from my side:
Is it possible to prepare BASIC programs outside the ESP (using Windows/Linux) and upload them via tftp to the ESP and then just run them?

Greetings and wish you and all others much fun with espple
Eva

@hrvach
Copy link
Owner

hrvach commented Jan 24, 2018

I'll try testing a little more how 802.11b vs g work, it connects faster when 802.11b is selected on my Linksys with OpenWrt. I agree it should be optional. Although the source is provided, it's not very convenient having to recompile to change modes, so it should be a configuration option instead of a hardcoded one.

As far as uploading BASIC programs, there is currently no way to do this, but I have an idea how this could be implemented easily and will have to test first before making any promises :)

Once again, I wish to thank you for your feedback and suggestions. Seeing people want to play with it makes me think all those hours didn't go to waste. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants