EAL - Industry 4.0 GPS Data Collection on Rc Car


Introduction: EAL - Industry 4.0 GPS Data Collection on Rc Car

About: Ich bin ein berliner von kuchen.

In this Instructable we will talk about how we setup a GPS module on a RC car and posted the collected data to a webpage for easy monitering. We have previosly made an instructable on how we made our RC car, which can be found here. This is using the same build, although we have decided to scrap the ultrasound sensors and applied the GPS module instead. In the project we have setup a database that contains the GPS data, and build a webpage that the data can be found on, aswell as applied it to a map, so you can see where the car has been. Visit Joerha.dk to view the webpage.

On the flowchart at the top, you can see an overview of the technologies that have been used in this project. To get the most out of this Instructable, you need to have familarity with some, if not all of the technologies used. It is linked according to usage. Having understading of Github will also help, as we have linked to our github repositories.

List of utilities:

  • Github
  • Raspberry PI/Raspbian
    • Python
  • Node.js
    • Express.js
    • Sequelize.js
    • MySQL
    • Bootstrap

Step 1: Database Setup

In this segment we will talk about how we build the database system that our GPS data is pulled from. The database is build in MySQL according to the picture above, where we have two tables - “Users” and “GPSEntries”. In users we have “Id” as our primary key. It is used as an unique identifier. “Name” is the name of the user currently logged in. “Apikey” is the unique key given to the user to access the API. “Active” is to check if the user is active, we can deactivate the user, so he can’t access the database. “CreatedAt” and “UpdatedAt” is made by the process we used to build the database.

In the “GPSEntries” table we have all the attributes containing data from the GPS module. “Time” is the current time of the GPS module, we use it to show time of the posting. Then we have the position in coordinates, aswell as “speed” and “heading”. We also have alot of error attributes, that shows if there is an error in the data from the GPS, fx in the coordinates. We have added them to the database, but we do not show them on the webpage. “UserId” is a foreign key that contains the “id” from the Users table. That is used to show which user posted the data.

Step 2: API

In this segment we will talk about the API that controls the database and pastes the data to it. The web API is built with Node.js, which utilizes Express.js and Sequalize.js.

Node.js is used to run JavaScript serverside, where as it is normally used primarily for client-side scripting on a webpage.

Express.js is the framework we used to build the API.

Sequalize.js is used to make the links between the Gps data, and the database attributes. It uses a method called ORM (Object-Relational Mapping) to do this. This is also where “CreatedAt” and “UpdatedAt” is created (Shown in step 1).

The API can be used by visiting api.joerha.dk. Then add /gps to the url, that will show all the data in the database in JSON format. To control how many entries you want, you can add /2 (The user) and /x (number of entries) to the url. Fx api.joerha.dk/gps/2/10 will show the 10 latest entries. An outtake of the formatted data is shown in the picture above.

Code can be found here: Github

Step 3: GPS/Python Application

In this segment we will talk about the script which runs on the raspberry
and collects the GPS data, and sends it to the API.

To collect the data from the GPS we are using a daemon called gpsd (Picture 1). This is where we collects the data that we post to the database, and the basis for our GPSEntries table. The script that pulls the data from gpsd and posts it to the API, is written in python.

The application initializes a thread, so it can run both gpsd and our program at the same time. The Gpsd data is being streamed continuously while the GPS is active (Picture 2).

Then we make a while loop that continuously posts its payload to the API containing the GPS data. The data is formatted as JSON. The payload consists of the attributes seen in the GPSD. The .fix tag acts like a snapshot of the current data, and sends that to the API. This is done by request.post, and uses the url and API key. Print (r.status_code) is output to the user, to know whether the data got across properly. Time.sleep (0.5) is how often the data is posted (Picture 3)

Code can be found here: Github

Step 4: Webpage for the Project

In this segment we will talk about how we made our webpage that shows the data, and other information about the project. The site is build with HTML, css and JS.
To start with we used Bootstrap 4.0, which is a library for HTML, css and JS. It comes with alot of functions that helps you build your website. We have used it for the navbar at the top, aswell as the row and column setup that the site is build with. Then we have another small css script controlling the colours of the background and headers. Untop of that we have made use of a library called lightbox, so you can click the pictures and they pop-up. The contents of the site contains a google map, a table of data, a video of the car in action and a link to this very page.

The google map is the most interesting. The map is loaded through a google API, where an unique API key is inserted for it to work. The data is streamed to the map in an interval of 500ms. We have made a function where the last 100 data points in the database is shown as markers, so you can follow where the car has been. This is done through what is called an AJAX call.

The data sets in the GPS data table is requested in the same way. In the table you can see the last 10 entries, updated in real time when the GPS is active. We retrieve data from the database in an interval of 500 ms.

Code can be found here: Github



    • Microcontroller Contest

      Microcontroller Contest
    • Make it Move Contest

      Make it Move Contest
    • Casting Contest

      Casting Contest

    We have a be nice policy.
    Please be positive and constructive.