Touchless Do More, That's how we start. In amidst of this COVID-19 Pandemic, It asserts the importance of avoiding human to human contact as much as possible to break the chain of this contagious spread. So the problem that we choose to solve is the fare collection. Perhaps it comes down to achieve two aims at once. Meaning that our India really needs some robust system for collecting fare in the public transport sector also during this time of contagious spread, we are in an indispensable need to avoid human to human contact. Hmm. Best of Both Worlds!Even though it was being implemented in all developed countries, It was still not feasible to implement at India on a very large scale. That's where our system comes into play, A Low-cost Fully Automatic Fare Collection System for India's Public Transport Services.
Overview Of The Project
Now, we are going to explain how we made TapToPay Automatic fare collection system using Arduino MKR WiFi 1010 board from Arduino, Mifare MFRC522 RFID Reader/Writer, Google firebase and Google sheets. The MKR board and card reader uses SPI for communication. We have used tags as a bus stop identifier and cards for individual users.
Brief Introduction about RFID Technology
RFID or Radio Frequency Identification system consists of two main components, a tag and a reader. A reader consists of a radio-frequency module and an antenna which generates a high-frequency electromagnetic field. on the other hand, the tag is usually a passive device. It contains a microchip that stores and processes information.
Let's Make It
Step 1: Detect stop card and user card
When the RFID is placed near to the RFID reader, it will be checked with the database to identify whether it is a Stop card or Passenger card. If it is a stop card, then update the current stop in the system.
Step2: Update Passenger List
If the read card ID is not present in the bus stop database then it is a Passenger card. A separate list is maintained for the boarded passengers. Once the passenger card is read, the ID will be searched in the passenger list. If the ID is not present in the list add the passenger ID and the current stop as a boarding point of the passenger.
The passenger list is maintained in a linked list.
int update_pass_list(byte *rfTag, int point, int amount)
{
passenger_t *pass = NULL;
if (!head) {
/* Passenger on boarding case */
if (amount < min_req_amt(point)) {
Serial.print("Problem");
return -1;
}
pass = (passenger_t *) malloc(sizeof(passenger_t));
if (!pass) {
/* This case will hit only when the system in bad state */
printf("Failed to allocate Memory\n");
exit (-EXIT_FAILURE);
}
head = tail = pass;
memcpy(pass->rfTag, rfTag, RFTAG_MAX_LEN);
pass->startPoint = point;
pass->next = NULL;
} else {
pass = search_tag(rfTag);
if (pass) {
/* Passenger getting off case */
/* Deduct money and write */
byte data[MAX_DATA_SIZE] = { };
byte* out = 0;
int_to_byte(Cal_fare(amount, (point - pass->startPoint)), data);
updated_balance = byte_to_int(data);
/* Deleting entry from list */
delete_entry(rfTag);
} else {
/* Passenger on boarding case */
if (amount < min_req_amt(point)) {
/* If the passenger card has low amount then reject it */
return -1;
}
pass = (passenger_t *) malloc(sizeof(passenger_t));
if (!pass) {Serial.print("Failed to allocate Memory");
/* This case will hit only when the system in bad state */
printf("Failed to allocate Memory\n");
exit (-EXIT_FAILURE);
}
tail->next = pass;
memcpy(pass->rfTag, rfTag, RFTAG_MAX_LEN);
pass->startPoint = point;
pass->next = NULL;
tail = tail->next;
}
}
}
Step 3: Calculate fare and update balance
When a passenger is getting off from the bus, the card should be tapped. Our system will read the card and search the ID in the passenger list and will fetch the passengers boarding point from the list. With the current stop and the passenger's boarding stop, the fare will be calculated. The calculated fare will be deducted from the available balance in that passenger's card and the remaining balance will be updated to that card.
int Cal_fare(int amt, int num_stop)
{
return (amt - (num_stop * FARE_PER_STOP));
}
void int_to_byte(int data, byte buffer[MAX_DATA_SIZE])
{
int x = data / MAX_AMT_PER_BYTE;
int y = data % MAX_AMT_PER_BYTE;
int i = 0;
memset(buffer, 0, MAX_DATA_SIZE);
if (x == 0) {
buffer[0] = y;
} else {
/* update dataBlock with new balance amount */
for (i = 0; i < x; i++) {
buffer[i] = 0xff;
}
buffer[x] = y;
}
}
int byte_to_int(byte buffer[MAX_AMT_SIZE])
{
int curr_output = 0;
for(int i = 0; i < MAX_AMT_SIZE; i++) {
curr_output = curr_output + (int) buffer[i];
}
return curr_output;
}
Step 4: Delete Entry
After updating the remaining amount to the passenger card that passenger ID will be searched in the list and the entry will be removed from the list. The list maintains only the on-boarded passengers in the list.
void delete_entry(byte *rfTag)
{
passenger_t *list = head;
passenger_t *prev = NULL;
if (!rfTag)
return;
/* Updating the head in case of first entry itself the match */
if (list && !memcmp(list->rfTag, rfTag, RFTAG_MAX_LEN)) {
head = list->next;
free(list);
return;
}
/* searching the entry in the list */
while (list && memcmp(list->rfTag, rfTag, RFTAG_MAX_LEN)) {
prev = list;
list = list->next;
}
if (!list)
return;
prev->next = list->next;
/* Updating the tail */
if (list == tail)
tail = prev;
free(list);
}
Step 5: Send UID to Firebase and update Google sheet
The passenger details will be updated in the cloud database. It will help to track the passenger's route in case he is tested with COVID-19 positive.
The Passenger details are Passenger ID, On-boarding stop with time, Off stop with time.
Software Flow:
Howthis system willslow down Covid-19spread in India?
In India, like in so many other parts of the world, the coronavirus has struct a massive blow to transport. Enhancing the safety of bus transport will be the most pressing issue. In Indian bus transport, cash is being used by the passengers to pay their fare through which there is a possibility of virus transmission. India's move away from cash has been aided by the government. Despite the push, India remains a cash-intensive economy. Some state governments also begin e-ticketing system for its buses to minimise contact. Our Arduino based TapToPay system will play a significant role in the Indian Transport system if implemented.
The video below gives you a quick overview of the project and can be used as a starting point to understand the project.
Enhancements
- As a prototype, we used a single RFID reader/writer. In a real-time deployment it can be used two or more RFID reader/writer. One for Stop tags and One for passenger cards.
- A separate RFID reader/writer can be used for recording data of boarding passenger and leaving passenger.
- A separate server and new database technology can be used to store the passenger travelling details in the cloud.
Comments
Please log in or sign up to comment.