Connecting the Raspberry Pi

Now that we have the Primary Connection String, we can use it to connect our Raspberry Pi to the Azure IoT Edge resource. To do this, follow these steps:

  1. Open up a Terminal on the Raspberry Pi. We are going to use the nano program to modify the configuration of our installed Azure IoT Edge component. Type the following code into the command line, and hit Enter
sudo nano /etc/iotedge/config.yaml
  1. Scroll down to find the Manual provisioning configuration section, and locate the device_connection_string variable, as illustrated in the following screenshot: 

  1. Paste in the Primary Connection String from the previous step in place of <ADD DEVICE CONNECTION STRING HERE>, and be sure to keep the quotes. You may click on Edit | Paste to paste the new connection string.
  2. Press Ctrl and X on your keyboard, and then Y and then Enter to save the changes.
  3. We will now restart the iotedge daemon. Type the following code into the command line, and hit Enter:
sudo systemctl restart iotedge
  1. To see the services that are running with our Azure IoT Edge device, we may use the list command. Type the following code into the command line, and hit Enter:
sudo iotedge list
  1. You should see that the edgeAgent is running. The edgeAgent always runs when an Azure IoT Edge installation is set up.
  2. To verify that our Azure IoT Edge device is communicating with Azure, navigate back to the Azure portal and go to the home page.
  3. Click on our IoT Hub resource (AresHub) and scroll down until you see the IoT Hub Usage chart. You should see that there is one IoT device shown on the chart, as illustrated in the following screenshot:

  1. As there are device twins for every device connected to the IoT Hub, there will be one for the Azure IoT Edge device we just set up. Scroll down a bit more and verify that a device twin was set up, as indicated in the Device twin operations chart shown in the following screenshot:

We have successfully turned our Raspberry Pi into an Azure IoT Edge device. In the next section, we will deploy a simulated temperature sensor service to our edge device and view telemetry information using the Microsoft Device Explorer application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.152.87