Building a real time vehicle tracking system with MoveInSync
In this IoT hackfest, Microsoft teamed up with MoveInSync to help migrate a vehicle tracking solution to the Microsoft Azure cloud platform from Amazon Web Services (AWS) by using Azure IoT Hub and Azure Stream Analytics. This report describes the solution, the results, and the next steps.
- Sudhir Rawat – Senior Technical Evangelist, Microsoft India
- Surbhi Jain – Audience Marketing, Microsoft India
- Akash Maheshwari – Co-founder, COO, MoveInSync
- Nagamanoj Vankadhara – Senior Software Developer Engineer, MoveInSync
- KDV Prasad – Senior Software Developer, MoveInSync
MoveInSync, located in India, is in the business of solving office commute problems through ridesharing. An office commute is different than a normal commute because the employee has to reach their office by a certain time. In India today, 20%–30% of organizations in the IT and ITES sectors pay for their employees’ commute, either as a regulatory requirement or as a perk. MoveInSync has built a transport management platform that is used to move people or goods very efficiently. 140,000 employees daily use MoveInSync’s software as a service (SaaS) solution, and 20,000 vehicles are mounted with the MoveInSync solution.
One of the solutions built using the transport management platform is the employee transportation solution. This solution is used by organizations that provide pickup and drop-off services for their employees (such as IT, BPO, and the airline sector). This solution helps these organizations reduce cost and improve employee satisfaction by reducing employee travel time through route optimization. To ensure the safety of women employees traveling at odd hours, they have developed a safe travel corridor, which is based on data from past travel routes and traffic stops.
This solution has been operational since August 2011 and has top companies in each sector on the client list. Specifically, this solution benefits stakeholders in the following ways:
- Cost savings (route optimization, vehicle seat utilization optimization)
- Enterprise risk (employee safety, financial compliance)
- Employee satisfaction (real time vehicle information for tracking)
MoveInSync’s employee transportation solution automates the employee transport for organizations that provide transportation to their employees. The users of the solution are transport teams and employees of the organization.
Transport teams use the solution for scheduling employees, preparing routes, tracking vehicles, auditing vehicle usage for billing, and getting billing data for invoicing vehicle providers.
Employees use the solution (in the form of a mobile device or a paper tripsheet generated by the system) for checking in and checking out a vehicle. Project managers and employees can sign in to the system to mark their team’s schedule or their own. However, these sign-ins are not enabled by default for a deployment. The entire solution is based on roles, where each role has access to certain functionalities. The solution is provided as software as a service (SaaS).
In this engagement, MoveInSync brought one part of their existing solution, Real Time Vehicle Tracking, to Azure from Amazon Web Services (AWS).
The current solution is built on virtual machines deployed on AWS. The web server is hosted on Amazon Elastic Compute Cloud (Amazon EC2) running SUSE® Linux Enterprise Server 11 Service Pack 2, Java Development Kit 1.7.X, and Apache Tomcat version 7.0.XX. The web applications use Apache ActiveMQ to pass on events to each other. ActiveMQ is deployed on the same virtual machine.
The database server is on another Amazon EC2 instance running SUSE® Linux Enterprise Server 11 and Postgres relational database management system. They are also using Memcached to store non-critical data for improving performance.
Devices on which only MoveInSync’s application could run, such as Ideos (Android 2.2), Moto E 1st gen (Android 4.4), Moto E 2nd gen (Android 5.1), and Micromax Q416 (Android 5.1.1), were available in cabs. These devices are used for tracking the vehicle, signing the e-tripsheets, and keeping track of the kilometers run. These devices also have the capability of raising an SOS alarm. They send the location/GPS details to the ETS Platform server, which is further used for billing or security-related use cases.
A mobile app is available for employees on Android, iOS, and Windows, from which employees can view/edit their schedule, track the cab, and raise an SOS. The devices are rooted and all the bloatware is removed. MoveInSync applications run in kiosk mode so that no other applications can be launched.
Communication with the server happens over HTTPS on a mobile data network. The data send frequency is a minimum of 10 seconds and a maximum of 3600 seconds, based on different states of the device (duty on/off, trip running/not running, power connected/not connected). The data packet size is a maximum of 25 KB.
The data is stored in partitions that are accessible to the root. USB Debugging is disabled so that no one can get into the file system to read this data.
The solution had a few problems:
- Cab devices keep sending data even when there is no one listening, generating a lot of data that is not required.
- There was a load on the Web Apps server because it’s acting as a communication channel as well.
- Scalability was difficult.
- Manageability of the entire infrastructure was difficult.
- Device management was difficult.
The new solution helps to manage and register a device, enabling secure devices and event processing.
Solution and steps
In the previous section, we discussed the customer’s current architecture and the problems associated with it. In this section, we propose a new architecture and discuss the involvement of each service.
Step 1: Building the end-to-end flow
Figure 1. Proposed architecture
In this architecture, as soon as the driver in a cab starts their shift, they sign in to the application. The driver sign-in information is sent to Azure IoT Hub and then gets stored in Azure Redis Cache through Azure App Service. After that it keeps sending ‘keep alive’ messages to IoT Hub. The worker role captures the event and checks if it’s already available in Redis Cache; if it’s not, the role inserts it.
After an employee signs in to the MoveInSync mobile application and selects the cab that they want to track, it sends an event to IoT Hub. The worker role captures that event and stores that information in Azure Redis Cache. Next, the worker role sends a message to the device in the cab asking it to start sending the cab’s coordinates, which then show up in a map to the employee. After the trip is finished or no one is tracking the cab, the worker role sends a message to the device in the cab asking it to stop sending coordinates.
Step 2: Configuring IoT Hub and Azure App Service
The Microsoft and MoveInSync teams had a discussion about the capabilities of Azure IoT Hub. The discussion happened around device management, device-to-cloud and cloud-to-device messages, high availability, disaster recovery, identity registry operations, security, and monitoring. We also discussed Azure App Service and Azure Functions, but because MoveInSync has expertise in Java, and Java is not an option with Azure Functions, they decided to use Azure App Service.
The MoveInSync team used in-house expertise to set up IoT Hub and wrote Java code for processing incoming events.
Figure 2. IoT Hub setup
Figure 3. IotDevicesManagement.java for device registration and deletion
Figure 4. IotHubCommunication.java for sending data from cloud to devices
Figure 5. Eventhubconsume.java for receiving message from IoT Hub, processing it, and sending it to IoT Hub
The reference for these code snippets is mentioned in the Microsoft GitHub IoT device samples repo.
For code deployment, Azure Toolkit for Eclipse is used.
Step 3: Solution testing
The MoveInSync team did a solution test, represented in the following screenshot, which indicates the cab location. The cab device sends data about its location to IoT Hub, which processes it and renders it to the employee device. The test was successful and MoveInSync was happy and also liked less latency on cab movement.
Figure 6. Screenshot of solution
Figure 7. Team during solution testing
- Ideos (Android 2.2)
- Moto E 1st gen (Android 4.4)
- Moto E 2nd gen (Android 5.1)
- Micromax Q416 (Android 5.1.1)
The Microsoft and MoveInSync teams worked closely together to conclude a successful implementation of the IoT solution. MoveInSync had their solution running on AWS. We used Azure IoT Hub and Azure App Service, which are platform as a service (PaaS) services, so the integration was quick and straightforward.
We ran into few challenges during the testing phase of the solution. We finished an end-to-end scenario where we read data from the cab device that an employee could track on their device. The MoveInSync team got to learn about using Azure PaaS services along the way and they were happy to see the seamless integration. Our team also learned about hardware and devices that are being used in local industries and gained experience about connecting those to our Azure services.
Opportunities going forward
Currently the solution is in the testing phase. Based on the observations, they may upgrade the Azure App Service plan and/or bring another instance of IoT Hub. The MoveInSync team rolled out this solution to 5% of employee devices (approximately 2,000 devices) and to 300–400 cab devices.
The plan is to roll out the solution to all the employee devices and cab devices in phases. By May 2017 this solution will go live. We will continue to engage with MoveInSync to help them onboard more devices and make sure the right architecture is in place. We’ll keep an eye out and update the customer whenever Azure Functions provides support for Java.
On the cloud side, MoveInSync is evaluating other Azure services and plans to move other parts of the solution to Azure.
Quote from the customer:
“We are looking forward to leveraging Microsoft Azure IoT Hub to help us to scale 10x. We have tens of thousands of devices in each vehicle and hundreds of thousands of users tracking these vehicles through mobile apps. Real-time tracking is an important factor for employees who are sharing the vehicles. We are also planning to use C2D [cloud-to-device] for pushing data from the cloud to devices inside the vehicles. In our current solution, the devices in vehicles are polling servers and hence require us to manage 30 odd servers.”