Now that we have created the resources on Azure we can update the code to point to the IoT Hub and then deploy the devices.
To program the ESP, you hook it up to the USB-to-UART converter; ensure it is in programming mode (by ensuring IO0 is connected to ground) then programming it. If it refuses to program, try unpluging and re-pluging the power pin, as the ESP may have booted in run mode rather than program mode. To program it you clone the repo and then use PlatformIO to program it.
Hackster have a good guide with pictures on wiring if you have never programmed an ESP8266 before.
Clone the repo https://github.com/GP2020-Sierra/azure-sphere
Update the app_manifest.json
file
1) Under AllowedConnections
in Capabilities
, replace sierra.azure-devices.net
with the hostname listed for your IoT Hub in Azure.
2) Under DeviceAuthentication
in Capabilities
, replace the UUID with the UUID of your tenant (can be seen in the output of azsphere tenant list
)
3) Under CmdArgs
, replace the ID with the ID Scope
from your IoT Hub DPS in Azure.
Build the code following Microsoft’s instructions.
To simply deploy the code to multiple boards you can create a product and deploy the .imagepackage
file from the out
folder.
1) azsphere prd create -n sierra
2) azsphere device-group deployment create --devicegroupname "Field Test" --productname "sierra" --filepath "<PATH>\out\Debug-3\Sierra2020.imagepackage"
3) (for each device) azsphere dev ect --productname sierra
Once a device is deployed, its location can be set by following the instructions at the bottom of this README’s Azure page for setting up the device twins.
Below is an image of what a deployed device looks like