ESP8266 doesn't connect to WiFi using WPA2/TKIP

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
zeevro
Posts: 6
Joined: Mon May 09, 2016 8:00 pm
Contact:

ESP8266 doesn't connect to WiFi using WPA2/TKIP

Post by zeevro » Tue May 10, 2016 1:27 am

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.
Last edited by zeevro on Wed May 11, 2016 7:58 am, edited 1 time in total.

zeevro
Posts: 6
Joined: Mon May 09, 2016 8:00 pm
Contact:

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

Post by zeevro » Wed May 11, 2016 7:57 am

No-one has any ideas whatsoever?

User avatar
deshipu
Posts: 1348
Joined: Thu May 28, 2015 5:54 pm

Re: ESP-12F weird WiFi issue

Post by deshipu » Wed May 11, 2016 6:06 pm

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.

zeevro
Posts: 6
Joined: Mon May 09, 2016 8:00 pm
Contact:

Re: ESP-12F weird WiFi issue

Post by zeevro » Wed May 11, 2016 7:40 pm

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?

zeevro
Posts: 6
Joined: Mon May 09, 2016 8:00 pm
Contact:

Re: ESP-12F weird WiFi issue

Post by zeevro » Wed May 11, 2016 8:05 pm

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.

User avatar
deshipu
Posts: 1348
Joined: Thu May 28, 2015 5:54 pm

Re: ESP-12F weird WiFi issue

Post by deshipu » Wed May 11, 2016 10:09 pm

Awesome! Thanks for posting the answer, that may help people with similar problems in the future.

User avatar
platforma
Posts: 258
Joined: Thu May 28, 2015 5:08 pm
Location: Japan

Re: ESP-12F weird WiFi issue

Post by platforma » Thu May 12, 2016 2:19 pm

Might be worth adding this to the FAQ as well.

Post Reply