Introduction: LTE Arduino GPS Tracker + IoT Dashboard (Part 1)

Picture of LTE Arduino GPS Tracker + IoT Dashboard (Part 1)

Introduction

What's up guys! This Instructable is a follow-up of my first Instructable on using the Botletics LTE/NB-IoT shield for Arduino so if you haven't already, please read it to get a good overview of how to use the shield and what it's all about. In this tutorial I'll focus on IoT data logging, and specifically, GPS and temperature tracking and provide you will all the code and guidance you'll need to hit the road and test it out!

This Instructable is mainly focused on the LTE shield that I personally designed and built, but everything here (including the Github Arduino library) should work on SIMCom's 2G and 3G modules like the SIM800/808/900/5320 as well since it's just an updated version of the Adafruit FONA library. Regardless of hardware the concept is exactly the same and you can do lots of cool stuff with this, including sensor data logging, remote weather monitoring, auto theft karma GPS tracking, etc... so read on!

Step 1: Gather Parts

Picture of Gather Parts

The list is the same as in my first tutorial and is really simple!

  • Arduino Uno, Mega, or Leonardo. Alternatively you can use any other 3.3V or 5V microcontroller but you would have to wire up the pins externally.
  • Botletics SIM7000 LTE Shield Kit (comes with the shield, dual LTE/GPS uFL antenna, and stacking female headers). Make sure you go through this tutorial to select an appropriate version!
  • Hologram SIM card. The first SIM card (called the "developer" SIM card) is completely free (just pay $5 shipping) and comes with 1MB of data per month! In the USA you will most likely be on the Verizon network if you use the Hologram SIM card.
  • USB cable to program your Arduino or to power it.

For the GPS tracking test!

  • You can use a car USB adapter to power your Arduino while testing the shield on the road.
  • Alternatively, you can use a battery pack (7-12V) to power the Arduino via the VIN and GND pins.

Step 2: Physical Assembly

Picture of Physical Assembly

Now that you have all your parts, here's a quick recap of what you need to do to set up your hardware:

  • Solder the stacking female headers onto the shield. See this tutorial on how to do that.
  • Plug the shield into the Arduino, making sure to line up all the pins so you don't damage them!
  • Insert the SIM card as shown in the picture. The metal contacts face downward and make note of the location of the notch in the corner.
  • Plug in your Arduino to your computer using a USB cable. You might notice that the shield's green power LED doesn't light up. That's perfectly normal because the shield's PWRKEY pin needs to be pulsed low for a little bit in order to turn it on. The example Arduino sketch in the following section will take care of that for you!
  • Attach the dual LTE/GPS antenna to the uFL connectors at the right edge of the shield. Note that the wires will criss-cross so don't plug in the wrong ones!
  • You're all set for the software!

Step 3: Arduino Setup & Device Testing

Picture of Arduino Setup & Device Testing

Arduino IDE Setup

If you haven't already, please see the "Arduino IDE Setup" and "Arduino Example" steps in my previous Instructable to make sure your board is functioning properly. In those instructions you'll need to download the library on the Github page and open the example code "FONA_LTE_Test". (As you can tell After following those instructions you should have tested the network connection, GPS, and posting data to dweet.io.

IoT Example Sketch

Now that you've tested the core features of your shield, load the "IoT_Example" sketch in Arduino IDE. You can also find it here on Github. Upload this code to your Arduino and open the serial monitor and you should see the Arduino find the SIM7000 module, connect to the cell network, enable GPS and keep trying until it obtains a fix on location, and post the data to dweet.io. This should all run without changing any line of the code, assuming you're using the LTE shield.

By default you will see the following line define the sampling rate (well, actually the delay in between posts).

#define samplingRate 30 // The time in between posts, in seconds

If this line is left uncommented, the Arduino will post data, delay 30s, post data again, repeat, etc. During the 30s delay you can do things like put the Arduino in low-power mode and fancy things like that, but to keep things simple I'll just use the delay() function to pause the operation. If you comment this line the Arduino will post data then go directly to low-power sleep mode indefinitely until you press the reset button on your Arduino. This is useful if you are testing something and don't want to burn your precious free data (although honestly each post uses practically nothing) or maybe you have external circuitry to reset the Arduino (555 timer? Accelerometer interrupt pin? Temperature sensor interrupt? Think outside the box!)

The next line sets whether the shield will turn off after posting data or remain on. You might opt for the former choice by uncommenting the line if you're only sampling once in a while, but if you have a relatively high sampling rate you will want to leave the line commented so that the shield stays on and doesn't have to re-initialize, re-enable GPRS and GPS, etc. When the shield is left on it's able to post extremely quickly!

//#define turnOffShield // Turn off shield after posting data

Also keep in mind that this example automatically fetches the module-specific and globally-unique IMEI number of the SIM7000 and uses it as the device ID (or "name" if you prefer) to identify the device when it posts data to dweet.io. You can change this if you want, so I'd thought I'd just let you know :)

To check if your data is actually being sent to dweet.io, simply fill in the appropriate info and copy/paste the URL into any browser:

dweet.io/get/latest/dweet/for/{deviceID}

where {deviceID} should be substituted with the IMEI number which is printed out in the serial monitor at the beginning, right after the Arduino finds it. After entering that URL in your browser you should see a JSON response like the following:

{"this":"succeeded","by":"getting","the":"dweets","with":[{"thing":"112233445566778","created":"2017-12-28T23:32:39.803Z","content":{"lat":11.223344,"long":-55.667788,"speed":10,"head":75,"alt":330.7,"temp":21.2,"batt":3630}}]}

Looking at the "content" you should see the latitude, longitude of your location, your speed (in kilometers per hr), direction heading (degrees), altitude (meters), temperature (*C, but feel free to convert in the code), and the supply voltage in milli-Volts (which for the LTE shield should always be around 3600mV because of the voltage regulator). For more info on the NMEA data string you can take a look at page 149 of the SIM7000 AT command manual.

Once you verify that your setup is successfully sending data to dweet, let's set up the dashboard to view all our data on a nice interface!

Step 4: Freeboard.io Setup

Picture of Freeboard.io Setup

For this tutorial we'll be using freeboard.io, a really cool IoT dashboard that can connect with numerous cloud platforms like PubNub and dweet, as well as other features like JSON and MQTT. As you probably have guessed we'll be also using dweet.io which is used in the example code from the previous section. As an important note, dragging panes in freeboard.io doesn't seem to work in Chrome so use Firebox or Microsoft Edge instead. If you don't, it can be a real "pane" to re-arrange the items on your screen!

Account & Device Setup

  • The first thing you'll need to do is create an account by clicking the red "START NOW" button on the freeboard.io home page, enter credentials, and click "Create My Account". You will then get an email notification confirming your new account.
  • Now click "Login" at the top right of the home page and after signing in you should see your "freeboards", which are just dashboards that you set up fr your projects. Obviously if the account is new you will see nothing here so just enter a new project name and click "Create New" near the top right. This will then bring you to an empty dashboard where you can set up the interface just how you like it. In freeboard there you can set up various "panes", and each pane can have a single or multiple "widgets" which are things like graphs, maps, gauges, etc. that display your data in some way.
  • The first thing we need to do now is to set up the actual source of data, which is your Arduino + LTE shield. To do that, click "ADD" on the top right under "Datasources". Next, select "Dweet.io" and enter any name you want under the "Name" field. However, make sure that under the "Thing Name" field you enter the shield's IMEI number instead of any arbitrary name, because that's what freeboard will use to pull data from dweet.
  • After clicking "Save" you should see your device appear under "Datasources" as well as the last time it sent data to the dweet. You can also click the refresh button to check for the latest values, but freeboard will update by itself so you normally shouldn't have to use that button.

Dashboard Setup

Now let's take a look at how to set up the actual bells and whistles that you want to see on your screen!

  • To add a pane, click the "ADD PANE" button at the top left and you will see it add a small window on your screen. However, there's nothing here yet because we haven't added any widgets!
  • To add a widget click the little "+" button on the pane. This will bring up a dropdown menu with various widget options. Since we're going to be doing some GPS tracking let's pick the "Google Map" widget. You should then see two fields, the latitude and longitude. In order to fill these out properly your device needs to have posted to dweet already. Assuming it has, you should be able to click "+ Datasource", click on the datasource (the "SIM7000 GPS Tracker"), then click on "lat", which is the variable name that the shield uses when posting to dweet. Repeat the procedure for the longitude field and click the slider at the bottom if you want the map to draw lines between data points to mark where you've been.
  • Now you should see a small map of your approximate location! To test if the map works, try changing your current GPS lat/long to something slightly different by changing, for example, the first digit after the decimal point of the lat/long values in the dweet URL that was printed in the serial monitor in Arduino IDE when the shield posted data. After tweaking them, copy and paste the URL and execute it in your browser.
dweet.io/dweet/for/112233445566778?lat=11.223344&long=-55.667788&speed=0&head=10&alt=324.8&temp=22.88&batt=3629
  • Now switch back to freeboard and you should see that it graphed your tweaked location and drew an orange line between the points! Cool stuff huh? So I think you get the picture that our GPS tracker will send location data to dweet for you to see it on freeboard in real time or after your adventure is over

Extras

Since our little GPS tracker sends not only lat/long data but also altitude, speed, heading, and temperature, let's throw in a few more widgets to make our dashboard more colorful!

  • Let's begin by adding a new pane then to add a gauge within the new pane click the "+" button in the pane and select "Gauge". Just like before, use the datasource and select "speed" as the data we're interested in fetching for this gauge. You should then see a nice gauge on your dashboard!
  • Repeat this for the altitude and temperature values.
  • Now for the heading let's add a "Pointer" instead. This is essentially a compass because it starts off pointing up (North) at 0 degrees and rotates clockwise for positive headings.. Perfecto!
  • To change the size of the pane, hover over the pane which contains the map and you should see a little wrench symbol at the top right. Click that and enter a title for the pane and enter "2" under "Columns" to increase the width of the pane.
  • To change the locations of the panes simply drag them around! You can also experiment adding a "Sparkline" which is basically just a line graph so you can see not only the latest data but historic data as well.

Have fun and set it all up how you like it because we're ready to go out on a field trip!

Step 5: Testing

Picture of Testing

To test your setup I would recommend setting the sampling time to a lower value, like 10-20s so that you can capture your journey with higher resolution. I would also leave the "turnOffShield" variable commented out so that the shield doesn't go to sleep. This allows it to post data in quick succession.

After uploading the code to your Arduino, either get a battery pack (7-12V) to power the Arduino or simply plug the Arduino in using a car USB adapter. I personally found this method easier :)

Next, open up freeboard somewhere so when you return you can see the results! Once you plug in the Arduino you're good to go! Start driving around, get some coffee, return home, and you should see the data plotted on freeboard. If you really want (I don't recommend this while driving...) you can view the freeboard data on your phone in real time as your friend drives the vehicle. Fun stuff!

Step 6: Results

Picture of Results

For this test my dad and I went to get some chicken drums at Trader Joe's (onmomnomnom...) and we collected some pretty accurate data. I had the device send data every 10s and the max speed from the trip was about 92khm (around 57mph) which is quite accurate because we kept an eye on the speedometer the whole time. The LTE shield definitely does its job quite well and sends data to the cloud very quickly. So far so good!

However, perhaps the not-so-good news is that the map widget on freeboard isn't as great as I had originally thought. It doesn't allow you to move the location of your mouse and it stays centered on the last location so it's great for things like a car GPS tracker but not if you want to analyze a completed trip with all the data points, especially if it was a long journey.

In this tutorial we learned how to use the LTE shield as a GPS tracker and data logger and how to quickly view the data on freeboard.io. Now use your imagination and apply it in your own project. You can even add on more shields and turn this thing into a low-power solar data logger! (I might actually be planning on doing a tutorial on that in the future!). Because of the limitations of the freeboard map I'm also planning on making a brand new tutorial on how to make your own Android app that fetches the data from dweet and will allow you to graph the location of the tracker on Google Maps with start, pause, and stop features for your trip! Stay tuned!

  • If you liked this project, please give it a heart and vote for it!
  • If you have any questions, comments, suggestions on a new tutorial, or tried this project yourself, definitely comment below!
  • I'll be launching an Indiegogo campaign on Feb 1st to raise funding for the LTE shield in this tutorial so I can mass-produce it, so please share with anyone you think might be interested! You can view the campaign preview here.
  • Follow me here on Instructables or on my YouTube channel to stay updated with my latest Arduino projects! I'm a young engineer with a passion for sharing what I've learned, so there will definitely be some more tutorials soon!

Comments

SameerS16 (author)2018-01-17

Hi, I want to make something for human SOS emergency location tracker and GSM based help text / call (later on). I have the ZBT GPS module and Arduino UNO board with LCD. Will this tutorial work for my GPS module, and can I power it up with 9V battery or similar power source? I want it to be in a compact box that someone can carry in person.

arduinofanboy (author)SameerS162018-01-17

Hi there,
I'm sorry but you're using a completely separate piece of hardware and I don't know enough about it to really give you any guidance on it. Best of luck with your project though!

arduinofanboy (author)2017-12-30

Hey guys, I just created a sequel to this Instructable that shows you a better way of viewing your data and real-time map on an amazing free IoT dashboard called ThingsBoard.io! Check it out here: https://www.instructables.com/id/LTE-Arduino-GPS-Tracker-IoT-Dashboard-Part-2/

About This Instructable

1,356views

33favorites

License:

Bio: I'm a young engineer with a passion for DIY and electronics! Learn to share, share to learn!
More by arduinofanboy:LTE Arduino GPS Tracker + IoT Dashboard (Part 2)LTE Arduino GPS Tracker + IoT Dashboard (Part 1)ESP32 BLE + Android + Arduino IDE = AWESOME
Add instructable to: