Install dependencies by running the following on the device's python console:
# Setup network first
import network
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect("yourssid", "password")
# Then install the required packages
import mip
mip.install("umqtt.simple")
mip.install("umqtt.robust")
Since the Raspberry Pi Pico needs to communicate with thin-edge.io over the network, the thin-edge.io instance needs to be setup to enable this communication.
-
On the main device where the MQTT broker, tedge-mapper-c8y and tedge-agent, run the following commands to set the configuration:
tedge config set c8y.proxy.bind.address 0.0.0.0 tedge config set mqtt.bind.address 0.0.0.0 tedge config set http.bind.address 0.0.0.0 tedge config set c8y.proxy.client.host $HOST.local tedge config set http.client.host $HOST.local
If your
$HOST
variable is not set, then replace it with the actual name of the host your are running on (e.g. the address must be reachable from outside of the device) -
Restart the services
systemctl restart tedge-agent tedge reconnect c8y
-
Check that the address is reachable from outside, e.g.
curl http://$HOST.local:8001/c8y/inventory/managedObjects/
-
Using Thonny, connect to your Raspberry Pi Pico
-
Copy across the following files
src/main.py
=>/main.py
src/config.py
=>/config.py
-
Edit the
config.py
and update WIFI and broker settings -
Start the application (ideally without Thonny connected, otherwise Thonny can interfere with functionality such as device restart, software updates etc.)
OTA updates via: * https://pypi.org/project/micropython-ota/