Azure IoT Hub
How to set up an IoT Hub, register a device, and simulate the device to send telemetry data or files to Azure Blob Storage.
- In your Azure account, search for IoT hub
- Click on Create
Fill the following details such as: Resource group (create new or choose an existing one), IoT Hub name, choose a Region, choose a Tier
Click on Review + create
- Click on Create
- Once your deployment is complete, Go to resource
On the left pane in your IoT device, locate Device management and choose the Device blade
Click on + Add device
- Give your Device ID a name and click on Save
NB: Notice that your device is created.
- Click on your device
- Take note of your Primary connection string as it would be useful all through the project. You should also copy the string.
Use this link to open a raspberry web simulator on another browser: https://azure-samples.github.io/raspberry-pi-web-simulator/#GetStarted
Once the web simulator window is opened, look to the lines of codes at the top right of the screen. Set your focus on line 15
Replace the string on line 15 with the copy of the Primary connection string in step 11. Ensure the it is in between the inverted comas (‘ )‘
After which, Run the program
You will notice the red right blinking at the left side of the window. At the bottom right, you will see consistent results of communication between the web simulator and your device in azure.
To test the connection, go back to your IoT device in Azure.
- Click on the Message to device tab
- Type a message you want to send and click on Send Message
!8. Go back to your web simulator.
- You can stop the program from running temporarily (optional)
- Scroll up gradually the bottom right section to see the message you sent to the web simulator. The headline will be Receive message
Another thing you can do with your IoT hub is to send images from your phone (Android or IOS) to your IoT device.
In your IoT device, locate the Hub settings and choose the Message routing blade
Click on + Add
In the Endpoint tab of the Add a route page, fill the following: Choose the Endpoint type using the drop down arrow. Since we are working with in this project, we chose storage.
Other details to fill are Endpoint name and Pick a container
Click on Create + next
Give the route a name in the Route tab.
Choose Device Telemetry Message in the Data source field
Click on Create + skip enrichments
Confirm that your Message routing has been created successfully
Next, you need to configure the File upload. It is the next blade after the Message routing blade in the Hub settings tab
In the Storage container settings section, Select Azure storage container
Click Save
- In the Storage accounts section, select an existing storage account from the list or create a new one by clicking the + Storage account tab
To learn how to create a Storage account, visit this link: Editing "Creating Storage Account in Azure"
Select a container you want your blobs to be stored in..
Click Select
- Confirm your selection and click Save
On your phone, download the IoT plug and play on Google Play Store or use the link https://apkpure.com/iot-plug-and-play/com.iot_pnp
Open the app and click on the Scan QR Code
- Click Connect manually
Choose IoT Hub device connection string
Copy your Primary Connection String in step 11 and paste it in the box
Click Connect
Wait for it to connect
It shows this once it has connected.
- At the bottom of the screen, choose Image
Click on Select an image
Choose the source to get the image from.
Please note, If you receive an error such as this, refer back to step 29 and configure file upload in your IoT device in Azure account.
- Once you have successfully selected an image, you will receive the message below
- Go to your container in your storage account to conform that the image is successfully uploaded. Follow the series of figures below to see the steps.