Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 1.4-hardware-software-communication.md with workaround links #73

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ In this tutorial, you will learn how to send commands to and receive sensor data

In an earlier module (blink and read), you learned how to blink the onboard LED every two seconds. In this section, you will control the onboard LED using MQTT, a standard protocol for internet-of-things communication. By definition, hardware/software communication implies that you are interfacing multiple devices (in this case, your microcontroller and a Jupyter notebook running on e.g., Google Colab). Let's start with a hands-on example.

✅ Create a new file on your Pico W microcontroller called `mqtt_led.py` and copy the script below (based on [JayPalm's gist](https://gist.github.com/JayPalm/8bfd836b696c28ec5dc1f6b5b4dd18ea) and [`mqtt_as` README](https://github.com/peterhinch/micropython-mqtt/blob/master/mqtt_as/README.md)). Ensure that your microcontroller has been set up according to the instructions in the "Running the demo" module earlier in the course (only [`netman.py`](https://github.com/sparks-baird/self-driving-lab-demo/blob/main/src/public_mqtt_sdl_demo/lib/netman.py) [[permalink](https://github.com/sparks-baird/self-driving-lab-demo/blob/0ff0adec3e997c096990de594844d73a9ce18fd6/src/public_mqtt_sdl_demo/lib/netman.py)] and an appropriately filled-out `my_secrets.py` are required). You will also need to upload the [`mqtt_as.py` module](https://github.com/peterhinch/micropython-mqtt/blob/master/mqtt_as/mqtt_as.py) to either the main directory or the `lib` folder. Make sure to replace `<your_id_here>` with your course ID (without the brackets). If you've forgotten your GitHub Classroom course ID, you can refer back to your quiz responses from the GitHub starter tutorial assignment. Once you've updated the file, save the file and click play.
✅ Create a new file on your Pico W microcontroller called `mqtt_led.py` and copy the script below (based on [JayPalm's gist](https://gist.github.com/JayPalm/8bfd836b696c28ec5dc1f6b5b4dd18ea) and [`mqtt_as` README](https://github.com/peterhinch/micropython-mqtt/blob/master/README.md)). Ensure that your microcontroller has been set up according to the instructions in the "Running the demo" module earlier in the course (only [`netman.py`](https://github.com/sparks-baird/self-driving-lab-demo/blob/main/src/public_mqtt_sdl_demo/lib/netman.py) [[permalink](https://github.com/sparks-baird/self-driving-lab-demo/blob/0ff0adec3e997c096990de594844d73a9ce18fd6/src/public_mqtt_sdl_demo/lib/netman.py)] and an appropriately filled-out `my_secrets.py` are required). You will also need to upload the [`mqtt_as.py` module](https://github.com/sparks-baird/self-driving-lab-demo/blob/045b276480d64bdd24287f427491041c33535ef2/src/public_mqtt_sdl_demo/lib/mqtt_as.py) to either the main directory or the `lib` folder. Make sure to replace `<your_id_here>` with your course ID (without the brackets). If you've forgotten your GitHub Classroom course ID, you can refer back to your quiz responses from the GitHub starter tutorial assignment. Once you've updated the file, save the file and click play.

`my_secrets.py`
```python
Expand Down Expand Up @@ -212,7 +212,7 @@ For a hobbyist project, these might not be large concerns; however, when impleme

<!-- ✅ Read about the [Paho MQTT Python client](http://www.steves-internet-guide.com/receiving-messages-mqtt-python-client/). Pay attention to the section about using a `Queue` -->

✅ Review the [micropython-mqtt repository README](https://github.com/peterhinch/micropython-mqtt) and its [Asynchronous MQTT docs](https://github.com/peterhinch/micropython-mqtt/blob/master/mqtt_as/README.md)
✅ Review the [micropython-mqtt repository README](https://github.com/peterhinch/micropython-mqtt) and its [Asynchronous MQTT docs](https://github.com/peterhinch/micropython-mqtt/blob/master/README.md)

✅ Read [Receiving Messages with the Paho MQTT Python Client](http://www.steves-internet-guide.com/receiving-messages-mqtt-python-client/), paying special attention to the "Use the Queue object" section. Then read the Basic first-in first-out (FIFO) Queue section from [this page](https://pymotw.com/2/Queue/#basic-fifo-queue)

Expand Down
Loading