TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: Building a GPS receiver

552 pointsby codyd51about 1 year ago
Hi everyone!<p>Shortly after publishing my iOS 4 jailbreak last October[1], I got to work on my next hobby project: a from-scratch homebrew GPS receiver, which can solve the user’s location solely from billions of radio antenna samples.<p>I took a commodity SDR (alongside the Python standard library and numpy) and built a signal processing pipeline that can detect and track GPS satellites over many minutes, drop and pick up satellites as they come in and out of view, and precisely determine the user’s position and clock inaccuracy.<p>All told, gypsum can go from a cold start to a fix on the user’s position, and the precise time, in less than a minute of listening to the antenna. I went on a journey of learning how to detect and track satellite signals that are literally too quiet to hear, and I hope that some of the magic comes through in the posts!<p>After implementing this myself and walking the long road of getting it working, I’m left completely stunned by the brilliance of GPS, across so many axes. I hope you enjoy the read!<p>On a more personal note, I’ll be starting a new job next week which isn’t as amenable to publishing side projects, and therefore this will be my last publicly-published project for some time. I’ve had great experiences making and sharing projects on here, and I’m really grateful for the positive feedback that’s been shared!<p>[1]: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=37736318">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=37736318</a>

30 comments

amlutoabout 1 year ago
&gt; Just one problem: you won’t find any SDR on the market that will claim to be able to sample a wave oscillating over a billion times a second.<p>This was true, but not any more. You can get truly impressive “direct RF sampling” or “direct RF conversion” receivers that are more than fast enough for GPS. For example:<p>Xilinx RFSoc: <a href="https:&#x2F;&#x2F;www.mouser.com&#x2F;datasheet&#x2F;2&#x2F;903&#x2F;ds889_zynq_usp_rfsoc_overview-1670395.pdf" rel="nofollow">https:&#x2F;&#x2F;www.mouser.com&#x2F;datasheet&#x2F;2&#x2F;903&#x2F;ds889_zynq_usp_rfsoc_...</a><p>A nice National Instruments article: <a href="https:&#x2F;&#x2F;www.ni.com&#x2F;en&#x2F;solutions&#x2F;aerospace-defense&#x2F;radar-electronic-warfare-sigint&#x2F;advantages-of-direct-rf-sampling-architectures.html" rel="nofollow">https:&#x2F;&#x2F;www.ni.com&#x2F;en&#x2F;solutions&#x2F;aerospace-defense&#x2F;radar-elec...</a><p>And their referenced off-the-shelf hardware: <a href="https:&#x2F;&#x2F;www.ni.com&#x2F;en-us&#x2F;shop&#x2F;category&#x2F;flexrio-custom-instruments-and-processing.html?productId=230187" rel="nofollow">https:&#x2F;&#x2F;www.ni.com&#x2F;en-us&#x2F;shop&#x2F;category&#x2F;flexrio-custom-instru...</a><p>One might be forgiven for being a bit puzzled as to why NI thinks that direct RF conversion is cost-effective but nonetheless sells the device for $30k :) That being said, if I were prototyping a system that wanted phase-coherent wideband reception around 3 GHz and I had a proper lab and budget, I’d buy a few of these. If I were to go to production, I’d either wait for costs of a homemade board to come down a bit or see whether a traditional heterodyne receiver could do the trick.<p>Hmm. For military applications, if I were concerned about really advanced RF-seeking weapons pointed at me, a direct conversion receiver is probably great — there won’t be any leakage of the LO that an enemy device could try to detect.
评论 #40043653 未加载
评论 #40050999 未加载
AdamJacobMullerabout 1 year ago
Cool article.<p>Whenever I see &quot;from scratch,&quot; I&#x27;m always curious to see how from scratch the author actually means so I&#x27;ll admit I was a bit disappointed to see that the hardware was just RTL-SDR. Still, the protocol decoding was very interesting and the result is great.<p>&gt; GPS was launched in 1978, which was 45 years ago at time of writing. Five billion people are currently under 40 years old, so well over half the world’s population has never existed in an environment but this.<p>A note based on this. While GPS was around since 1978 the signal was intentionally degraded with a process known as &quot;selective availability&quot; until 2000. This largely rendered GPS unusable for many many purposes, definitely useless for road navigation, it had some limited utility in areas like backcountry navigation and was definitely useful for marine navigation.<p>&gt; gypsum can go from a cold start to a fix on the user’s position, and the precise time, in less than a minute of listening to the antenna<p>This is very impressive and outclasses what I see even commercial receivers doing today, do you have any idea how? I remember on road trips in the early 2000s I would have to sit on the side of the road and wait for the GPS receiver to get a fix (a 15-20 minute process, when it worked) before we could leave. Or, more likely, my mother would just start driving with paper maps.
评论 #40045267 未加载
评论 #40042471 未加载
评论 #40045414 未加载
评论 #40042930 未加载
评论 #40043598 未加载
评论 #40042939 未加载
评论 #40043016 未加载
评论 #40042137 未加载
评论 #40042931 未加载
magnatabout 1 year ago
Note that GPS receiver capable (i.e. not artificially limited) of providing navigation data while moving 600 m&#x2F;s or higher used to be considered munition by ITAR. The amount of legalese at updated ruling [1] is well beyond what I can make sense of, to the point I don&#x27;t even know if it still applies.<p>While we&#x27;re at SDRs, ITAR is also responsible for takedown of passive radar GNU Radio module made by Kraken RF team.<p>[1] <a href="https:&#x2F;&#x2F;www.space.commerce.gov&#x2F;itar-controls-on-gps-gnss-receivers-updated&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.space.commerce.gov&#x2F;itar-controls-on-gps-gnss-rec...</a>
评论 #40044101 未加载
blobcodeabout 1 year ago
A good, decently detailed look at signal processing required. I also like <a href="https:&#x2F;&#x2F;ciechanow.ski&#x2F;gps&#x2F;" rel="nofollow">https:&#x2F;&#x2F;ciechanow.ski&#x2F;gps&#x2F;</a>, which has some fantastic visuals to go along with this explanation.
评论 #40045445 未加载
sizzzzlerzabout 1 year ago
Brilliant! I have no idea what the technical background of the author is but for anyone to tease apart the vast, complex, details of the GPS universe is a massive feat. Coupled with his ability to craft software to both assist his analysis and to implement the final solution, he has created a magnificent project. I&#x27;ve been studying GPS and worked with it professionally for a number of years and I still don&#x27;t know everything about it. I&#x27;m looking forward to digging into the code. Kudos to the author!
评论 #40051036 未加载
评论 #40047998 未加载
tylerchrabout 1 year ago
Super impressive. Can’t agree more with the author that GPS is a stunningly clever engineering achievement.<p>For those interested in the story of the development of GPS, I found “GPS Declassified” by Richard Easton to be an engaging retelling.
评论 #40043632 未加载
评论 #40051031 未加载
OmarShehataabout 1 year ago
Amazing! I also had exactly the same experience that led me to research this a few years ago, realizing that:<p>- GPS works even in airplane mode (while on a literal airplane) - It works without cell service, or wifi, or anything - The United States of America controls the GPS constellation, and they can (and have!) turned off GPS off certain regions at will when necessary (which has prompted other countries to launch their own GNSS constellations) - GPS satellites don&#x27;t send down a location, they only send down time<p>I think it&#x27;s a really fun exercise to do this with data you receive on your phone. Your phone has a direct link to satellite.<p>(side note: I recently learned the basic principles of star navigation, and while it is a completely different mechanism, it also relies very much on keeping accurate time, which I thought was a fun symmetry!)
评论 #40043787 未加载
评论 #40047828 未加载
评论 #40043428 未加载
评论 #40050881 未加载
评论 #40045892 未加载
评论 #40044228 未加载
wglbabout 1 year ago
&gt; Have you ever noticed that your Maps app still works during a flight?<p>Yes, and I use that to take pictures of features below my as we fly from one place to the other.<p>If you have a iPhone, when you land, those pictures will be associated with the place you were when the photo was shot. This enables you to locate those curious features you happen to see.
noman-landabout 1 year ago
I really love how this article is paced in real time from the first person as a learning adventure. Even down to the search terms used and the inner monologue. This is my absolute favorite kind of tutorial because you&#x27;re not just being taught to fish, you&#x27;re being shown how go about sourcing the parts to built your own fishing machinery.
评论 #40051059 未加载
js2about 1 year ago
A documentary which interviews the principals involved in the creation of GPS (<i>The Lonely Halls Meeting</i>) is on YouTube:<p><a href="https:&#x2F;&#x2F;youtu.be&#x2F;Z5N4CqJLAhQ?si=lvaQZv-WG3ab_gEI" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;Z5N4CqJLAhQ?si=lvaQZv-WG3ab_gEI</a>
throw0101cabout 1 year ago
Standford has&#x2F;had a course that is available online on GPS&#x2F;GNSS and a lot of the nitty-gritty details:<p>* <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;playlist?list=PLGvhNIiu1ubyEOJga50LJMzVXtbUq6CPo" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;playlist?list=PLGvhNIiu1ubyEOJga50LJ...</a>
评论 #40051152 未加载
评论 #40049415 未加载
michaeltabout 1 year ago
Great project, thanks for posting it!<p>It just so happens I&#x27;ve got an RTL-SDR, a GPS receiver that outputs raw pseudoranges, and a signal splitter that lets me put the signal from one antenna into two receivers.<p>So if you like I can get the pseudoranges out of a commercial GPS receiver, and the raw signal from an RTL-SDR at the same time, which <i>might</i> help you pinpoint your last bit of location inaccuracy.<p>Would you be interested in that? Or do you consider this project complete?
评论 #40051117 未加载
seba_dos1about 1 year ago
&gt; I’ll be starting a new job next week which isn’t as amenable to publishing side projects<p>What does a job have to do with publishing hobby projects?
评论 #40049767 未加载
ck2about 1 year ago
If you really want to see all the gps-like services out there and have android, you must play with the open-source GPStest<p><a href="https:&#x2F;&#x2F;github.com&#x2F;barbeau&#x2F;gpstest">https:&#x2F;&#x2F;github.com&#x2F;barbeau&#x2F;gpstest</a><p>I&#x27;ve been fascinated for years how badly GPS does altitude (mean-sea-level)<p>in the USA they had to build an augmentation system for airplanes for altitude (WAAS)
评论 #40052527 未加载
ChuckMcMabout 1 year ago
Just want to say Cody this is a super write up!
NovemberWhiskeyabout 1 year ago
It&#x27;s not entirely clear to me from the write-up, but it seems some of the problems that the author had with the &quot;tracker&quot; come from attempting to do carrier phase synchronization (with the Costas loop) before any kind of clock recovery.
评论 #40051167 未加载
tgsovlerkhgselabout 1 year ago
Wow, thank you! While I had a glimpse at various parts of the madness earlier, this is the first article that actually brought it to a level where I could convince my brain to understand it end-to-end.
评论 #40051024 未加载
ruudaabout 1 year ago
&gt; Have you ever noticed that your Maps app still works during a flight?<p>I noticed the opposite, it always fails to locate any satellites, even when GPS is still turned on in aeroplane mode. I&#x27;m not sure why.
评论 #40045029 未加载
评论 #40046196 未加载
AlexanderTheGr8about 1 year ago
&quot;Interestingly, the only thing stopping civilians from using the P code is the knowledge of the value of its chipping sequence. If the formula to generate the P code was publicly known, there’d be nothing stopping civilian GPS receivers from locking on to it, with the exact same techniques as are used for the C&#x2F;A code.&quot;<p>I didn&#x27;t finish reading the whole thing but was curious. Is there any way of brute forcing it or some other trick to get the chipping sequence to get the P code for more precise GPS?
评论 #40050043 未加载
评论 #40049772 未加载
wkat4242about 1 year ago
I find it amazing that they managed to design and build all this in the 1970s when computers were only in their infancy and SDR was complete science-fiction.
jeffypooabout 1 year ago
This was a delightful read. Reminded me of my time working on low power FHSS radio gear. We truly take modern wireless technologies for granted!
评论 #40051099 未加载
two_handfulsabout 1 year ago
Beautifully written, and educational. Plus very impressive technically! I wish I could upvote this more than once. Thank you!
评论 #40055236 未加载
bArrayabout 1 year ago
Would like to add that I have purchased myself the SDR so that I can replicate the experiment&#x2F;work done here - it seems super cool!
CamperBob2about 1 year ago
Anyone manage to get this working with pip in Windows? After installing the dependencies:<p><pre><code> C:\dev\gps\gypsum-release&gt;gypsum-cli.py Traceback (most recent call last): File &quot;C:\dev\gps\gypsum-release\gypsum-cli.py&quot;, line 9, in &lt;module&gt; from gypsum.receiver import GpsReceiver File &quot;C:\dev\gps\gypsum-release\gypsum\receiver.py&quot;, line 20, in &lt;module&gt; from gypsum.navigation_message_decoder import EmitSubframeEvent File &quot;C:\dev\gps\gypsum-release\gypsum\navigation_message_decoder.py&quot;, line 8, in &lt;module&gt; from gypsum.navigation_message_parser import ( File &quot;C:\dev\gps\gypsum-release\gypsum\navigation_message_parser.py&quot;, line 62 *bits ^ SyntaxError: invalid syntax</code></pre>
评论 #40042639 未加载
darkhornabout 1 year ago
Is it possible to trick phones with a jammer in a large area to make it look like all phones are in a specific point on Earth. Only with a jammer?
评论 #40042511 未加载
评论 #40042774 未加载
评论 #40042520 未加载
评论 #40043506 未加载
评论 #40043301 未加载
emehrkayabout 1 year ago
Does anyone know how the data a stored, where at, what tech etc? I can only assume that the retention policies are in decades
评论 #40057386 未加载
kaitocrossabout 1 year ago
Does it only support the US-made GPS (NAVSTAR GPS) or other GNSS systems like Galileo as well?
评论 #40051093 未加载
noman-landabout 1 year ago
Really amazing piece of work. I look forward to digging into it. Thanks for sharing.
hcfmanabout 1 year ago
Really nice writeup!
pictureofabearabout 1 year ago
Now do it for the encrypted signal (the P(Y)-code)!