I've started a project for my college work and I've been able to make some headway on my own while checking for code and ideas online. However, I feel that I've reached a stage where I could use some feedback on whether I'm heading in the right direction.
The basic idea of the project is to use Arduino, a GPS module, a RFID card reader and RFID cards to calculate the fare for passengers that use public transport. I'll also include a 16x2 LCD screen for visual messages.
A brief background on how public service vehicles (PSVs) operate in my country.
In Kenya, we have PSVs called matatus that operate all over. They can be of different sizes ranging from 6 seater to 50 seater. The most common are the 14 and 33 seater.
The matatus pick up and drop off passengers at different stages along the route but they also frequently drop off people at any place along the road. The pick up points and drop off points are never fixed. On a route 40km long there could be 15 official pick up/drop off points but unofficial can be as high as 40.
The fare for each passenger is determined by the conductor/tout of that vehicle. He/she decides based on time of day, day of the week, from what stage to what stage and any other factor.
The above system has a lot of issues as it is cash based, not predictable and prone to the whims of the matatu touts. I wish to introduce a cashless predictable system
How my system works
I propose to use distance as the measure of how much a passenger should be charged for the trip they make. A lot of the current taxi hailing apps use both distance and time but for the purpose of this project, distance is enough
There would be a base fee which is applied all the time and when the passenger travels a certain distance, then the passenger will be charged a fee per distance.
So it can be of the form of y=mx+c where
- y is the total fee
- m is the rate per km
- x is the distance travelled
- c is the base fare
The distance needs to be calculated. For this I've decided to use a GPS module. I could have used Google maps but the issue is that our matatus don't always stick to known roads and can use rough roads or gullies to get to their destination. So using maps wouldn't have been easy. Calculating the distance makes more sense.
The distance would be calculated every 1-2 seconds and added to get a cumulative total. So say the matatu moved 15m the first sec, then 25 the next sec and 25 again. So say in a span of 30 min they moved a cumulative total of 45km. The passenger would be charged for that 45km
Where does RFID come in? The system has to find a way of keeping track of each and every passenger since not everyone entered at the same stage. So whenever a passenger enters the vehicle, they swipe their card against the RFID reader and the system records the position where they started from. The passenger at that point is assigned a 0 total and from that point on they will get their distances added up until they leave
When the passenger leaves, then they have to swipe again to show that they have left. The system has to calculate the final total of distance, get the fee for that distance and add the base fee and finally display the fare to be charged. The fare is then deducted from the RFID card.
Arduino brief sketch:
- Scan for RFID card
- Save RFID card ID to a table with distance column
- The distance column starts at 0
- Every 1 second, calculate the distance, add it to the figure in the distance column for that ID
- The above step is done for all IDs in the table
- Every 1 second, the Arduino scans to check if the card ID is still in the system or not
- It also checks to see if the same ID has been swiped out
- If the card is swiped out, finalize the total, calculate the fare and display the result
- Once swiped out and the result displayed, the fare is deducted from the card
- And finally the ID is removed from the table and the distance reset to 0
So far I've been able to get a code working for calculating the distance every 1.5 seconds (I can change this time interval)
I've also got the code to check for new IDs and store them
I'm stopping at this juncture to see if there's something else I need to do before proceeding. If all this looks good, I'll post the code soon