Page 1 of 1

ESP8266 doesn't connect to WiFi using WPA2/TKIP

Posted: Tue May 10, 2016 1:27 am
by zeevro
This is the module I'm using: http://www.electrodragon.com/product/wi ... d-esp8266/
WiFi Router is MikroTik 951-2n

It connects OK to my android phone's AP, and also to the neighbor's free network. Get's an IP address and all, but when I connect it to my router, it has a weird problem.
My router has two WiFi networks - A WPA2 one and an open one.
When I connect to the open one everything seems OK and the DHCP client works but no packets get in or out of the module.
Looks like this:

[code]>>> w.connect('Public-Internet', '')
f 0, >>> scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 1

connected with Public-Internet, channel 6
dhcp client start...
cnt
ip:10.0.1.200,mask:255.255.255.0,gw:10.0.1.1
pm open,type:2 0

>>> w.isconnected()
True
>>> w.ifconfig()
('10.0.1.200', '255.255.255.0', '10.0.1.1', '10.0.1.1')
>>> import socket
>>> socket.getaddrinfo('google.com', 80)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: -2[/code]


When I connect to the WPA2 network, it doesn't even really connect, even though the router logs a connection attempt:

[code]>>> w.connect('Zeev', 'asdfqwer')
f r0, >>> scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 2
cnt
pm open,type:2 0

>>> w.isconnected()
False
>>> w.ifconfig()
('0.0.0.0', '0.0.0.0', '0.0.0.0', '10.0.1.1')
>>> socket.getaddrinfo('google.com', 80)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: -2
[/code]

Anyone has any ideas? I tried everything. Erased and reflashed several times with --flash_size=32m, changed MTU, channel and encryption settings on the router. I'm stumped.

Thanks for any help.

Re: ESP-12F won't connect to MikroTik 951-2n

Posted: Wed May 11, 2016 7:57 am
by zeevro
No-one has any ideas whatsoever?

Re: ESP-12F weird WiFi issue

Posted: Wed May 11, 2016 6:06 pm
by deshipu
The only idea I have is to try connecting with something that can collect proper logs (a Linux box), to your network and your neighbour's, and then compare the logs to see what the differences are.

Also check the logs on the router side.

Re: ESP-12F weird WiFi issue

Posted: Wed May 11, 2016 7:40 pm
by zeevro
As it turns out, the ESP thinks that both networks are open, even though one of them (Zeev) is WPA2-encrypted:

(b'Zeev', b'L^\x0c#z\xb1', 6, -40, 0, 0)
(b'Public-Internet', b'N^\x0c#z\xb1', 6, -40, 0, 0)

Does this help?

Re: ESP-12F weird WiFi issue

Posted: Wed May 11, 2016 8:05 pm
by zeevro
The problem was my AP supported TKIP as a possible encryption option. TKIP, as it turns out, is obsolete. Turned that off and the ESP works.

Re: ESP-12F weird WiFi issue

Posted: Wed May 11, 2016 10:09 pm
by deshipu
Awesome! Thanks for posting the answer, that may help people with similar problems in the future.

Re: ESP-12F weird WiFi issue

Posted: Thu May 12, 2016 2:19 pm
by platforma
Might be worth adding this to the FAQ as well.