peterhinch / micropython-mqtt

A 'resilient' asynchronous MQTT driver. Recovers from WiFi and broker outages.
MIT License
549 stars 116 forks source link

Wifi never get activated on RP2 W in standalone power (Vsys) #107

Closed felinh closed 1 year ago

felinh commented 1 year ago

Hi Peter, first of all thank you for your great contribution on asyncio and micro python . i have learned a lot with your work. I am running mqtt [micropython-mqtt] on RP2 MicroPython v1.19.1-915-g2bcd88d55 on 2023-03-02; Raspberry Pi Pico W with RP2040

and the RP2 is hosted on this board: https://kitronik.co.uk/products/5329-kitronik-compact-robotics-board-for-raspberry-pi-pico

every thing is working well when RP2 is powered from USB up to the mqtt connection , but when powering RP2 with Vsys (thru kitronik VSYS board), it apprears that

self._sta_if.active(True) is not effective at all (I printed self._sta_if.active() that always return False).

It seems that there is Pin 29 stuff to do , but I did not succeed at all. (I tried pin_29=machine.Pin(29, machine.Pin.OUT, pull=machine.Pin.PULL_DOWN) with no success)

can you help me please (sure it is not mqtt related!)

ebolisa commented 1 year ago

Can you get your hands on that board’s diagrams or trace that line yourself and see where it goes/if it’s shared?

felinh commented 1 year ago

I opened issue on #1610140833 to get the schematics . on their website FAQ: it is said:

peterhinch commented 1 year ago

I am puzzled by this. I performed the following test with a Pico W. I edited main.py thus

import time
time.sleep(4)
import do_connect
do_connect.do_connect()  # A simple connection script

This connects correctly as verified by pinging its IP address (determined previously by running do_connect() at the REPL).

I find it hard to envisage what the Kitronic board can be doing to enable the REPL to work but causing the WiFi to fail. My guess is that it simply isn't providing enough power. WiFi takes significant pulses of power. When I first ran the test I had the bench supply set to 150mA: on connection it tripped this. I then increased it to 300mA and it connected successfully. The mean current is under 50mA but there evidently is a substantial spike.

felinh commented 1 year ago

Hi Peter, you were right. by changing the time.sleep value, I can clearly see a correlation between the time the brightness of the LED of the Kitronic board is decreasing and the time of execution the instruction sta_if.active(True). As the Kitronic primary power (6.8V) is quite well sized because I use it to power some Servo, I suppose it is the internal 5V regulator of the Kitronic that is limited and does not match with the power on sequence of the RP2 Wifi module . As a fix, I did isolated the RP2 VSYS from the Kitronic board , added a schotty and connected to a 5V buck. This is absolutely dirty but it works. Many thanks to you and @ebolisa for the support, I was far to imagine this was the root cause. I hope Kitronic will improve this for the future version of thoses boards. 20230306_105448