Week 10: Networking and Communications


This week, we were assigned to use networking to connect wired or wireless nodes. I decided to use my synthesizer from last week, and let it communicate with my laptop over network. Luckily, my synthesizer already uses the Pico W, which has a WiFi chip, so it made the task easier. I am also a big fan of the MIDI protocol, and I thought it could be fun to implement my own version over a wireless network.

Since my speaker was very quiet in my output week, I decided to use network to send the notes that were played over WiFi to a laptop running a Node.js server. To do so, I started reading into how I could connect the Pico W to my WiFi and started experimenting. It ended up being pretty easy and I got the ball rolling quickly. Then, I decided to use Node.js to set up a UDP socket that could receive the notes from the keyboard. The server was fairly straightforward and quickly enough I managed to let my Pico and laptop communicate over this socket. I now wanted to transmit the notes to another client on my laptop that would run a piano.

I used the JavaScript Piano Keyboard App template to have a quick website running a piano simulation using javascript. I modified the javascript code to receive the triggers from the Node.js websocket rather than the keyboard, and the whole architecture was setup! To summarise, here is the architecture:

Finally, I was able to play over WiFi using my Capacitive Keyboard! I know the video doesn't show it properly, but there the Pico W is only plugged to a wall socket, and communicates with my laptop only over WiFi!

Notes to a future me (learning outcomes):

  • Using websocket with CircuitPython is not trivial, so UDP or TCP sockets are useful.
  • Latency over local network is low enough for music applications!