Auto Monitor

by Vandammecasper in Circuits > Electronics

127 Views, 1 Favorites, 0 Comments

Auto Monitor

intro.jpg

It can sometimes be difficult when you are transporting friends, but you agree to divide the cost of petrol between you before the trip to make the actual cost easy to calculate.

My solution is to create a machine that measures the distance travelled by a particular person and then calculates the cost of that journey on the basis of fuel prices, distances and average fuel consumption of the vehicle.

Tools and Supplies

materials.jpg

First of all you will need some tools:

  • Computer
  • Soldering bolt
  • tin
  • 3D printer
  • Stripper
  • cutter

Then you will also be needing some supplies:

  • LCD screen
  • RFID reader
  • RFID tag(s)
  • Rotary encoder
  • Raspberry pi
  • breadboard
  • wires
  • Pisugar battery
  • Ethernet cable

Connecting All the Components

After finding all of your tools and supplies you will have to use those tools to connect all of the components to the raspberry pi. Make sure to pay close attention to the wiring and not to put components which run on 3.3V on 5V.

Database

schema dbs.png

After connecting all the components we will have to create a database. In the database we will have to save our data.

we will be saving:

  • first name of every passenger
  • last name of every passenger
  • the rfid id for each passenger
  • (picture of the passenger is also an option)
  • the beginning of every drive
  • the end of every drive
  • the active time of every drive
  • the distance driven
  • the cost of every drive
  • the latitude of the last located position
  • the longitude of the last located position

The Idea of the Code

code.png

After we have made our database we will have to write the code for the machine to work.

Here you have the link to the github page where you can find all the used code for my project:

https://github.com/howest-mct/2021-2022-projectone...

the code works like this:

  1. We start up the machine and import the neccesary files to run the code.
  2. Then we make sure all the GPIO pins are set correctly for everything to function as wanted.
  3. After that we will start the display_on function which shows the ip adress and if available the LAN adress on the lcd to connect to the website with your phone or other digital device. After showing that the lcd will show the instruction to press on the button of the rotary encoder.
  4. Then when you press on the button of the rotary encoder the press function will be initiated, this function lets the rgb light up blue to indicate the rfid reader is ready to receive a rfid tag. It also makes sure that the table on the activity screen on the website turns blue and that stand by is displayed
  5. After going through the press function we will proceed automatically to the rfid_read function, here we look for an rfid tag that has to be read. The moment that is it read the function will send to the website that the machine is active so that we can see in the current drive screen on the website that the machine is active. Then it will set the rgb led to green to indicate that the machine is activated. After setting the rgb we will display on the lcd a welcome message with the name of the passenger that just logged in and we will active the neccessary threads for the upcoming procedures. now we will proceed to go to the display function.
  6. In the display function we set the different screens for the lcd when the machine is active. the first screen shows the ip and the LAN adress when available. The second screen shows which passenger is logged in, the third screen shows the distance that has currently been driven, the fourth screen shows the time that the machine is active and the last screen shows the current cost of the ride.
  7. while running you can move the screens by turning the rotary encoder, the function for this runs by a thread and is called rotation_decode here we count the screens (if you turn to the right the screen goes up if you turn to the left the screen goes down)
  8. In the meanwhile here are 2 other threads running
    1. you have the thread which tracks the active time which is ... this function will repeat every minute and will see what the time difference is between that moment and the starting moment in minutes.
    2. The other thread is the distance function which tracks the distance driven, this means that it will try to find a location every second and it will calculate how far it is from the previous found position. Like this it is able to track the distance during a drive.
  9. Then when you press the button on the rotary encoder while the machine is active and read out the badge we will again go through the press and rfid_read funcion. Then it will see that the id it just read is equal to the last read id and he will close the current drive. After that we will upload the neccessary data to the database.

Exterior Design

behuizing.png

Now it is time to think about the exterior design of your machine. Mind that all the components that users will have to use to operate your machine have to be accessible. But don't forget to make this project your own by making it look exactly like you want by using a 3D printer. I went for a pretty basic but clean look but be creative if you want to!