The monitoring of incoming cargo into US ports and roadways is of vital importance for a multitude of security and economic reasons. Cargo shipments can be subject to problems such as theft, tampering, or being used to smuggle contraband without the knowledge of the shipper.
The Azure Sphere Shipping Container Security Device is a portable security device that will be mounted inside the doors of a container and will be used to continuously monitor for unauthorized door access, unauthorized relocation of the container outside the facility , and detect breaches to any of the six walls of a container.
These thing need to be setup for a working Azure Sphere development environment.
Bill Of Material
- Azure Sphere Starter Kit
- Anker Portable Charger
- Ublox Neo M8N GPS
- Seed Grove - Vibration Sensor
- HC-SR505 PIR Motion Sensor
- SHT15 Temperature Sensor
- Visual Studio 2017
- React Native
Configure IoT Central Hub
Once the IoT Central Hub and had been set up with the Azure Sphere MT3620, create the following interfaces in device template :
Then go to view and create five chart as below. These chart will help to visualize Azure Sphere data over time.
Azure Sphere MT3620 Implementation
- 1. GPS
- The first sensor that I interface the MT3620 is the GPS. For GPS, I used UART protocol to get the data from the GPS module. Below is the function for GPS:
- 2.Grove Sensor Vibration
- Next , I configure the Grove Vibration Sensor with I2C protocol. The output is an analog value from 0-3.3V which i scale to 0-100. In my system, anything above 60 is consider major vibration and could be a possible breach.
- 3.Temperature Sensor
- Temperature Sensor is also use I2C protocol. The process is similar to Vibration Sensor but the register address is changed.
- 4.PIR Motion Sensor
- The motion sensor implementation is simple. The senor output a high (3.3V) if there detection of human presence and a low (0V) if there no detection. I connect the output of the PIR Motion Sensor to a PWM pin on the MT3620. The simply just check the pin value and send a 1 or 0 based on the pin voltage level.
- 5.Sending Data
- To send data from the MT3620 to the Azure sphere, I create a function that format data to IoT Central Hub protocol and send it to the Hub via Internet. The function is show below.
- As an example, i create a function called SendTemp that send Temperature value at an interval of 500ms using the SendTelemetry function.
- The important part here is that the you must set the data the same as the name you set in IoT Central Hub or else it won't get recognized. The full code is in the repo link below. The code is compile and build using Visual Studio 2017. Once the whole project is uploaded to the MT3620, the graph in IoT Central Hub in the device section will begin display data as show below.
Setting Azure Cloud Services
The android app is made using React Native for ease of cross-platform between ios and android. The main point key thing in this app is the need to set up the Azure Event Hubs. Once the Azure Event Hub is configure correctly and filled with data, I used the following line to import the data.
import Azure from "iotc-1e97f318-f85b-42fa-88f8-4f27f7d5a85d.azure-devices.net"
The URL come directly from the Azure Sphere Event Hub primary-key link. For example, I used the key in Detect.js which is a page that use infrared data to detect human presence. The code is show below with usage of Azure Event Hub API.
- 1.Android App
- To compile the Azure Android App you must have React Native install and a working android phone connected to your computer.
- To compile the firmware you must have VS2017 with Azure Sphere SDK install. Launch the .sln file in AzureFirmware folder and press F5 to compile.