View All Posts
read
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi

Learn how to connect a GPS board to an ESP32 and parse location data using the Arduino framework while walking around. This tutorial also includes tips on troubleshooting serial connectivity with a USB to UART board and a terminal program.

Related Content
Transcript

[0:00] We had a few questions from the Walky Talky project
[0:03] around ESP-NOW and what the actual range is.
[0:06] They are all good questions - and they’ll be answered in a future video.
[0:09] This video is a bit of prep work - I wanted to get a GPS board connected up to my ESP32
[0:15] so I could test ESP-NOW out in the wild while walking around.
[0:19] But before cracking on I’d like to thank the PCBWay for sponsoring this video.
[0:24] PCBWay offer PCB Production, CNC and 3D Printing, PCB Assembly and much much more.
[0:29] They are great to deal with and offer excellent quality, service and value for money.
[0:34] Check out the link in the description.
[0:36] So, I had a look in my box of old bits and bobs and found this board.
[0:41] I backed the Tessel 2 on Kickstarter quite a few years back and ended up with a whole bunch of modules
[0:46] it seems to be a bit of a dead project now - let me know in the comments if they are still going.
[0:50] This is an A2235-H GPS module from Lantronix.
[0:55] It’s a nice little GPS board.
[0:58] And as with most GPS devices, it supports a serial connection
[1:01] so wiring it up is simply a case of connecting power, along with the RX and TX lines.
[1:06] There are a couple of interesting wrinkles with this board.
[1:10] The first on is that it has an ON/OFF pin to control whether it is switched off or on.
[1:14] This needs to be taken high to make the board wake up.
[1:18] The other wrinkle is that it uses a proprietary binary protocol called SiRF
[1:22] and needs to be instructed to switch to the standard NMEA text format.
[1:27] You can do this with some pull up resistors on a couple of the pins
[1:31] but as these pins are not broken out on this board I’ll need to send it a special command to switch to NMEA mode.
[1:37] Testing out a GPS board out is pretty straightforward
[1:40] most of us will have one of these USB to UART boards laying around
[1:43] so we can simply wire the GPS board up and use a terminal program.
[1:47] If you’ve got a standard GPS board then it will probably be running at 9600 baud, 8 bits no parity and 1 stop bit.
[1:56] But check the docs for your board to confirm this.
[1:59] With my board, it boots up in SiRF mode and you connect to at 115200 baud.
[2:06] As you can see it immediately starts to output binary data.
[2:10] To switch into NMEA mode we need to send this binary command.
[2:14] This will switch the device to NMEA with a baud rate of 4800.
[2:19] Once we send this message we can reconnect our terminal at 4800 baud
[2:24] and we start to see the nice NMEA ASCII messages coming through.
[2:28] At the moment the board is on my desk, so we aren’t getting any location data.
[2:32] You can see this in the GGA messages that are coming through.
[2:36] However, after leaving it in the window for a while we can get a fix and location data starts to come in.
[2:42] If you’re having problems with your GPS board,
[2:44] hooking it up directly to your computer and using a terminal program is definitely a good first step towards troubleshooting.
[2:51] A good sign that things are happening is the RX LED flashing indicating that data is coming in from the board.
[2:58] Moving onto the ESP32
[3:01] Using the GPS board with the ESP32 and the Arduino framework is pretty straightforward.
[3:06] The ESP32 has 4 serial peripherals available and it’s also very flexible on the pins that can be used.
[3:12] So we can wire our GPS board up to pretty much any pins we want.
[3:16] You can also include indicator LEDs on the RX and TX lines to help diagnose any problems.
[3:23] Both the RX and TX lines are active low so you just need to connect up a resistor and an LED to the 3.3V line.
[3:30] You should see the RX line pulsing fairly regularly as data is transmitted from the GPS.
[3:37] Setup and reading from the Serial ports is very easy with Arduino code.
[3:41] For my GPS board, I have some initialisation to do.
[3:44] I need to connect initially at 115200 baud and I need to toggle the On/Off pin from low to high.
[3:52] Once I’ve done that I just send the command to switch to NMEA mode and reconnect at 4800 baud.
[3:59] With that done we can simply read from our serial peripheral and output the results to the default Serial.
[4:05] Running this up we can see that we get the NMEA messages echoed from the GPS board.
[4:10] This is all very good, but it’s not very usable yet.
[4:12] You really need to parse the messages coming in and turn them into position data.
[4:16] We could write out own parser, but honestly, life is way to short for that.
[4:21] There are a lot of GPS libraries available it’s worth having a look around to find one that suits your needs
[4:26] if you’ve got any favourites then please leave some suggestions in the comments.
[4:30] I’ve found a very nice C++ library for doing the parsing of the data that seems to work well on the ESP32
[4:37] and also plays nicely with streaming data directly from the serial peripheral.
[4:41] With it wired up we now get a lot of interesting data from our GPS device
[4:45] probably a bit too much information to be honest
[4:48] for most projects, you’ll generally just want the latitude and longitude along with some indication of how good the fix is.
[4:54] I’ve hooked up the GPS to my TTGO display board
[4:57] and set it up to show some of the information coming from the GPS.
[5:01] I’ve put the code for this on GitHub - the link is in the description.
[5:05] The code supports both SiRF based GPS boards and standard NMEA GPS boards.
[5:08] There’s a video coming up in the pipeline where we’ll use the GPS to measure the effective range of ESP-NOW in the real world
[5:14] so don’t forget to subscribe.
[5:16] Thanks for watching
[5:17] and I’ll see you in the next video.


HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
Blog Logo

Chris Greening

> Image

atomic14

A collection of slightly mad projects, instructive/educational videos, and generally interesting stuff. Building projects around the Arduino and ESP32 platforms - we'll be exploring AI, Computer Vision, Audio, 3D Printing - it may get a bit eclectic...

View All Posts