How to use the WiFi on the PyBoard

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
Peugot206
Posts: 31
Joined: Sat Apr 09, 2022 5:57 pm

How to use the WiFi on the PyBoard

Post by Peugot206 » Sat Apr 09, 2022 7:23 pm

Hi community,

How can I use the WiFi for the PyBoard SF2. The documentation seems outdated for this board which is a big bummer for me: https://docs.micropython.org/en/latest/ ... ckref.html, or am I just looking at the wrong place here? Could anyone provide me an example code?

I tried the network code for the ESP32, but as I thought (logically) it does not work for the PyBoard.

Any help is welcome :)

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: How to use the WiFi on the PyBoard

Post by dhylands » Sun Apr 10, 2022 3:51 am

I found an old forum post when the Pyboard first came out that referenced this site:https://pybd.io/hw/pybd_sfxw.html#wifi-control and that seems to be the same as the WLAN documentation: https://docs.micropython.org/en/latest/ ... .WLAN.html

Peugot206
Posts: 31
Joined: Sat Apr 09, 2022 5:57 pm

Re: How to use the WiFi on the PyBoard

Post by Peugot206 » Sun Apr 10, 2022 9:54 am

dhylands wrote:
Sun Apr 10, 2022 3:51 am
I found an old forum post when the Pyboard first came out that referenced this site:https://pybd.io/hw/pybd_sfxw.html#wifi-control and that seems to be the same as the WLAN documentation: https://docs.micropython.org/en/latest/ ... .WLAN.html
Thank you! Now I can connect to a network, awesome.

Now the next part.. how can I make (GET, POST) requests? The 'urequest' module doesn't seem to work on the PyBoard. Next to requests I would also like to try websockets. Do you have any idea on how to do this for the PyBoard?

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: How to use the WiFi on the PyBoard

Post by dhylands » Sun Apr 10, 2022 8:43 pm

I'm actually trying to do exactly the same thing.

You can find urequests.py here: https://github.com/micropython/micropyt ... equests.py

So checkout the micropython-lib repository: https://github.com/micropython/micropython-lib/

and set an environment variable MPY_LIB_DIR to point to the micropython-lib directory.

Then go into the micropython/ports/stm32/boards/PYBD_SF2 and edit manifest.py and add this line to the end:

Code: Select all

freeze("$(MPY_LIB_DIR)/python-ecosys/urequests", "urequests.py")
and if you rebuild micropython, it will have urequests.py builtin as a frozen module.

Alternatively, you could just copy urequests.py onto your pyboard.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: How to use the WiFi on the PyBoard

Post by dhylands » Tue Apr 12, 2022 5:56 am

I got picoweb running on my pyboard D and I put all of the files together over here: https://github.com/dhylands/picoweb

Post Reply