This project showcases a simple interconnectivity among a server, a mobile application and a hardware. The mobile application (android) majorly deals with user input and exchanges data with the server (PHP). The server inturn publishes data onto the mqtt channel. The hardware (raspberry pi 3) is connected to the same mqtt channel and depending on the message sent over the channel does specific operation.
Consider a metro station with tollbooth. Commutators scan a QR Code on the tollbooth which unlocks the toll gate. The travel through the metro and once they reach the destination station, they scan the QR Code on the toll booth again to unlock the gate. The transaction not only gets recorded but the entire process requires no physical exchange of money.
- A tollbooth consists a QR Code attached to it.
- The QR Code encodes the station and gate number of the tollbooth. This helps to note which tollbooth is the commutator using. The information is sent to the server when the QR Code is scanned.
- Use the mobile application to scan the QR code on the tollbooth.
- Data associated with the tollbooth and user is spent over to the server.
- Server updates the database and spends message over MQTT Channel to open the connected toll gate.
- Simlarly the commutator can unlock the gate at the destination station.
- Raspberry Pi/Arduino - This handles the hardware part of the system. We have used Raspberry to avoid the trouble of setting up ethernet for arduino.
- Ultrasonic Sensor (HC-SR04) - This will enable the auto closing of the gate after a commutator passes through the gate.
- Server - This handles the centralized transaction and updation of user records. We have used XAMPP and coded our server with PHP.
- Mobile Application - This handles the interaction with the user. The camera of the mobile scans the QR Code and use internet to relay data to the server. We have used Android.
- MQTT Broker - (Message Queuing Telemetry Transport) In lucid terms it is just a channel where devices can publish or subscribe to a topic. There are many free brokers available for testing!
- Database System - Store the user data for authentication, transaction and tour details. We have used MYSQL.
- Android (Mobile Application) - https://github.com/iamsandeepkhan/smartToll_app
- PHP (Server) - https://github.com/iamsudiptasaha/smartToll_server
- Raspberry pi (Hardware) - https://github.com/iamsudiptasaha/smartToll_hardware
This repository contains the mobile application functionalities to handle the android application. The application uses a QR code scanner to scan the QR codes on the tollbooth. The data is then sent over to the server using HTTP protocol. The data is processed and the gate is unlocked accordingly. User information associated with a tour is also updated. The application provides tour history and a demo bank system. In real time it is recommended to use third party bank api.
Link to JSON : https://github.com/bluerhinos/phpMQTT
Link to Vision API : https://developers.google.com/vision/android/barcodes-overview
- Please update the host name information res/values/strings.xml file!
- Return values : JSON Encoded data. Contains two mandatory fields to determine successful server operation:
"sucess" : "true"/"false" - If the operation was successful or not.
"errorCode" : If sucess is false then we may get the following error codes. The associated error is mentioned alongside.
- "1" = Invalid data or empty data.
- "2"= Improper option.
- "3"= Failed DatabaseConnectivity, try again.
- "4"= Duplicate username, rejected.
- "5"= MYSQL error.
- "6"= no such user
- Tour status : Different status codes for tours and their associated status is mentioned along side:
- "0" = Default tour status value.
- "1"= Travelling.
- "2"= Completed.
- Data over MQTT Channel : JSON Encoded data. Contains two mandatory fields to determine successful server operation:
"station" : Station name or code
"gate" : Gate code associated with the station.
- QR Code Encoded Data : JSON Formatted data. Contains two mandatory fields to determine successful server operation:
"appname" : "smartoll"
"station" : Station name or code
"gate" : Gate code associated with the station.