10 ms·
Show HN: Tracking my local bus with a RaspberryPi
- fersarr 4y agoFinally started using my Raspberry Pi! I built a bus clock to know when to leave the house and never miss the bus again. Wrote this little post to share the details and some pictures.
- pmontra 4y ago"Error establishing a database connection" Probably HN killed the server. BTW, where did you buy the Pi, or did you already have it at home?
- noodlesUK 4y agoIt’s sad because I desperately want a raspberry pi or two for some projects I’ve been kicking the can on, but I simply can’t get them for anywhere close to MSRP. The shortage hurts.
- Grimburger 4y agoPerhaps try an equivalent like odroid? You usually get far more compute per $ anyway.
- dual_dingo 4y agoI haven't closely monitored the situation for years now, but it used to be the case that OS/software support for anything than a Raspi was often spotty at best. With a Raspi, you not only have Raspian/RPiOS that fully supports all models back to the first one from 2011, but a decent number of really good alternatives like Fedora, Ubuntu and special appliance variants, e.g. for console emulation etc. In contrast, my last experiments with some other SBCs consisted of downloading some ancient ISO files of questionable provenance from some shady .cn domains. It might have gotten better, but one should carefully investigate the software situation before buying a non-RPi SBC.
- fragmede 4y agoIt depends on your level of expertise and how comfortable you are straying from an online guide. It's just a small matter of computer engineering, for different difficulty values of "just".
- icelancer 4y agoThis is getting significantly better and fast - largely due to RPis being unavailable for 2 years and growing (and won't get better anytime soon). Odroid's ecosystem is quite a bit better these days. I highly recommend getting an XU-4 from Ameridroid or HardKernel themselves (my last order arrived within 10 days from South Korea to the west coast with zero customers issues) for a fraction of the RPi 4 MSRP cost (much less what it actually costs now) and tinker.
- icelancer 4y agoWe switched to Odroid XU-4s for this reason.
- inferiorhuman 4y agoYa know, I just realized I missed the Thursday batch of Pi4s and got to thinking about my ODroid C1. I have generic USB cables and chargers laying around but I still don't know where my non-standard C1 charger went. The last time I made this sort of comment one of the top replies was that Pis are notoriously picky about their power supplies. Be that as it may I've not run into any trouble with my Pis (Zero W + 3B). Hence I'm using my Pis while my C1 sits unused.
- JonathanBuchh 4y agohttps://rpilocator.com https://rpilocator.com is great for finding Pi's closer to MSRP. You just have to waif for them to be in stock.
- deleted 4y ago[deleted]
- TedDoesntTalk 4y agoI have one or two I’ll sell you below MSRP. I don’t use them anymore (barely did did to begin with). Email is in my profile. I just sold a Remarkable2 eink tablet to another HNer this way!
- JoshMcguigan 4y agoThanks for sharing! In the first screenshot of CLI output, it seems to show three buses all being 1 minute out? Am I misreading that?
- fersarr 4y agoYea I was surprised with that one too. It wasn't my local station but I think that sometimes happens when it's a busy station at a busy time so they have more than one bus. Or it might be a bug.
- handelaar 4y agoNot very surprising to me that they'd start bunching by Bethnal Green tube having all just been slogging their way through Mare Street in Hackney, honestly
- will0 4y agoLooks like it's been hugged to death. Archive.org link: https://web.archive.org/web/20221102223146/https://purplehoisin.com/i-built-a-bus-clock-with-a-raspberry-pi/ https://web.archive.org/web/20221102223146/https://purplehoi...
- fersarr 4y agoWow! I wasn't expecting this at all. Thanks for the cozy hug of death :) Also, thanks for posting the archive link! I'll try to make it more resilient for the future.
- jpribyl 4y agoThe problem I’ve faced is that the official live update arrival times are often wrong. I’ve fantasized for years about engineering a network of self contained + solar powered microcontroller / camera units that I could place on top of bus stops to track them myself. Then again, by the time I get around to it the official arrival times will likely have become more reliable. Any rate, great write up- thanks for sharing!
- acomjean 4y agoIt’s a fun problem. We hire 4 trolleys for our open studio event in Somerville. One of our volunteers bought some smart phones, and we pulled a together a php and MySQL back end, some google maps and Trolley Tracker. We can see them bunch up over the course of a day. A lot of transportation services have tracking now.
- RektBoy 4y agoWhy is the live data wrong? Why is it called live data, then? HH For example, here in Prague, trams always arrives on time schedule or few minutes after that. (you can wait 2minutes lol) Also all of our public transport has publicly accessible GPS tracking. Buses are more off of the time schedule, but you can check the GPS and compute the live time. And subway doesn't make sense to track, since it arrives every few minutes at any station.
- jpribyl 4y agoHa! I should have specified, I’m in the US- I think it’s a large number of factors that ultimately boil down to “there’s no incentive to be accurate” our buses are often 15-30 minutes late. I don’t think this is very typical, but I have even had a bus driver stop mid route, say “this is as far as I’m going today”, kick everybody off, and drive away
- samstave 4y agoHa! me and several engineers from Lockheed built just such a thin in 2007 -- but we couldnt get funding for it (we built the RFID tracking system for the military) but we were too early for the market at the time and people werent educated about tracking so we go rejected all over....(it was for fleet operations - we built the tracking systems for all weapons shipments and containers for the military at the time.
- omh 4y agoI love the form factor of this and the ambient data. TFL do have some quite good APIs so you could use those rather than scraping the HTML. https://tfl.gov.uk/info-for/open-data-users/api-documentation https://tfl.gov.uk/info-for/open-data-users/api-documentatio... I think you need to register but they seem happy to have amateurs and enthusiasts using them and they work quite well.
- beckingz 4y agoOh this is cool. It's a shame that the WMATA bus data here in DC is so bad. The APIs are fine, but the data is all over the place.
- throwoutway 4y agoAnyone know what that screen is? I don’t see a link in the article
- fersarr 4y agoOh Sorry! I should have added that. Here's a link to it https://thepihut.com/products/hdmi-4-800x480-ips-touch-screen-gpio https://thepihut.com/products/hdmi-4-800x480-ips-touch-scree...
- parkersweb 4y agoIf you’re interested in this you might also be interested in a project I’m currently involved with. There’s a legal obligation in the UK for bus operators to supply live vehicle location positions and static timetable data to the Bus Open Data Service here : https://data.bus-data.dft.gov.uk https://data.bus-data.dft.gov.uk
- fersarr 4y agoOh that's great to know! There seems to be an experimental API already, will have a look :) thanks!
- gedy 4y agoI know buses rotate and really not practical, but I'd try putting an Apple AirTag somewhere on the bus discretely and track that way.
- wildrhythms 4y agoWouldn't this cause frequent bus riders to get an alert that they're being followed?
- WaitWaitWha 4y agoFor a minute, before following the link, I was thinking 'why not just look up the schedule? And, did you leave a RasPi on a bus?! Those things are like $200 now! Maybe you can get it back at the bus depot...'
- nashashmi 4y agoWhat do you mean 200$
- bombolo 4y agoThey are a bit hard to find at the moment.
- michaelt 4y agoIf you want a new raspberry pi 4 8GB today, you basically have to buy from a scalper at a cost of around $200 [1] Or you can try to monitor https://rpilocator.com https://rpilocator.com more than the scalpers do, and you might be able to get one for $100 instead. [1] https://www.ebay.com/sch/i.html?_from=R40&_trksid=p2380057.m570.l1313&_nkw=raspberry+pi+4+8gb&_sacat=0 https://www.ebay.com/sch/i.html?_from=R40&_trksid=p2380057.m...
- deleted 4y ago[deleted]
- fersarr 4y ago:) We could hide it inside a bus and make a geolocation game!
- goatcode 4y agoIn some areas, it would be necessary to somehow install trackers on your busses that you use. Depending on the jurisdiction, I've had to deal with busses either being possibly 10 minutes early, or missing their stop time by up to half an hour.
- geraldwhen 4y ago
- scary-size 4y agoAwesome! Did something similar using GTFS data. Used an e-ink display though: https://github.com/Scarysize/transit-pi https://github.com/Scarysize/transit-pi
- gala8y 4y agoE-ink is much better choice. Bus & Mag-Lev?
- scary-size 4y agoBus and ferry in Hamburg
- gala8y 4y agoCool.
- l72 4y agoI love these types of projects. Being able to automate or make a daily chore easier is so liberating. As a public transit user, I too have written a dashboard for my transit system on top of the smashing dashboard. It runs on a raspberry pi hooked up to a TV in my front room. As others below have complained about arrival estimations being unreliable (or these days where we are low on operators and have a bunch of ghosts buses!), I found having a map with real time location gives me a better idea when I should leave: https://blog.line72.net/2019/08/02/announcing-realtime-bus-tracking-for-smashing-dashboard/ https://blog.line72.net/2019/08/02/announcing-realtime-bus-t...
- allenbina 4y agoI'm amazed at my own programming progress over the past 10 years. I used to read these posts in awe of how people knew how to do such fascinating things that seemed so magical to me. 5 years ago I got myself a raspberry pi and an Arduino starter kit and just started playing around with them. I learned python by practicing on leetcode and other sites and I'm able to recognize a lot of libraries and patterns in his code. It's a bit less magical but I have a much more refined appreciation for posts like this.
- deleted 4y ago[deleted]
- sergiotapia 4y agoNext step is realizing that most code is a liability and you will begin to loathe anything "smart". I'm at this step right now. I'm curious if any graybeard out there can share what the next step is. I don't even want smart electrical outlets.
- seanw444 4y agoIt's the natural progression I think. - Step 1. Know nothing about computer technology, and think it's magic. - Step 2. Begin to learn about computer technology, and think it's fascinating. - Step 3. Learn a lot about computer technology, and lose your trust in most developers/engineers that aren't yourself, and avoid said technology.
- beoberha 4y agoThis is extremely accurate in my experience (besides trusting only myself, I don’t even trust myself). In general, the engineers I work with are much less “techie” than a lot of people I know outside of work.
- jaimehrubiks 4y agoIf only the Chicago CTA api was close to reliable... It's well known for the ghost buses and disappearing trains. However we wouldn't probably need to call Apis, just refreshing their website would work as it's similar to OP's (or Google maps or any other using the apis). The best solution here would be to secretly implant a RPI zero with gps into every bus
- fersarr 4y ago> The best solution here would be to secretly implant a RPI zero with gps into every bus Ha and then you can also create an API for others with that data :)
- seanw444 4y agoNow that would be cool. Although costly, if it were discovered.
- rosnd 4y agoWhy costly?
- alex_suzuki 4y ago> The best solution here would be to secretly implant a RPI zero with gps into every bus From the title, this was what I was actually expecting the article to be about. :-)
- ge96 4y agoHa I taped one (with camera) to my window to spot when the FedEx truck was coming. (no vision just periodic images uploaded to local website).
- fersarr 4y agoWas this in order receive your personal deliveries?
- ge96 4y agoYeah my apt complex sucks, doesn't accept deliveries and FedEx doesn't have tracking like Amazon does. Usually I try to change the delivery address to some hold location but sometimes not possible. It was a lazy update every 5 seconds loop/webpage updates image url with time query. Not great but did it's job.
- ge96 4y agoLooks like I killed my SD card interesting.
- sowbug 4y agoRe future work "It bugs me that I’m fetching this information every 30 seconds even though most of the time I won’t use it": Take a look at Home Assistant, which runs nicely on the same hardware. You get a reasonably capable platform that knows when you're home and can be told a schedule, so you can then limit the checks to times when you'll actually need to know. https://www.home-assistant.io/ https://www.home-assistant.io/
- deleted 4y ago[deleted]
- BrandoElFollito 4y agoI think that the platform is more than reasonably capable. Either your usage fits into one of the zillions integrations (especially via HACS), or you can easily build something alongside with pyscript. The state machine in HA is excellent, I use it for unrelated projects instead of a bus or something like that. The UI is good and is getting better. I wrote years ago my own dashboard (that uses data from HA, among others) but I am slowly getting used to the idea that I may simply replace it with a full-screen page from HA's UI (especially when I manage to have widgets written in Quasar/Vue running correctly)
- habibur 4y ago> Since I already had an unopened Raspberry Pi 3B that I ordered in 2016 (6 years ago!!) The key line. RPi aren't any more available as like before, for your new projects.
- ajsnigrutin 4y agoYep.. I'd have used an esp8266 for this, and kept the rpi in the box, for when I "really need it". And it truly is a sad time for rpi-based projects... it really plugs a gap between cheap microcontrollers and power-hungry servers/PCs,...
- Mumps 4y agoI wonder if a Pi Pico W would be sufficient to run this, even? waaay cheaper (and available).
- ajsnigrutin 4y agoI just took a quick glance at the specs, and sure... running an lcd and parsing some text from the web seems totally doable, and in contrast to RPi (3, 4...), you can actually buy picos :)
- ranger_danger 4y agoNow if only this could be done for public school buses that never show up at the same time. Younger kids are required to be dropped off/picked up in the presence of an adult, but one is often left out in the cold/snow/heat/whatever for far too long wondering if the bus will ever arrive, or if they were already passed by.
- reckless 4y agoI'd definitely recommend you use homeassistant as a front-end for this. You can then update a 'sensor' using an mqtt message.
- wirthjason 4y agoNow if someone can build something to track ghost trains. I’m looking at you CTA!
- teeray 4y agoSmall UX idea: what you really care about is not when the next bus arrives, it’s “can you make it?” Of course, you can arrive at the latter from the former, referencing the current time, and roughly how long it takes to get to the bus stop (with reasonable buffer time). Or you can do this work in code, and put a countdown timer beneath each bus time (such that you walk out the door before time expires and you will make it).
- qwertox 4y agoI have a tablet mounted on the wall which displays different kinds of stuff, like weather conditions and forecasts and so on. Among this is the time of civil dawn, because at this time I don't want to be riding bike anymore since it's getting dark (and colder). Next to it is a countdown timer with an offset of minus two hours, since I do ride my bike around 1 to 1.5 hours. So when I see that this timer is reaching 0, I know that I'm at my last opportunity to go for a bike ride that day. Once it reaches 0, it shows the countdown to the correct, non-offsetted time of civil dawn, but in another color, so that I know that I still have time to make a shorter ride. I barely look at the time of dawn, since the countdown timer is so much more informative for me. It let's me know how many hours or minutes I still have to do things.
- phh 4y agoMy dream UX for that is a single ambient led ranging from green to red, but making it overall usable counting we're two, using two different trains, with different WFH schedule is rather complicated
- Scene_Cast2 4y ago
- ageitgey 4y agoI made a similar thing in London as well: https://twitter.com/ageitgey/status/1383381051154726920 https://twitter.com/ageitgey/status/1383381051154726920 The TfL API is really pretty good - no need to scape pages.
- fersarr 4y agoreally cool! and huge!
- et-al 4y agoFor anyone who's looking to build something similarly, you want to search for your agency's GTFS Realtime feed: https://gtfs.org/resources/gtfs-realtime/ https://gtfs.org/resources/gtfs-realtime/ Transitland offers an API that's easier to use than parsing the agency's XML imho: https://www.transit.land/ https://www.transit.land/ None of this will still solve the issue of ghost busses, though. ;)
- rakoo 4y agoThis is exactly what Web Out Of Browsers (https://woob.tech/ https://woob.tech/) aims to do: get information stored in websites, and offer a programmatic way to use them. There is an application called woob travel that shows timetables: https://woob.tech/applications/travel https://woob.tech/applications/travel. It plugs back ends, each of which is a website. Once parsed, the data is programmatically available for anything. Bonus point for OP: it is all written in python !
- ranguna 4y agoSo, a web scrapper?
- rakoo 4y agoYes a web scraper. But it's not (just) an end to end scraper: it gives you easy access to the data so you can do whatever you want with it. Display a table for easy consumption, store it in graphite for historical data, ring a bell when a threshold is reached...
- quijoteuniv 4y agoFor a moment i though he did a solution for the «ghost buses» . I always used the bus app and it works fine untill, from time to time, you turned 2/3 minutes before to the bus stop, timer goes down, then says due…. And disappears!!! And no bus pass, trust me, i question myself several times. The 254 is a common offender of the “ghost buses” :)
- zeristor 4y ago254? https://tfl.gov.uk/bus/route/254/ https://tfl.gov.uk/bus/route/254/ I was at a TfL hackathon once, at QMW along this route, but that is irrelevant. Strangely TfL seemed to be beholden to Ordnance Survey for some copyright issue, it couldn't have been for the Natrional Grid reference could it? Converting between lat/long to OSgrid was a bit tricky when you have to take the curvature of the Earth into account to get that last bit of accuracy. https://www.movable-type.co.uk/scripts/latlong-os-gridref.html https://www.movable-type.co.uk/scripts/latlong-os-gridref.ht... PS For some reason I almost wrote Couverture of the Earth, just trying to reduce chocolate intake.
- quijoteuniv 4y agoMmm… maybe it was the 271 now that i think of it. But it happen with others too
- selectodude 4y agoIt's somewhat comforting in a bad way that this isn't an issue isolated to my city. We even have the same name for them.
- deleted 4y ago[deleted]
- sorenjan 4y agoWhile this is a nice project, it's basically just simple web scraping. I was hoping for something a bit more interesting, like decoding the radio signals for the bus stop displays[0] and using that data. If it's available from an API it of course makes more sense to use that though. [0] https://www.windytan.com/2013/11/decoding-radio-controlled-bus-stop.html https://www.windytan.com/2013/11/decoding-radio-controlled-b...
- unnouinceput 4y agoOr setup a RPi camera, with OpenCV and recognize your bus while it's around the corner 2 streets before coming to the stop so you know you'll have a full minute until it gets there. I mean a 30 meters pole on top of your house isn't something that hard to do. And the programming of that is so much more fun that just the web scrapping. Plus is actually more accurate than a web scrapping that can have de-synchronizations between that and the real bus.
- deleted 4y ago[deleted]
- dssagar93 4y agoI feel lucky that in India we have an app to track the live location of all the buses. I almost use it daily and plan my day accordingly.
- deleted 4y ago[deleted]
- chandlerswift 4y agoI'd been exploring a similar project a few years ago, and ended up making a map that showed the location of buses along the routes I tended to take. I was pretty happy with it...except for the fact that it was built for the town (Duluth, MN) I went to school in, and I didn't get it finished until finals week of my last semester, and I left town immediately after! https://chandlerswift.com/projects/bus-tracker https://chandlerswift.com/projects/bus-tracker
- bitxbitxbitcoin 4y agoThat board deserves to be on display at City Hall or something. Inspiring work and I lament with you that you weren’t able to use it more than a few days.
- chandlerswift 4y agoThanks! :) I definitely thought about seeing if I made a polished version, if I'd be able to sell a copy to the local transit authority, or something. But it made for a great conversation piece, and was tons of fun to build, so it's definitely a success as far as I'm concerned.
- knodi123 4y agoSmall world. I did this on behalf of BlirpIt for UVM back in 2009 or so. We had trackers on each bus, and they would report location on a certain interval, or whenever the speed changed by a certain threshold from the speed at last report. We had server-side geofences on each bus stop, and defined a "route" that was just a chain of stops, and then we stored a moving average of time between each pair of stops and that was about it. One of the more fun projects I was doing back at that time!
- timmaah 4y agoSmall world indeed. > then we stored a moving average of time between each pair of stops and that was about it. Modest. It got a little more sophisticated once we brought code inhouse.
- KerrickStaley 4y agoI built something similar recently, linking it here in case people want similar projects for inspiration: https://www.kerrickstaley.com/2022/02/25/transit-panel https://www.kerrickstaley.com/2022/02/25/transit-panel I think the biggest difference is that I wrote my version as a web app without any backend (it gets data from a REST API + a hardcoded schedule as a fallback), so that I could host it on GitHub pages and display it on a cheap Android tablet. I still use it every day and am glad that I made it :)
- colanderman 4y agoI did a similar thing as a web page an eInk tablet. What doubled the value for me though was adding a weather widget to the corner. It shows me: * the current temperature * the high or low over the next 12 hours * graphical forecast of the 12 hours (including chance of precipitation) which is all the info I need to know to dress for wherever I'm taking the bus to. You can get all this info (including graphics!) from weather.gov DWML, e.g. https://forecast.weather.gov/MapClick.php?lat=40.7143&lon=-74.006&unit=0&lg=english&FcstType=dwml https://forecast.weather.gov/MapClick.php?lat=40.7143&lon=-7...
- SergeAx 4y agoI recently moved to Belgrade, Serbia and found out that Google Maps are giving sometimes inaccurate data about public transit. All locals are saying that they are using Moovit app. And that app on Android has a widget showing next bus/tram/trolleybus: https://imgur.com/a/OsDyLIR https://imgur.com/a/OsDyLIR
- sashk 4y agoIn February 2020 I did almost same: used beautiful soup to parse njtransit's arrival time website to send a push notification to my phone about 10 minutes before bus arrives to my stop in the morning, so I had enough time to get there. Unfortunately, something happened that year, which forced me not to use bus any more.
- 2143 4y ago> It bugs me that I’m fetching this information every 30 seconds even though most of the time I won’t use it. You don't have to. If the program knows that the bus is 20 minutes away, it could wait 10 minutes or so before doing a refresh (assuming the bus doesn't magically gain a lot of speed in the meantime).
- mcluck 4y agoThese are my favorite kinds of projects. Not some major disruptive application, just a tiny project that solves a real problem for a real person. Great job OP!
- franga2000 4y agoI had this exact idea more than 5 years ago, but the only thing my city provided were horrible PDF timetables. No GTFS, not API, not even an easy to scrape HTML table. Ever since then, my constant side project has been to create a hub for transit and other mobility data from all providers in the country (Slovenia) and just this year, all the work has started coming together. That stupid bus clock will become not only possible, but trivial to build in just a few more weeks. It took a many meetings with company executives and government officials, freedom-of-information requests, hours of reverse engineering apps and subsequently arguing with lawyers... I accidentally stumbled onto two entirely separate multi-million-euro cases of clear corruption in public tenders, several CVSS >= 7 vulnerabilities, got both job offers and legal threats (once from the same company) and throughout the process learned more about multiple different CS fields than I did about even a single one in 3 years of university. So if anyone else wants to build such a clock, but is disappointed that their local bus company doesn't have an API, don't be discouraged. There is always a way. It might cost you a year's worth of free time and most of your sanity, but you will end up with some shiny LEDs on that wall that still won't prevent you from missing the bus and a bunch of extremely niche knowledge. 10/10 would recommend