Lora Based Gps Tracker Using RAK3172

by gabriel.bertet in Circuits > Electronics

2077 Views, 7 Favorites, 0 Comments

Lora Based Gps Tracker Using RAK3172

IMG_20220318_171601.jpg
IMG_20220318_171650.jpg
Sans titre.png
IMG_20220312_182142.jpg
Sans titre.png

Hi, today i will show you how to build a lora based GPS tracker. The system work on battery and send battery level through a low power network(Should work on V2). Gps coordinate are send at regular interval. The system is fully configurable by using some commands send by "the thing network". This system doesn't need any sim card or a subscription. I know, this system could look a lot bigger than what you expected, but 3/4 of the size is used by the battery .

Supplies

RAK3172-300x227-1-removebg-preview.png
Sans titre.png

Power Management (Theory)

Lipo-battery-guide-Voltage-vs-capacity-used-percentage.jpg

Well first thing first, because i used a lipo battery the operating voltage should be as low as possible. As you can see on the image, the voltage of the lipo will drop. That's a terrible problem ! If the voltage goes to low , the system will stop working. As we get a 2S lipo battery, the voltage show on the graph has to be double. In my case, the voltage have to stay above 3.6*2 = 7.2V .

Then i had to check if the minimum input voltage of the LDO is lower than this limit. In the datasheet, it says the minimum input voltage is at 4.4V. It's great because the LDO wont be limiting factor.

I chose to run my system at 3.3V because it's easier and also because I had a lot of 3.3V LDO into my workshop.

Power Management (Application)

Sans titre.png
IMG_20220208_205743.jpg
Sans titre.png

Now, let's solder all the alimentation part together !

I used a JST connector to connect the battery to the charge controller, but you should consider to use XT60 instead because the maximum current flow into JST is about 3Amps whereas XT60 is 60Amps.

You can follow the diagram to solder the battery . Be really careful of polarity (i destroyed one controller). On the picture, i have two pack of wire solder on the board because my battery doesn't have 2 pack of wire.



Gps

download.png
NEO-6M-GPS-NMEA-Sentences-Output-On-Arduino.png

Okay so the main part of this project is a GPS. It is really easy to make it work ! But understand the data isn't.

Just wire every thing together using the documentation show above. Sometimes, after a long journey, the device could take a long time to work correctly. In that case you will have to go outside or put the module next to the windows. It took me 20 minutes to work.

The code i used is not mine , but it is working perfectly to prototype.

You should get a NMEA frame ! This is a bit complex but we will only focus on the line starting by $GPGGA.

  • The first information is a time code (UTC)
  • The second one is Latitude
  • The third is Longitude
  • Then goes something that we wont use
  • Then number of satellite
  • Then again a non interesting data
  • And the altitude

Downloads

Rak3172 & TTN

Sans titre.png
Sans titre.png
Sans titre.png

Now , let's take a look to the transmission process ! 

I chose a RAK as Lora emitter because it's quite simple to use and well documented first , but also because it has the Lora WAN stack . This component is based on a stm32 microcontroller and has multiple feature.

I said Lora or Lora Wan , but what is the difference ? The answer is easy to understand : Lora is the technology and Lora wan is the network. Some Lora module are only build to make pear to pear communication (P2P) , whereas other have the ability to connect to gateway and Lora wan network .

Then , what is TTN ?

TTN also called "The things network" is a public network made by numerous users around the globe.


The rak as it's own software to save some parameter. This software is called RAK serial port tool . In order to configure it , wire the rak by using a USB to Uart adapter. Then plug the module into your computer and launch the Rak software.

Click on the right com port number and select Baud Rate : 9600 , now just write into the text box (next to the send button) "ATE" . If everything work correctly , the receiving box should show a perfect "ok" . Many command can be used on the rak , and you can find them all just there .

Be careful, in reality you will have to add the \r\n string after your command to be understood by your rak. But the software do it by itself.

By default, the Lora module is working using class A, this mean that the rack can only receive data when he also send data. It is also using OTAA protocol to make connection to Lora network.

Okay, to connect to the thing network you will need some information. You can find them by using :

AT+NWKSKEY=? 
AT+APPSKEY=?
AT+APPEUI=? 
AT+DEVEUI=?  

Now just go on The things network consol and follow this procedure :

  1. If you don't have an account just create one / log in
  2. Click on "Go to application"
  3. Click on "Add application"
  4. Write application id field (it could be whatever you want)
  5. Then click on "create an app"
  6. Click on "add end device"
  7. Go on manually
  8. Choose the right Frequency plan (868 MHz for Europe)
  9. Select Mac V1.0.2
  10. Select RevB
  11. Now , write every information starting by DEVEUI


Okay, well now, you will have to initialize the connection to TTN . To do so just write into your serial software :

AT+JOIN=1:0:10:8  

If everything goes write you should be able to see +EVT:JOINED.

Sometimes , you will have the +EVT:JOIN FAILED message. That mean there is no Lora connection where you are .

Now, i will show you how to change settings through the Lora network !

First you will have to go into your end device and find this messaging page. Then click on downlink and choose the port number 9. Okay now you just have to enter your command. This command is an hexadecimal command. The first two number are used to choose which settings it will have to change. Then the other are the value to applied to this setting .

For example, here i choose to set the delay between two measurement at 165 min.


Software Codding

Sans titre.png
Sans titre.png

The code for the attiny is really simple !

It take data from the Gps module and and only save the position. This is possible thanks to tinyGps. Then it send all the data to the TTN server. Be careful , you have to change all the information (DEVEUI ...) by yours . Obviously this key are not mine and only random number !

All the Lora function are store into a function file and can be compile as one unique file. To do so just click on the little arrow in the top right corner of Arduino Ide. Then write a name and press enter. I should create a new file saved into the same folder. Now just copy/paste the code into this file and it's done.

In the future i will try to make a RAK3172 library ;D .

PCB

Sans titre.png
Sans titre.png
52713d5b757b7fc0658b4567.png

I designed a PCB using Kicad, and i just add a switch to power up the all things. The circuits approximately measure 5cm by 3cm. I only use pcb because the rak is mainly available on special package and have to be solder. If you don't want to use it, you should consider to buy rak breakout board . The circuit is quite simple, it just connect two Uart RX and two Uart TX on a aTtiny85. Pin 3 is used for Transmission to the GPS and Pin 2 for receiving from the GPS . Same thing for the RAK3172 on pin 0 and 1 !

Because we won't use the transmitting line to the GPS, i will delete it on a V2 .

I would like to do a voltage measurement using the CAN of the attiny,but the voltage reference on the attiny is 1.1V or Vref. The problem is that I have only 2 pins left . In my case i will need 3 of them ( 2 for analog measurement and 1 for Vref. So if you have any idea please comment !


You can downloads all files on my GitHub !

Wiring Diagramm

schema global.png
Sans titre.png

Okay , now as you can see , I'm an expert using paint ( not really ) !

I made two different diagram. The first one work on battery and are a little more complex . It goes from the battery to the charger and to the motherboard. Again , don't forget to close the switch before any charging process.

The second one is directly plug on a socket or on a car battery. For this one you will need a buck converter ! I personally use a LM2596 . The buck will drop the voltage from 12V ( car battery voltage ) to 5V, but you will need to calibrate this module. To do so just use a screw driver and move the little potentiometer to adjust the voltage.

3D Modeling / Printing

Sans titre.png

For this step, obviously you will need a 3d printer! If you can't print at home, you can buy it online or create a small box using junction box.

I printed it using PLA (so it is water sensitive) . It took me approximately 10 hours to print at 100% scale for the back and 4 hours for the top. I choosed to print it all black because it will be easier to hide.

Assemble

IMG_20220227_165125.jpg
IMG_20220227_173317.jpg
IMG_20220227_172127.jpg
IMG_20220227_165134.jpg
IMG_20220312_174253.jpg
IMG_20220318_171640.jpg

To build this thing, start by soldering the power jack using the following diagram :

Then add the battery and the charge controller and glue it into the box.

I recommend to let the charge controller back side in contact with air because this surface is globally a lot warmer than others and air will help to dissipate some heat.

To Solder the pcb, i used a ts100 soldering iron and a TS-1 tip . This totally do the job when combine with some flux. All the board could be solder by hand. I used two 10uF capacitor next to the ams1117 and three 100 nF decoupling capacitor next to the microcontroller. Then i added a 100k ohm resistor (R1) and a 330 ohm resistor called (R2).

On some pictures, two capacitor are missing , but you have to solder them


Programming

IMG_20220318_172540.jpg
IMG_20220318_172553.jpg
Sans titre.png
Sans titre.png
Sans titre.png

In order to program the µC , i used a ISP programmer. If you don't have any programmer, you can follow this steps. To do it , you will need an Arduino Uno and Arduino Ide.

Start by uploading the ArduinoIsp sketch on your Arduino Uno. Then choose the right programmer, it should be "Arduino as ISP" . Next, you have to Select Attiny85 and an internal 16 Mhz oscillator .