What’s that plane I hear? Telegram1090

on

Living near a busy airport – and especially directly under one of the major flight paths – means regularly dealing with the noise of planes taking off and landing. In attempt to overcome the frustration of having calls and Netflix binges interrupted every few minutes during the nice months of the year when the windows are open, I set out to make the best of it. Inspired by a post on Hacker News earlier this year about how easy (and cheap!) it is to set up your own ADS-B monitoring station I realized I could build a program that automatically sends me information about the planes I hear flying over my home.

With the idea in mind I purchased an RTL-SDR starter kit and dug up my Raspberry Pi Zero W from the depths of my desk drawers. I was honestly amazed at how easy it was to start playing around with the SDR. Within 30 minutes of opening up the kit, I had everything I needed on my computer to listen to FM radio. A little more fiddling and research and I was listening to the airport radios, followed by eventually getting dump1090 set up on my RasPi and plotting the live data on a map. Once I had dump1090 setup and was able to access the processed ADS-B packets over my network it only took a couple weekends of spare time to put together the Node.js app that runs the Telegram notification bot. So without further ado, here’s a quick little demo:

The Hardware

Parts

The project cost totaling up to just under US$70 (excluding shipping fees and the USB power adapter).

Setup

Antenna – For this setup I have mounted the smaller dipole antenna in an airport-facing window using the suction mount from the antenna kit. I’ve adjusted the antenna so that each side is about 1/2 the wavelength of the 1090MHz signal I’m listening for – roughly 13.8cm – and aligned to form a 90° angle. Conveniently enough, this is about the same as the maximum length for this antenna. While I could probably be more scientific about tuning the length of the antenna and setting its position, the current setup works great for my relatively short-range needs, and the indoor location of the antenna is probably a bigger problem than the length and angle.

RasPi & SDR – These two parts are twist-tied to the window shutters. While originally they were resting on the window sill, I quickly found that opening the shutters would usually result in everything falling to the floor.

The Software

The Raspberry Pi has been setup with a standard headless Raspbian Stretch installation. Since the Pi is a fairly popular tool of choice for airplane tracking, everything that was needed for the SDR can be installed with prebuilt packages. For ease of setup, I chose to use the dump1090 fork maintained by FlightAware. Their package provides both a web UI for viewing the live data in human readable formats as well as the standard dump1090 network endpoints for fetching the data in SBS1 and BEAST formats.

A screenshot of the message sent by the Telegram1090 bot.
A Screenshot of the Telegram Bot’s messages

As for the bot, I used Node.js and TypeScript since I’m relatively comfortable with both. Plus there’s the added benefit that there are already libraries for handling SBS1 data, geographical calculations, and the Telegram bot APIs. The Node.js app I put together handles everything from fetching the SBS1 data from dump1090 to sending the the messages to the Telegram bot API. I’ve created a systemd service to automatically run the Node.js app when the Raspberry Pi boots up so no need to remember to restart everything manually.

Check out the Telegram bot code and setup instructions on GitHub

https://github.com/flakeparadigm/telegram1090

What’s next?

  • Visualizing or analyzing the data that’s being collected and saved. There’s something really cool about collecting this data myself that makes me really want to create a 2D heat map or a 3D flight path model. While FlightAware and Plane Finder’s tools can make live maps, there aren’t any built in tools for visualizing historical data.
  • Analysis of airplane size when determining if I should be notified. Large planes like A380s and B747s can be heard from much further away than smaller turboprops. Since some planes broadcast their size or model it might be possible to fine-tune the radius for notifications based on this information.
  • Altitude checking before sending notifications. Occasionally planes will pass over at altitudes high enough that they cannot be heard. It’s a bit pointless to receive these notifications because I’d never notice them if it weren’t for the message from the bot.
  • Telegram live location tracking. Telegram allows displaying live locations within messages, so the bot could share the actual location of planes as they fly within range of the base station.

10 thoughts on “What’s that plane I hear? Telegram1090

  1. Hi, thanks for posting this. I tried setting this up and I had some problems. Specifically when I got to the npm start command. The output is below. Would you be able to advise where I went wrong?

    Thanks & best regards,

    Bill

    pi@rpi4:~/telegram1090 $ npm start

    > [email protected] start /home/pi/telegram1090
    > ts-node ./src/index.ts

    node-telegram-bot-api deprecated Automatic enabling of cancellation of promises is deprecated.
    In the future, you will have to enable it yourself.
    See https://github.com/yagop/node-telegram-bot-api/issues/319. internal/modules/cjs/loader.js:1138:30
    Error: ENOENT: no such file or directory, open ‘/home/pi/telegram1090/persisted/flights-2020-06-15T02-20-29.json’
    at Object.openSync (fs.js:458:3)
    at Object.writeFileSync (fs.js:1355:35)
    at JsonPersistence.save (/home/pi/telegram1090/src/persistenceService/jsonPersistence.ts:16:12)
    at PersistenceService.saveCallback (/home/pi/telegram1090/src/persistenceService/index.ts:45:29)
    at PersistenceService.start (/home/pi/telegram1090/src/persistenceService/index.ts:34:14)
    at PersistedFlightCollection.createPersistenceService (/home/pi/telegram1090/src/airplaneService/persistedFlightCollection.ts:48:21)
    at new PersistedFlightCollection (/home/pi/telegram1090/src/airplaneService/persistedFlightCollection.ts:21:33)
    at new AirplaneService (/home/pi/telegram1090/src/airplaneService/index.ts:30:24)
    at Object. (/home/pi/telegram1090/src/index.ts:8:25)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Module.m._compile (/home/pi/telegram1090/node_modules/ts-node/src/index.ts:837:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Object.require.extensions. [as .ts] (/home/pi/telegram1090/node_modules/ts-node/src/index.ts:840:12)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at main (/home/pi/telegram1090/node_modules/ts-node/src/bin.ts:226:14)
    at Object. (/home/pi/telegram1090/node_modules/ts-node/src/bin.ts:485:3)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! [email protected] start: `ts-node ./src/index.ts`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the [email protected] start script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    npm ERR! A complete log of this run can be found in:
    npm ERR! /home/pi/.npm/_logs/2020-06-15T02_20_30_166Z-debug.log

    1. I don’t think I’ll have a chance to test for this error myself in the next couple days, but looking at the log this line sticks out to me:

      ENOENT: no such file or directory, open '/home/pi/telegram1090/persisted/flights-2020-06-15T02-20-29.json

      The issue is probably because I didn’t include an empty “persisted” directory in the git repo, so creating it manually might fix your issue:
      $ mkdir persisted

      If not, then I can try to investigate further next weekend.

          1. When I start it, I only get “Connected to SBS1 messages at localhost:30003” and thats it. My Dump1090-fa ist running and working and Planes are flying overhead, but my bot is not doing anything. Token is okay. Do I have to insert the Botname anywhere?

          2. After the service is started up and running, In Telegram you have to start a chat with the bot and send a message that says `subscribe` to it. Then it should start sending you notifications.

          3. I already did that and it says “You are now subscribed to updates”, but nothing, i even changed the mileage from home but nothing.

          4. Ah okay. I’ll try and find some time this weekend to test it out and see if there are any issues, but it’s been quite a while since I’ve had it running on my own system.

          5. That would be cool. You can reply to me via Github, I raised an issue.

Leave a Reply

Your email address will not be published. Required fields are marked *