In this tutorial, I will show you how to connect the SAMD21 to the GPS receiver, GP-20U7, and 2.8 TFT touch shield, and show date, time, and location information on the TFT display.
In this test example, the GPS module will stream date, time, and position updates every 5 seconds over a serial UART, which you can view in the TFT display for position, date, or time tracking purposes.
The SAMD21’s most exciting features is SERCOM – its multiple, configurable serial ports. The Arduino IDE equips the SAMD21 with two hardware serial ports by default, plus a third “USB serial port” for communicating between the serial monitor.
Each of these serial ports has a unique serial object which you’ll refer to in code:
To use the Serial Monitor to debug, you’ll need to use
If you want to use the pins 0/1 serial port, you’ll need to use it with Serial1 or "Serial to pins 30/31".
GPS Receiver - GP-20U7
This 56-channel GPS receiver module provides position and time readings with high sensitivity tracking capabilities and low power consumption "40mA@3.3V (max), " ideal for portable applications.
___________________________________ | GPS | SAMD21 | SAMD21 | | Port 0 | Port 1 | |_________|_________________________| | GND | GND | GND | | TX | RX (pin 31) | RX (pin 0)| | 3V | 3V | 3V | |_________|_____________|___________|
This is a little explanation about the time and time zone.
To find your own time zone, you first need to find your longitude. Once you have the longitude of the place you're at, now you can find your timezone. There are different ways to get the time zone.
Longitude is usually measured in degrees, minutes and seconds. Here's how longitude converts into your personal timezone: 15 degrees of longitude = 1 hour difference; 1 degree longitude = 4 minutes difference. 15 minutes of longitude = 1 minute difference; 1 minute of longitude = 4 seconds difference. 15 seconds of longitude = 1 second difference; 1 second of longitude = 0.066 (recurring) seconds difference
My home is at 117° 4' 50.1924'' W, so converting this all to seconds of longitude gives:
(degrees x 3600) + (minutes x 60) + (seconds) = (117 x 3600) + (4 x 60) + (50.1924) = (27421200) + (240) + (50.1924) = 421490.1924 Now find the time zone difference in seconds of time: 421,490.1924 / 15 = 28,099.34616 seconds get hours: divide 28000 by 3600 equal 7 hours and some left over get minutes: 99 / 60 minutes 1 and some left over get seconds: 99 - 60 equals 39 seconds so the result is: 7 hours 1 minute and 39 seconds
In my case:
timeZone = floor(longitude / 15);
Floor because I'm in Tijuana and the difference is -7, maybe you will need to use the ceiling.
- D0 -- Unused
- D1 -- Unused
- D2 -- LCD data bit 8
- D3 -- LCD data bit 9
- D4 -- LCD data bit 10
- D5 -- LCD data bit 11
- D6 -- LCD data bit 12
- D7 -- LCD data bit 13
- D8 -- LCD data bit 14
- D9 -- LCD data bit 15
- D10 -- LCD CS pin, active low
- D11 -- LCD RS pin
- D12 -- LCD WR pin
- D13 -- LCD RD pin
- D14(A0) -- Touch Screen Y-
- D15(A1) -- Touch Screen X-
- D16(A2) -- Touch Screen Y+
- D17(A3) -- Touch Screen X+
- D18(A4) -- Unused
- D19(A5) -- Unused
- samd21: https://learn.sparkfun.com/tutorials/samd21-minidev-breakout-hookup-guide/all
- TFT Touch Shield: http://wiki.seeedstudio.com/wiki/TFT_Touch_Shield_V1.0
- SparkFun: https://www.hackster.io/capdeadpool/samd21-gps-test-guide-a0aff9