Automatically update satellite TLE from celestrak - Example flow

With a lot of help from @dceejay (it was his undocumented feature of his node that made this possible) here is an example of how you can get a satellite TLE (Two Line Element) from celestrak.com and output the satellite position data. What do with it from there is up to your project.

This post comes close to what we need, but hit the bug that @dceejay fixed a few days ago.

One of the keys that helped me on this project was seeing the TLE age in the data.
Here is a typical TLE from celestrak.
image
The year and fractional day of the year are in the first line of the TLE.

Now that you can clearly see the age of the TLE you know what you are dealing with.
The other aspect this example flow deals with is that you should not have to get the TLE every time you want to point the antenna.
Most TLEs are only updated every 24 hours (once a day).
There are two parts to the flow then.

  1. Every 24 hours do a HTTP get on the TLE and store it a flow.context
  2. Every 15 minutes output the satellite position using the flow.context data (the TLE).

Here is the flow:

[{"id":"ff478ce1.f0b78","type":"inject","z":"dac61f27.3a12b8","name":"24 hours","props":[{"p":"payload"}],"repeat":"86400","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1430,"y":1300,"wires":[["7f94c7f5.78a3d8"]]},{"id":"7aaf15aa.0224dc","type":"debug","z":"dac61f27.3a12b8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2210,"y":1240,"wires":[]},{"id":"7f94c7f5.78a3d8","type":"http request","z":"dac61f27.3a12b8","name":"get 25E TLE","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://celestrak.com/satcat/tle.php?CATNR=39215","tls":"","persist":false,"proxy":"","authType":"","x":1610,"y":1300,"wires":[["76626a71.02b424"]]},{"id":"30bd0a6b.dcf856","type":"tle","z":"dac61f27.3a12b8","satid":"","tle1":"","tle2":"","coordsys":"latlongdeg","name":"25E Alphasat","x":2020,"y":1240,"wires":[["7aaf15aa.0224dc"]]},{"id":"7ee3cc64.1568f4","type":"debug","z":"dac61f27.3a12b8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1930,"y":1180,"wires":[]},{"id":"76626a71.02b424","type":"function","z":"dac61f27.3a12b8","name":"set","func":"// From the returned string, split on new line and build\n//an array of sat, tle1 and tle2\n//then store it in the 'flow' memory so we can use it every 15min to drive the dish.\n\nlist = msg.payload.split('\\n');\nflow.set(\"25list\", list);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1810,"y":1300,"wires":[["d7e3839d.1f54f"]]},{"id":"ca011185.37668","type":"function","z":"dac61f27.3a12b8","name":"get 25list","func":"// Get the TLE from the flow memory and feed it into the array and feed that into the sat node\n// (All this so we don't pound the celestrak website every 15 minutes needlessly)\n\nlist = flow.get(\"25list\");\nmsg.payload = list;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1580,"y":1240,"wires":[["4735b9e9.3dbc68","64941ac2.789ef4"]]},{"id":"d39902e0.20b55","type":"inject","z":"dac61f27.3a12b8","name":"15 minutes","props":[{"p":"payload"}],"repeat":"900","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1430,"y":1240,"wires":[["ca011185.37668"]]},{"id":"d7e3839d.1f54f","type":"debug","z":"dac61f27.3a12b8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1990,"y":1300,"wires":[]},{"id":"64941ac2.789ef4","type":"debug","z":"dac61f27.3a12b8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1710,"y":1180,"wires":[]},{"id":"4735b9e9.3dbc68","type":"change","z":"dac61f27.3a12b8","name":"tweak the payload","rules":[{"t":"set","p":"satid","pt":"msg","to":"payload[0]","tot":"msg"},{"t":"set","p":"tle1","pt":"msg","to":"payload[1]","tot":"msg"},{"t":"set","p":"tle2","pt":"msg","to":"payload[2]","tot":"msg"},{"t":"set","p":"timestamp","pt":"msg","to":"","tot":"date"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1770,"y":1240,"wires":[["30bd0a6b.dcf856","7ee3cc64.1568f4"]]}]

Lots of debug nodes so you can see what's going on. Once you have things working, feel free to delete them.
From here, you could plot the satellite position on the worldmap node, or send the position data to an antenna rotator to aim the antennas at the satellite - a future forum post perhaps.

Ben.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.