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