GPS Monitoring With OLED Display Project

by Mohannad Rawashdeh in Circuits > Microcontrollers

4432 Views, 15 Favorites, 0 Comments

GPS Monitoring With OLED Display Project

Inkedgps 019_LI.jpg
gps 013.JPG
ATGM332D_GPS_2020-Mar-13_06-25-25PM-000_CustomizedView18877315795.png
20191224_063241.jpg

Hello everyone, in this quick article I will share with you my project :ATGM332D GPS module with SAMD21J18 Microcontroller and SSD1306 OLED 128*64 display, I built a special PCB for it on Eagle Autodesk, and program it using Atmel studio 7.0 and ASF4 so in this article I will share with you this journey and the files I used if you are interesting to do it by yourself.

Now if you are programming your MCU/development board using Arduino , this project should be relatively easy to you , but here I will use ASF4(Advanced software framwork 4) from Atmel/Microchip which is based on C language and would give you an idea for how to read the GPS NMEA message using USART Asynchronous driver (Callback) and provide you with a simple library that you can use it with any Micro-controller and different platform by simply add the appropriate Driver you are using to receive the message from the GPS(NMEA message).

I will divide this article to:

  1. PCB Design.
  2. BOM you need to assemble the PCB
  3. Quick look to the software and the code itself and a test for the hardware and software.
  4. lastly but not least some point of improvement for this project.

You will find all the material related to this project on Github ( Here )

PCB Design Using Eagle

ATGM332D_GPS_2020-Mar-13_09-23-34PM-000_CustomizedView36851274035.jpg
ATGM332D_GPS_2020-Mar-13_06-42-45PM-000_CustomizedView1329099772.png
board image.png
schematic2.png
board image2.png
fusion360.png
ATGM332D_GPS v4.png

This project mainly based around ATGM332D GPS Module , simple GPS to use since it only needs a couple of passive components to work, and we could add a backup battery to save the time/date if we shutdown the main power source from the module.

and to control all the signals in the circuit I went with ATSAMD21J18B microcontroller , TQFP64 package since it has 128KByte of program memory storage and 32KByte of data memory (and I have a plenty of them laying around my workbench).

the circuit shall be powered by USB 5V source , also the USB can act as virtual COM port (CDC USB) and you can add a code for it if you want to communicate with the device through USB.

for the display I selected SSD1306 0.96' OLED display with SPI bus , it's small but it's the suitable for the PCB size I wanted, the board dimension 100x31 mm.

programming the Microcontroller will be through SWD programmer (I use Atmel ICE ) and will connect it through 1.27mm 10p pin header.

also I used Fusion360 to get a 3d view for the board and you can see some rendered image for it as well.

Soldering the PCB

20200315_110511.jpg
20200315_110535.jpg
20191226_102404.jpg
20191226_102408.jpg
20200315_111011.jpg
20200315_111421.jpg
20191226_111354.jpg
20191226_111401.jpg
20191226_111404.jpg
20191226_121411.jpg
20191226_121427.jpg
20191226_121458.jpg
20191226_121505.jpg
20200315_120650.jpg
20200315_120653.jpg
20200315_120657.jpg
20200315_133938.jpg
20200315_133949.jpg
20191226_121406.jpg
gps 009.JPG

You have the choice to order a stencil with your PCB , it's easier to apply the solder paste on the board using the stencil , I used hot plate to solder the components together , using hot air is also OK but be careful while soldering the LED since they are so sensitive to heat.

soldering the bottom side is a bit easier since it has only the SWD pin header and the backup battery , which you can solder them using soldering iron.

before you connect the circuit with any USB power source, check for any short circuit.

connect your GPS antenna and make sure you solder it's connector properly, I fixed the antenna on the bottom side of the board.

Software ... Functionality...results

gps 002.JPG
gps 014.JPG
20200109_171114.jpg
20200310_141337.jpg
20200310_141646.jpg
gps 010.JPG
gps 012.JPG
gps 017.JPG
gps 022.JPG
Inked168_LI.jpg
Inked169_LI.jpg
Inked172_LI.jpg
Inkedgps 019_LI.jpg
Inkedgps 021_LI.jpg
ATGM332D GPS Project

The software will be divided into 4 parts:

  1. USART to communicate with ATGM332 GPS module.
  2. SPI to communicate with OLED.
  3. USB CDC.
  4. GPIO to control LEDs

first connect the USB connector to power on the Circuit and then connect the ribbon cable with SWD connector.

Download the Code from github(Link here).

to get the Geo-Location you have 3 different NMEA messages options:

  1. GPGGA
  2. GPRMC
  3. GPGLL

I used GPRMC sentence to obtain the location , time and date (time is 0.0 GMT) so in the code you will find:

GPRMC.Enable=1;/*0 if no need for this message*/

GPGGA.Enable=0;/*0 if no need for this message*/

GPGLL.Enable=0;/*0 if no need for this message*/


you can enable them all together and read them at the same time get the data you need.

once there is a valid GPRMC sentence , the GPRMC.Ready will become 1 and you can obtain all the data available in this sentence , check this link to see the data available in this sentence.

simply if Fix is 'A' that's mean the Location are available , if Fix is 'V' that's mean the location is not available.

notice that ATSAMD21 has internal RTC , but here I don't use it and instead I use time and Date directly from the GPS, so if you don't want to use the CR1220 Backup battery , once you disconnect the USB power source you will lose the Time/Date and for the next time you power on the circuit the time/date area on the display will be empty until the GPS has a valid time/date value.

the display will show you the current status of the GPS and will show the Geo-location once it's available, however there are 3 LEDs on the Board:

  1. Green LED connected to PA06 , and will blink if there is a valid Geo-location value.
  2. Orange LED connected to PA07 and will blink once a second if there is no valid Geo-location.
  3. Red LED this one connected to PPS pin of the GPS Module and will blink only when there is a valid signal related to the Location.

Results:

The circuit worked very well with me , get the Geo-location from the GPS took 20-30 seconds outdoor with clear sight to sky and between buildings without any problem even with antenna on the bottom side of the board.

3D Printed Case... Sort Of

m1.PNG

I prepared a simple case (more precise holder) for this circuit but because of COVID-19 epidemic and the lockdown I'm in right now , I couldn't reach my 3d printer to print it, so I will update this section with stl file and a photos for the holder once it's available.

Things to Improve...

20200316_123257.jpg
Antenna passive.png
InkedSSD1306 code_LI.jpg
  1. Moving the SWD connector to the top side since it's easier to connect it with your programmer.
  2. Powering the circuit from Lithium battery, I did it by soldering a jumper and it worked fine , bare in mind that the Linear (LDO) regulator has V drop voltage if the (Vbat - Vout) less than the Vdrop limit the circuit might not work properly .
  3. making a user button a bit bigger so it will be easier to press.
  4. adding USB CDC code so you can communicate/design a special program for MAC/PC/linux.
  5. For the GPS antenna, I used Active antenna for this project, using a passive antenna is a possible, by adding Low noise op-Amp like AT2659 (check also the schematic on ATGM332 Datasheet P.14).
  6. for OLED 0.96' SSD1306 , the official library from microchip originally for 128*32 display , to modify the code to work with 128*64 you have to go to ssd1306.c and modify the code (check the image).