Realiable WiFi using PYBD

The official PYBD running MicroPython, and its accessories.
Target audience: Users with a PYBD
Post Reply
Posts: 4
Joined: Thu Jul 25, 2019 9:48 pm

Realiable WiFi using PYBD

Post by agners » Thu Jul 25, 2019 10:24 pm

Hi MicroPython community,

First, thanks for making something awesome as MicroPython happen! It really makes my software engineer heart really warm and cozy!

I use my SF2W since some weeks to log data to a MQTT server. This works nice and rather reliably. However, when my WiFi disappears my Python script gets stuck and remains so after connecting. I tried to make it more reliable, but was not really able to.

I tried with something like this in my main loop:

if not wl.isconnected():
while not wl.isconnected():

However, from what I can see wl.isconnected() never gets True in those situation.

Enabling tracing seems to indicate that the lower layer connects, but it seems not to be reflected on the Python API:

[ 884015] ASYNC(0000,32,0,0,0)
[ 884018] ASYNC(0000,ASSOC_REQ_IE,0,0,0)
[ 884018] ASYNC(0000,AUTH,0,0,0)
[ 884040] ASYNC(0000,ASSOC_RESP_IE,0,0,0)
[ 884040] ASYNC(0000,9,0,0,0)
[ 884040] ASYNC(0001,LINK,0,0,0)
[ 884049] ASYNC(0000,PSK_SUP,6,0,0)
[ 884114] ASYNC(0000,JOIN,0,0,0)
[ 884115] ASYNC(0000,125,0,0,0)

>>> wl.status()
>>> [ 888723] ETHRX len=152 dst=... src=.... type=IPv4 srcip=.... dstip=..

>>> wl.isconnected()

I also found this which claims that PYBD should automatically reconnect: ... /pyboard_d

This seems not true/have issues?

Banner says I am using:
MicroPython v1.10-445-ga9b1d3ca3 on 2019-05-29; PYBD_SF2W with STM32F722IEK

Which I think is the latest version? (at least banner did not change after reflashing some minutes ago. But *please* add version information to the PYBD builds in your downloads section...)

Best regards,

User avatar
Posts: 4345
Joined: Fri Jul 18, 2014 8:01 am
Location: UK

Re: Realiable WiFi using PYBD

Post by pythoncoder » Fri Jul 26, 2019 5:17 pm

There are two issues here. Firstly there is this Pyboard D issue which is still outstanding.
tl;dr the Pyboard D can get into a state where a connection is lost and can only be regained by a reset. This is a bug which will doubtless be fixed.

You haven't said what library you are using for MQTT. The official library responds badly to WiFi outages (regardless of platform). The general issues are discussed here.

There is a resilient MQTT implementation here.
Peter Hinch

Post Reply