Determine your location to the centimeter
around the globe? For everybody, not only for the military? Only with an ESP32 and a decent
GPS receiver module? Not possible! Wrong, it is possible. You can even earn some money by
building your own base station and connecting it to a global network! When I got this board
from Michael, a viewer of this channel, I was hooked on the idea of trying and
understanding this relatively new technology. What about you? Interested, too? Then, follow along.
Grüezi YouTubers. Here is the guy with the Swiss accent. With a new episode and fresh ideas around
sensors and microcontrollers. Remember: If you subscribe, you will always sit in the first row.
By the end of this video, you'll have a clear understanding of how it's possible to measure
the distance to fast-moving satellites more than 20,000 kilometers away and use that information
to calculate your exact position. You'll also see how this technology enhances standard GPS. To
demonstrate, we'll use my DIY ESP32 base station, connect it to a global network, and see if it can
really deliver centimeter precision. And finally, learn what DePINs are and how you can earn money
with this technology. This isn't just about the technology, it's about the practical applications
and the potential it holds for us all.
GPS was invented in the 1970s and implemented
from the 1980s on. In 1995, I had my first Garmin handheld GPS receiver for pilots. It
was mind-boggling because from now on, I always knew where I was and where the forbidden zones
started. A big stress reliever! The accuracy of this degraded non-military system was around 100
meters. Useful for pilots because they use wide “airways”, but not yet for car drivers. After the
gulf war, the US military stopped the artificial degradation of the GPS signals and so improved its
accuracy. I strongly suggest reading or listening to “You Are Here” if you are interested in how
it all began. Other nations like the Chinese, the Europeans, and the Russians started to build
their own “GPS” systems. Together, they are called “Global Navigation Satellite System”, short GNSS.
How does GNSS work? I will use GPS to explain it.
The most important fact is: In one microsecond,
light and also radio waves travel about 300 meters and 30 cm in one nanosecond.
If we want to measure the distance with a precision of 3 meters, we have to be able to
measure time with a precision of 10 nanoseconds, and if we want to measure 3 cm, we
need to get to a precision of 100 picoseconds. Not bad. Keep in mind:
These satellites are 20’000km away, move at high speed, and have to have exactly
the same synchronized time. At first glance, this seems to be impossible! But let’s
see how they managed to make it work.
To determine its position, a GPS receiver needs to
calculate the distance to at least four satellites by measuring the timing of the signals. For
that, it listens to 1575.42MHz or L1, where all GPS satellites transmit their signals. In the
meantime, other frequencies were added, mainly L2 at 1227.6MHz and L5 at 1176.45MHz. The engineers
back in the 1970s had to solve two main problems:
1. How to decode very weak signals
traveling 20’000 km through space?
2. How to distinguish between signals of
different satellites on the same frequency?
Let’s monitor these three frequencies with
a Spectran SDR receiver. All contain more or less random noise with no visible carriers.
Interesting! If I connect the same antenna to a proper GNSS receiver module, it shows my
position. Obviously, there are “hidden” signals on these frequencies. How does this work?
Back then, they decided that each satellite transmits its own “pseudo-random” pattern of
1023 bits with a rate of 1.023Mbit/s. That is the reason we can hardly distinguish them
from noise. Because these patterns are known to all GPS receiver modules, they can compare
the signals coming from all satellites with all known patterns. Mathematicians call this process
“cross-correlation”. The result is a peak when the received signal pattern and the code of one
particular satellite match in time. Nearly no peak is visible for signals of other satellites. So,
such a peak contains two parts of information:
1. Which satellite sent the signal
2. Its precise timing
The width of peak is about 1ns or 30 meters. Even
if you can determine the peak very accurately, the precision of this signal is limited to a
few meters because there are other sources of inaccuracies, as we will later see. This is the
precision of our smartphones, for example. After receiving the signals of all visible satellites,
our GPS receiver knows the distance to these satellites. But only if the clocks of all
satellites and our receiver are exactly synchronized. Keep in mind: A difference of one
nanosecond means already an error of 30 meters!
This is why all satellites have built-in atomic
clocks that are regularly adjusted by ground stations. Our GPS receiver module has a clock,
too. But to save cost and space, not a very precise one. So, the whole thing would not work
unless we use a trick that is later revealed.
The next problem: To get our precise position,
we need not only the distance to the satellites; our receiver also needs to know the
momentary position of each satellite, also with the precision of meters. We will
later see where it gets this information from.
To calculate a three-dimensional position,
the distance to at least three satellites and their precise positions are needed. The
trick to working with the unprecise receiver clock is to use the signal of a fourth
satellite to calculate the precise time. Now, we are ready to retrieve the exact
position with a precision of a few meters everywhere on Earth. It's incredible,
but it works with a receiver module for a few dollars and such tiny antennas.
As said before: We want more. 100 times more precision. Sounds impossible again!
Let’s try to understand which problems we have to solve to get to such a precision:
1. We have to be able to measure the travel time of the signal to the picosecond
2. We have to compensate for position errors of satellites to the centimeter
3. We have to account for time delays influenced by the ionosphere. The ionosphere is
the upper part of the atmosphere and consists of charged particles. They are heavily influenced by
the sunlight and therefore change all the time
4. And correct many more small
errors in the overall system
Let’s start with the first problem: Increase the
precision of the timing. As we saw before, GPS has a modulation frequency of 1Mb/s. But its “carrier”
frequency is around 1.5GHz and, therefore, a wavelength of around 20 cm. What if we would be
able to determine where on this wave we are? Then, we would know our position to the centimeter!
Technically, the place on a wave is called “phase”, BTW. Problem solved? Unfortunately,
not. As shown before, GPS has a precision of some meters. Let’s assume a precise GPS position
of 5 meters. Then, 20 wavelengths fit inside these 5 meters. This is rightly called ambiguity because
we know exactly where we are on the wave but, unfortunately, not on which one. Not good!
Clever engineers developed real-time kinematics or RTK to solve this problem: Let's assume you have
two receivers close together. One is fixed, and its position is exactly known; the other can be
moved, and its position is not known. Both measure the position with GPS and determine their phase.
Because one knows exactly where it is, it can determine on which wave it “sits” and determine
the actual difference between its position and the GPS position. If it would transfer this
information to the second receiver, this one could determine its exact position, too. And we solved
problems 2, 3, and 4. Because both receivers are very close, all these differences are nearly
the same and are included in the “correction” signal transmitted. Cool! If we call the fixed
receiver “base” and the second one “rover”, we have our RTK system. Of course, it is way
more complex, but for today, we stick with that.
Fortunately, the distance between the base
and the rover can be up to about 20 km, and the system still works.
The next problem: How is this correction signal transmitted from the base to
the rover? Here, we have four typical scenarios:
1. Directly by using a transmitter on the base
and a receiver on the rover. High-end lawn movers attach a base to the charging station and the
rover to the mover. Also high-end drones work with fixed bases close to the pilot. In this scenario,
each rover needs a base station. Commercial base stations, unfortunately, cost a fortune
2. Via internet. The base and the rover are connected to a service. The base transmits
the correction signal to the platform, and the rover receives a valid
correction signal without “owning” a base. Signals can be transmitted via Wi-Fi
3. Or via mobile networks. There are many such professional services available.
Usually very local and very expensive because building and maintaining bases every
20 km is not cheap. RTK2GO is a free service, but it only works if you have a base in the
vicinity. The closest one to my home is 40 km away. So later, I will build my own for
a fraction of the price of a commercial one
4. Via satellite. Companies like u-blox
operate many base stations around the world. Because they cannot afford one every
20 km, they placed them about 150km apart and do some math to their signals. Like that, they
typically get a precision of below one meter, but not to the centimeter. Still ok for many use
cases and available globally. But not cheap.
The board I got from Michael offers transmission
methods 2, 3 and 4. The ESP32 includes Wi-Fi, and this 4G modem can connect to
the next cellular tower. It even contains a satellite receiver that can receive
u-blox data from space. They offer a limited service for developers free of charge, BTW.
It also contains this small u-blox RTK receiver that covers the most important bands, L1
and L2, and shows its position on a map. So, let's check how it works. As said before,
I wanted the best precision. So I built a base station and connected it to RTK2GO.
We go away from the house to reduce signal reflections and start with GPS only. As expected,
the position moves a few meters. With RTK enabled, this changes considerably. The position is solid.
And if I move the receiver, or should I say, the antenna, along a straight line, we see
this straight line also on the map. Impressive! Here, you see typical applications
for RTK. Maybe something is for you?
To build a rover, we just need an RTK-enabled GPS
receiver and an ESP32 if we have Wi-Fi available, plus Michael’s Arduino software. Sparkfun
offers many such receiver modules and also wrote the required libraries.
We know now that RTK works, and we saw this rover board. But I also promised
that you could earn money with RTK. How does that work? And how can we build a base station?
Helium, with its network of LoRaWAN gateways, was one of the first companies that created
a new industry called “decentralized physical infrastructure networks”, short DePIN.
DePIN companies try to replace investors with crowdfunding. Like Helium, they create
a cryptocurrency and pay the owners of the infrastructure with this currency instead of
real money till they get paid by the customers. Everybody who had to work with professional
investors knows that this would be a very good idea for startups because often, these “investors”
are arrogant and a pain in the ass. People who watched my Helium video know that I was not happy
about this company. Mainly because there was no real business behind transferring LoRa messages.
But is DePIN in general a bad idea? I do not know yet because it is too new. But I give it a
chance if there is a real business case behind it. Selling RTK correction data seems to be a
multi-million-dollar business already now. So this market should be better than LoRaWAN messages.
And its future application is much broader.
A few DePINs have already tried to get such
networks up and running. One of them is Onocoy. This network has two advantages:
1. They allow Makers to create their own hardware and do not sell overpriced “miners”
2. Its president is one of the founders of u-blox, a no-nonsense guy also with a Swiss accent
How can we build such a base station? You need four things to get the best signal
and, therefore, the most rewards:
- A special antenna for all GPS bands
- An RTK receiver for all bands
- An ESP32
- Software to read the receiver and send the correction signal to the service
You can buy this receiver with an ESP32, but it is expensive and only delivers data to Onocoy. This
is why I built one myself. Mine delivers data to Onocoy and RTK2GO. I do not show how to build it
here, but you can find links in the description if you are interested in this technology. Anyway,
connecting four wires between the receiver and the ESP32 board and loading the software is
all it needs. The rest is configuration.
Keep in mind: Commercial stations cost thousands
of dollars. This miner still costs roughly 700 dollars, including shipping. My setup was less
than 300 dollars. It's not cheap, but maybe I will get the money back or make more than I invested.
It has already started to earn some cryptos.
Even if I will not earn a lot, I had a good
time learning and experimenting with this technology. It helped me understand one of the
key technologies of our civilization, and I pay respect to the engineers who, more than 40 years
ago, believed that such a system was possible and started to work on it. Keep also in mind that GPS
satellites synchronize most of our clocks and are part of each cellular tower, for example. I made
a video on how you can use this precise timing for cheap in your lab. Jamming these signals
seems to be a major threat during war times.
I also promised to tell you how GPS receivers get
the positions of all satellites. The pseudo-random code contains a very slow modulation that
transfers all this data, also called “almanac”. It can take more than 10 minutes to get all this
data. This is why all GPS modules have a small battery attached. They store the almanac data and,
because satellites do not frequently change their path, can use “old” data to get a faster fix.
If the GNSS receiver has an internet connection, like a Smartphone, it uses “assisted GPS” to
get this information much faster directly via the internet. This is why your Smartphone
nearly immediately knows its position.
In this video:
- We learned that GPS needs extremely precise and synchronized
time signals to measure the distance between satellites and our receiver
- It needs at least four satellites, three to determine the three-dimensional position
and one to correct the time of the receiver
- Its accuracy is limited by the slow
modulation as well as by variable influences by the ionosphere, for example
- If we want to get to centimeter precision, we need to measure the phase of the carrier signal
as well as account for the real-time difference between a precise position and the signal
- This difference is measured by a base station and transmitted to a “roving” station to enable
the rover to solve the ambiguity and determine its exact position. The distance between a base and
a rover should be below 20 km to get an RTK fix
- Commercial services sell such
correction signals for quite high prices. RTK2GO offers a free-of-charge
service but does not have broad coverage
- This is why I built a base and connected
it to Onocoy, a DePIN company that tries to build a global network of base stations and
sell the data for a lower price. I will be paid in cryptocurrency for my services. Who
knows if I will get the invested money back
This was all for today. As always, you find
all the relevant links in the description.
I hope this video was useful or at
least interesting for you. If true, please consider supporting the channel to
secure its future existence. Thank you! Bye