Case Study: AWS IOT based application development · IT Consulting & Development | Custom Software, SAP, Microsoft

Case Study: AWS IOT based application development

Home / IoT / Case Study: AWS IOT based application development

As a pharmaceutical company our client wanted to ensure the medicines reach to the dealers and hospitals at the right temperature and if they  are tampered or have met weather or temperature condition it can be found easily and discarded so it’s not used by Hospital staff. They also wanted to be able to see the stock of all items in one go which are lying in the stock and which are already in transportation

This will also help to improve the time to react if some medicines need immediate action or if my fridge is faulty, so they can accommodate the medicines in other fridge or send another truck to do the transportation avoiding spoilage of the medicines. These medicines are surgical instruments, Anesthesia medicine and other liquid medicines which need to be maintained at a specific temperature and humidity conditions.

It is important that medicines are stored correctly so that they don’t degrade and lose their effectiveness. These drugs should not be exposed to extreme temperatures, excessive light or moisture and it becomes very difficult to monitor any issues in temperature in a moving vehicle. With implementing our small IoT application which had the below toolkit we ensured these parameters were measured and any changes were highlighted

  • Raspberry Pi3
  • Humidity and Temperature sensor
  • Using AWS IoT core functionality.
  • Mobile application
  • Backend in Azure
  • Coding in C#, JavaScript and Angular 5 using Fiori guidelines

In this case study blog, we disc on how to set up AWS for the application. We created the below application and followed the steps as below

  1. Setup AWS
  2. Manage devices using AWS console
  3. Create a user and new Access key
  4. Use webserver to interact with the device
  5. Sending and receiving binary data for the device

Read each of these steps in brief and have a look at the App design we created.

1.Complete AWS Setup

  • Confirm Platform as Windows & Choose AWS IoT Device SDK using Windows And NodeJs

 

 

 

 

 

Register a thing by giving a device name

 

 

 

 

 

 

  • You can optionally choose a device type

 

 

 

 

 

 

  • Once the device is created download the kit

 

 

 

 

 

 

 

 

  • Kit will provide you with the sample code which can be used to test the connectivity

 

 

 

 

 

 

  • Test the connection with AWS IoT with the sample code

Open Windows Power shell >> Run as Administrator

Run the command

Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process And below then enter ‘A’ and then .\start.ps1

 

 

 

 

When the install completes as below . It will be connected to the device. You can also send a message to device by typing in text box and clicking on Send message button.

 

 

 

 

It will be received on device side and will be shown in the power shell

 

 

 

 

 

 

This will complete the initial setup

 

2. AWS IoT Console

AWS IoT console shows all the registered devices and allows you to manage the devices.

It will also let you interact with the device using MQTT or HTTPS

 

 

 

 

 

 

 

Now, test by sending a message

 

 

 

 

 

 

Recieve the message on the device as seen below

3. Create a user and new access key

In order to access the device or interact with the device you need to create a user

https://console.aws.amazon.com/iam/home?#/users

Go to Identity and Access Management

https://console.aws.amazon.com/iam/home?#/security_credential

In order to interact with device we will need accesskey and security key which you can find below

4. Web server to interact with device

The functionality provided by AWS IoT console can be replicated in our own custom web server to interact with device. In order to interact with device we will need the mqtt endpoint.

  • Find the end point AWS IoT

https://eu-central-1.console.aws.amazon.com/iot/home?region=eu-central-1

  • Interact with the Device

To interact with the device. To run the web server please follow these steps:

  • unzip ‘web.zip’ -> go to folder in command prompt and run following commands:
  • run “npm install”
  • run “./node_modules/.bin/webpack-dev-server –colors”

This code will allow 2 way communication with the device and can be extended to send any binary data.

Note: You will need to update the AccessKey, SecurityKey and AWS IoT Endpoint in the code (main.js)

5. Sending binary Data

We are leveraging the code downloaded at the time of AWS IoT Setup.

(copy the file in aws-iot-device-sdk\examples)device-example.js listens on mqtt topic ‘topic_1’. On receiving any message, it reads binary data from test.zip and send it on ‘topic_3’. Then web client reads the binary message and sent it again on ‘topic_1’.

Code Logic: Below code in the device  reads binary data from test.logic and sends via MQTT to the webserver

So as of now, on receiving the first message it will start a loop with the webserver of sending the same binary data and receiving the same binary data. i.e. once a device receives a message on ‘topic_1’ it sends binary message on ‘topic_3’ then web client reads the binary message from ‘topic_3’ and send the same binary message again on ‘topic_1’ and it keeps continuing.

Below code in the webserver will read the data sent by device and send the same data (binary data in our case) from webserver to the device.

Sending message from  Webserver

Receiving message to Device

This is a demo code to demonstrate binary data can be sent and received to/from device. The webserver code can be further updated to send any specific binary data or file which can be received on the device side and in our case was sent to the mobile device and we created a mobile app to monitor time data as below

Launch Page: Came at the start of the Application

Main Page 1: Shown after entering inside the Fridge icon above

Detail Page  to go inside each refrigerator as seen below

 

Hope you find the article interesting for any feedback please comment and for any business queries kindly contact us here 

 

Leave a Reply

Your email address will not be published. Required fields are marked *