First try at a websocket server - Pi Pico W5100S, HTML and javascript

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
Microprofessor
Posts: 5
Joined: Mon Feb 28, 2022 5:56 pm

First try at a websocket server - Pi Pico W5100S, HTML and javascript

Post by Microprofessor » Sat Apr 30, 2022 6:32 pm

Hi all,

I edited this post because I think I took the wrong approach. I though it was going somewhere but no... :(

My goal is to have a web interface to control electronics from a Pico. I would like to do this using HTML, Javascript and websockets. This is my first time using websockets and I could use some help, thanks in advance.

I'm working wih the Wiznet W5100S-EVB-Pico:
Image

My goal:
- Run a server on the Pico
- Serve an HTML interface to control electronics
- Establish a bi-directional websocket connection
- Return real time feedback from the Pi and display it in the interface

Ok, so what I'm about to type might make no sense at all but I'm confused.

I guess the first thing to figure out is what firmware to use and what module(s). If I use the official Pi Pico port from https://micropython.org/download/rp2-pico/ it does not contain usocket? Then there is also the Wiznet firmware: https://github.com/Wiznet/RP2040-HAT-Mi ... n/releases

When I try for example https://github.com/BetaRavener/upy-websocket-server it seems to be using socket and websocket modules that cannot be found.

Also I'm confused about setsockopt wich seems not to be available in some firmware versions?

Could anyone try to explain the concepts behind firmware, modules and what is (not) included ? And maybe give me a hint on how to achieve my goal?

Thanks!

Microprofessor
Posts: 5
Joined: Mon Feb 28, 2022 5:56 pm

Re: First try at a websocket server - Pi Pico W5100S, HTML and javascript

Post by Microprofessor » Mon May 02, 2022 6:18 pm

Ok, I feel like I'm beating a dead horse trying to figure out how to get sockets working on this board. I'm switching to the Arduino IDE and C++

I'm using:
https://github.com/khoih-prog/WebSockets_Generic
https://github.com/khoih-prog/Ethernet_Generic

My questions still stand though, I'm still interested in Micropython builds, modules and maybe one day build my own. Does anyone have any resources with basic info, the concepts, why and how? I really feel like there's a big gap between all the beginner stuff like blinking a LED and the way too advanced stuff. This is not Micropython specific by the way.

Anyway, any hints would be welcome!

Shards
Posts: 39
Joined: Fri Jun 25, 2021 5:14 pm
Location: Milton Keynes, UK

Re: First try at a websocket server - Pi Pico W5100S, HTML and javascript

Post by Shards » Tue May 03, 2022 8:43 am

Alternatively you could use a board / processor that already has ethernet access available. The teensy 4.1 has an optional kit to add an ethernet port and support is available in the Micropython port and it's very straightforward to use. I've set up an FTP server using a standard implementation and it just worked. I'd expect a webserver to be just as straightforward.

The Teensy uses the mimxrt chip, is very fast and the Micropython port is now pretty good. Downside is that it's significantly more expensive than the pico. Upside is that the guys who did the port are very helpful if you do have issues.

If you do want to stick with the pico and python Circuitpython looks like it has a module for the board you mentioned.

Rather than flogging a dead horse it's, perhaps, more a case of horses for courses.

User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

Re: First try at a websocket server - Pi Pico W5100S, HTML and javascript

Post by scruss » Tue May 03, 2022 2:31 pm

Microprofessor wrote:
Sat Apr 30, 2022 6:32 pm
I guess the first thing to figure out is what firmware to use and what module(s). ... Then there is also the Wiznet firmware: https://github.com/Wiznet/RP2040-HAT-Mi ... n/releases
This would be the one to use, as it has the Wiznet driver compiled in.

Do the examples at RP2040-HAT-MicroPython/examples at main · Wiznet/RP2040-HAT-MicroPython not work with this firmware?

Microprofessor
Posts: 5
Joined: Mon Feb 28, 2022 5:56 pm

Re: First try at a websocket server - Pi Pico W5100S, HTML and javascript

Post by Microprofessor » Thu May 05, 2022 7:43 pm

Thanks for the reply's

I'll have a look at the Teensy with ethernet kit. But at the moment I have my Pico with ethernet port onboard so I'm going to focus on that.

@scruss: The Wiznet firmware was my first try but somehow some modules/options are not available (like setsockopt). Sorry I can't be more specific, I was kinda of lost at that point and started looking for other options.

At the moment I have a functional HTTP and websocket server running om the Wiznet W5100S-EVB-Pico, programmed in the Arduino IDE.
(https://forum.arduino.cc/t/wiznet-w5100 ... s/987614/2)

But I,m still curious about the concept of firmware, builds, modules in MicroPython, so general info, links, tutotials etc are still welcome

Lobo-T
Posts: 36
Joined: Tue Nov 16, 2021 2:36 pm

Re: First try at a websocket server - Pi Pico W5100S, HTML and javascript

Post by Lobo-T » Thu May 05, 2022 8:11 pm

Wiznet support for the RP2040 is being worked on: https://github.com/micropython/micropython/pull/8540

Lobo-T
Posts: 36
Joined: Tue Nov 16, 2021 2:36 pm

Re: First try at a websocket server - Pi Pico W5100S, HTML and javascript

Post by Lobo-T » Thu May 05, 2022 8:56 pm

Lobo-T wrote:
Thu May 05, 2022 8:11 pm
Wiznet support for the RP2040 is being worked on: https://github.com/micropython/micropython/pull/8540
Here is firmware compiled for the W5100S-EVB-Pico based on that pull request. If you want to try it out.
https://drive.google.com/file/d/1LVOJ2N ... sp=sharing

Microprofessor
Posts: 5
Joined: Mon Feb 28, 2022 5:56 pm

Re: First try at a websocket server - Pi Pico W5100S, HTML and javascript

Post by Microprofessor » Thu May 05, 2022 9:34 pm

@ Lobo_T: Thanks I'll look into it

Post Reply