6.9020 HTMAA Week 12

[group work looks like this!]



OUTPUT

Networking with WiFi

In Week 11 (Machine Week) my group used a Flask server to network together our robot's esp32 camera with the python scripts that were performing object recognition and computing drive commands. Since my final project plans to use a Pico W (which can also connect to WiFi like the ESP), I imagined that using a similar server to visualize walk data once the device is connected to WiFi.

PCB Design Notes

For this week's project, I am using the same PCB I designed in Week 8, which corresponds to the "lower device" of my Final Project. I also plan to build on the technique I have worked on previously of writing walk data to the flash memory of the Pico W, and then dumping that data somewhere else at the conclusion of the walk.

The utility of networking over WiFi in this case is that it improves over my previous solution of dumping out walk data into the Serial Monitor, but rather allows me to receive it through a web server and visualize it on a site all at once. The interface for this will be further developed next week.

Writing to Web

Creating a system to write data from my Pico to a website required a three-part assembly of software:

[1]

First, the Pico W needs a sketch that tells it what WiFi network to look for and what server to "POST" information to. Importantly, the IP address of the server needs to be the local address of the laptop.

[2]

Second, the laptop needs to actually be running that server. This requires setting up a short Python script that spins up an endpoint on WiFi that can receive data from the Pico. I used Flask to do this, and I initialized the server from my terminal.

[3]

Finally, there needs to be some hosted webpage that can display the information being transmitted across the server.

Setup

I first used the linked demo to write a sketch that would connect my Pico W to my local WiFi network and confirm that it was connected to the right place. Then, I used the Arduino HTTPClient library to add code that would connect to my server: Then, I set up a really simple Flask server with the help of ChatGPT and ran it from my terminal. Here are the commands to do that: My Flask server is running from a separate folder, where the endpoint to display the information also is located (inside another folder called "templates"). Finally, I set up this visualization station as a basic HTML page: "WalkMap".

With the Flask server running and the sketch flashed to the Pico, I was able to see POST output from both the Pico and the Server. Here is the working output from the Pico, via Serial: And here is what the Flask output showed in Terminal: And finally the test output online:



The next step here is to merge in my GPS code so that when I press my button, it records coordinates, writes them to flash memory, and then dumps them to the server on a loop that checks whether WiFi is connected.

Asynchronous Testing

Trials and Tribulations

Following are some observations of the process this week, and some challenges or disappointments to record:

Learnings and Progress

Below is the delta between where I started on the skills for this week and where I arrived:

Resources and Acknowledgments

I found this Pico W WiFi tutorial by Drone Bot Workshop extremely helpful. As the tutorial acknowledges, most of the available references for Pico W use micropython, so I highly recommend the previous reference for those writing in C++. For a more standard micropython reference, the Raspberry Pi official demo is also useful.

Being still new to the conceptual framework of a web server, I also had some useful conversations with ChatGPT about setup and the general function of this framework.

Design Files