Device-to-Cloud Communication:

In the last blog I have explained the code that reads the sensors data, process it and sent to Cloud storage, in this case it is Azure Services.

 

First created an Azure IoT Hub using the Azure portal as described here. I am using my Biz Spark subscription for this.

 

Then provisioned a device in the above IoT Hub and got the Device Connection String, which is set in the device software in the azure1_config,h as shown below. Actually this device name / id will follow a format which is yet to be decided. The provisioning will final be done from a Mobile App.

#define AZUREIOTHUBCONNECTIONSTRING "HostName=esm-iot-hub.azure-devices.net;DeviceId=P-NUCLEO-AZURE1-Test;SharedAccessKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

 

Currently used Device Explorer utility provided by Microsoft is used to confirm that the data is received by the IoT Hub as shown in the following image.

Device Explorer showing the data as received by the IoT Hub

 

The data received by IoT Hub will be stored in Azure Storage / SQL database which will  be displayed by the Mobile App using Azure App Service. Currently this part is being designed and coded.

 

Mobile App Menu Contents:

In the last blog I have shown the glimpse of the Mobile App Main Menu, which is show below. The functionality is explained here.

Main Menu of the Mobile App (Android version is shown)

 

When the app is started it will be showing the Home page as shown below

Home Page of the Mobile App (Android Version)

 

Tapping the 'Hamburger' icon at the top left corner shows the Main Menu shown earlier. Tapping the [NEW DEVICE] button will allow to add a new device to the Azure IoT Hub. Tapping the [ABOUT] button will show the details about the app. Tapping the [START RECIVING DATA] button will start displaying the data as it is received by the IoT Hub. This will be in the form of a formatted table.

 

The Main Menu options are described below:

  1. Home (Live Data) - Shows the Home Page. This is used to return to the Home Page from any other page.
  2. Alerts - This will display the current and past alerts received. On app start, if there is an active alert the Alerts page will be displayed automatically.
  3. History - This system saves past 7 days data in the cloud storage. This past data will be shown here date-wise. This also includes the data received currently till the time of showing this page.
  4. Manage Cloud - This enables removing an existing device from IoT Hub. If no data is received from a device continuously for 2 days, that device will be 'disabled'. Such disabled device also can be enabled again here. Until it is enabled the data will not be received by the IoT Hub.
  5. Manage Device - This enables the setting of Wi-Fi credentials, IoT Device Connection String, Temperature Unit, Threshold Temperature and other necessary parameters in the device. This connects to the device through the Bluetooth.
  6. App Settings - This allows change of password and other app parameters be set.
  7. Setup New Device - This will walk you through the steps to setup a new device.
  8. About and Help - This shows the details of the app and help topics.

 

Currently researching on the components needed to connect the mobile app to Azure services. Once it is finalized more app pages will be designed and shown here.