When Raspberry Pi Pico W is released it became a new tool which can be used for IoT projects. While its fun to connect our own servers, AWS is an established enterprise ecosystem which every IoT enthusiast should have some experience on and Pico W gives us an cheap development board to get our feet wet. Some of AWS requirement seems to be overkill at first but it they will become useful as your project progress. So lets get started
First connect to AWS then open IoT core from menu
From AWS IoT select Policies
from polices menu select Create Policy
in create policy menu add name policy and add policies with Add new statement then click Create
in security > certificates menu select Create certificate from Add certificate
Select Auto generate new certificate and Active then click create
Download the certificates beware this will be the only time that you can download the certificates note the name of the certificate as we need it later.
In AWS IoT > Manage > Things menu click create things
In Create Things menu select Create single thing and click Next
select no shadow and give a name to your thing and click next
Click Skip creating a certificate at this time and click Create thing
in certificates menu select the certificate you just created
click Attach policies
select the previously created policy and click attach policy
you will see the the policy attached to the certificate
select Things in certificate menu and click Attach to things
select previously created thing and click Attach to thing
you will see that thing is attached to certificate
connect to Pico W and upload micropython code using our favorite ide
we need to convert AWS certificate format to DER format. I use openssl. Download openssl binary to your platform and run the following commands on your downloaded certificates you can distinguish certificates by how names end.
openssl rsa -in private.pem.key -out private.der -outform DER
openssl x509 -in certificate.pem.crt -out certificate.der -outform DER
upload these two certificates to certs folder. Change the AWS endpoint address with the address you get
wifi access point information and channel name
Before you execute program open MQTT test client and subscribed to temperature topic this will send the values in internal Pico W sensor
if you publish on to topic led the internal led of Pico W will turn on and if you publish off it will turn off.
Comments