Skip to content

TheDyslexicCoder/node-red-space-station-worldmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

node-red-space-station-worldmap

I am using Node-RED's WorldMap to locate the International Space Station & Chinese Space Station—Tiangong via N2YO.com API!

Minimum Viable Product, or MVP

Tracking the ISS   CSS on Node-Red

Prerequisites:

  • Create a free account with N2YO.COM to access the APIs for the International Space Station & Chinese Space Station—Tiangong.
  • Have access to Node-Red Terminal.
  • Install Node-Red Worldmap.
  • Willingness to shoot for the Stars~ 🚀

Table of Contents:

  1. NY2O Account Setup
  2. Building Out the Node-RED Canvas
  3. Deploying the ISS & CSS Tracker flow

Documentation:

Procedure:

Part 1: NY2O Account Setup

  1. Start by accessing N2YO.com.
  2. Click register for a new account.
N2YO.com.Account.Setup-I.C.T.GIF.mp4
  1. Create an account with your username & password. We will need them in the upcoming section.
  2. Click 'Submit' when done.
N2YO.com.Account.Creation-I.C.T.GIF.mp4
  1. Relogin to N2YO.com, and enter the username & password you created. ReLogin to N2YO com
  2. To check our profile, look towards the lower right corner of the screen labeled 'Your Current Location.' Click 'Change your location.' CurrentLocation
  3. On our Profile Screen, locate our observer coordinates.
N2YO.COM.OBSERVING.LOCATION-I.C.T.GIF.mp4
  1. Next, generate our API key by clicking the 'Generate your API license key' button.
N2YO.COM.API.Key-I.C.T.GIF.mp4
  1. Great! Let's compile the two API Request URLs for the International Space Station & Tiangong Space Station with our observable values.
Click to view my observable values from NY2O.com

NY2O.com Variables My observable values
NORAD ID for ISS 25544
NORAD ID for CSS 25544
Latitude 37.84
Longitude -122.29
API License Key W2P49E-CYAT4A-PL4YAB-4TSZ

  • Below copy the Sample URL & substitute the variables inside the Sample URL for your values from N2YO.com:
Click to view the sample API URL for the International Space Station & the Chinese Space Station—Tiangong

SAMPLE URL: https://api.n2yo.com/rest/v1/satellite/positions/NORADID/Lat/Lon/0/2/&apiKey={yourAPIKey}

    • Translate your code to:
Click to view the final API URL for the International Space Station & the Chinese Space Station—Tiangong

International Space Station API URL: https://api.n2yo.com/rest/v1/satellite/positions/25544/37.84/-122.29/0/2/&apiKey=W2P49E-CYAT4A-PL4YAB-4TSZ
Chinese Space Station—Tiangong API URL: https://api.n2yo.com/rest/v1/satellite/positions/48274/37.84/-122.29/0/2/&apiKey=W2P49E-CYAT4A-PL4YAB-4TSZ

10. Awesome! You should now have your two unique API URLs! Keep those URLs on the back burner, and we will come back to them later in the project!

Part 2: Building Out the Node-RED Canvas

  1. Open Node-RED on the Raspberry Pi terminal.
Click to view the steps for launching Node-RED on the Raspberry Pi terminal.

 node-red start

  1. Access Node-RED through the server URL and navigate the Installation Palette in the User Settings to install the WorldMap node.
Downloading.the.WorldMap.Node.on.Node-Red.-.I.C.T.GIF.mp4
Click to view the steps for installing the WorldMap in the Installation Palette.

 Menu > Manage Palette > Install > Type in WorldMap

  • If needed, click install and follow the steps to complete the installation process.
    • Now that we have installed the Worldmap node, we can start building the flow!
  1. We will begin by renaming the canvas from Flow 1 to ISS & CSS Tracker.
Renaming.Tab.to.ISS.CSS.Tracker.-.I.C.T.GIF.mp4
  1. Next, drag the Inject node into our canvas and adjust the following configurations:
Creating.the.Inject.Node.-.I.C.T.GIF.mp4
Click to view the steps for configuring the Inject node.

Inject node > Properties > Select Inject Once after 0.1
seconds, then > Repeat Interval every 32 seconds > Done

  • Perfect! Remember the two custom URLs you made for the ISS & CSS? It’s time to grab them, as we will use them in our HTTP request node!
  1. To create the International Space Station HTTP Request node, drag an HTTP request node into our canvas and follow configurations steps:
Pasting.the.ISS.API.Key.in.HTTP.Request.Node.-.I.C.T.GIF.mp4
Click to view the steps for configuring the International Space Station HTTP Request node.

http request node > Properties > 
URL: https://api.n2yo.com/rest/v1/satellite/positions/25544/37.84/-122.29/0/2/&apiKey=W2P49E-CYAT4A-PL4YAB-4TSZ 
> Return: a parsed JSON object > Name: N2YO Rest API (ISS) > Done

  1. We will add another HTTP request node for the Chinese Space Station and follow the configurations steps:
Pasting.CSS.API.Key.in.HTTP.Request.Node.-.I.C.T.GIF.mp4
Click to view the steps for configuring the Chinese Space Station HTTP Request node.

http request node > Properties > 
URL: https://api.n2yo.com/rest/v1/satellite/positions/25544/37.84/-122.29/0/2/&apiKey=W2P49E-CYAT4A-PL4YAB-4TSZ 
> Return: a parsed JSON object > Name: N2YO Rest API (ISS) > Done

  1. Next, we will drag the Function node to the International Space Station's path. Double-click the Function node, and type in the following JavaScript code, which will extract the JSON data from the HTTP Request node.
Pasting.Detailed.ISS.Position.in.Function.Node.-.I.C.T.GIF.mp4
Click to view the JavaScript code for ISS Position.

var iss = "International Space Station";
var lat = msg.payload.positions[0].satlatitude;
var lon = msg.payload.positions[0].satlongitude;
msg.payload = {
"name": iss,
"lat" : lat,
"lon": lon,
};
return msg;

  1. We’ll repeat the step for the CSS.
Pasting.Detailed.CSS.Position.in.Function.Node.-.I.C.T.GIF.mp4
Click to view the JavaScript code for CSS Position.

var css = "Chinese Space Station";
var lat = msg.payload.positions[0].satlatitude;
var lon = msg.payload.positions[0].satlongitude;
msg.payload = {
"name": css,
"lat" : lat,
"lon": lon,
};
return msg;

  1. Excellent, we are almost done! We’ll create the attributes to show the ISS on the WorldMap with the code below:
Pasting.JavaScript.for.ISS.Attributes.in.Function.Node.-.I.C.T.GIF.mp4
Click to view the JavaScript code for ISS Attributes.

var icon = "iss";
msg.payload = {
"name": msg.payload.name,
"lat": msg.payload.lat,
"lon":  msg.payload.lon,
"icon": icon,
"iconColor":"#ebbe56",
};
return msg;

  1. We’ll recreate the attributes for the CSS with the code below:
Pasting.JavaScript.for.CSS.Attributes.in.Function.Node.-.I.C.T.GIF.mp4
Click to view the JavaScript code for CSS Attributes.

var icon = "iss";
msg.payload = {
"name": msg.payload.name,
"lat": msg.payload.lat,
"lon":  msg.payload.lon,
"icon": icon,
"iconColor":"red",
};
return msg;

  1. Add a Debug node to the end of each flow path and edit the configurations:
Adding.Debug.Nodes.-.I.C.T.GIF.mp4
Click to view the steps for configuring the Debug node.

debug node > Properties > Output:complete msg object > Done

  1. Drag the WorldMap node and link the two functions node to it!
Adding.the.WorldMap.Node.-.I.C.T.GIF.mp4
  1. Finally, click the WorldMap node on the info tab, and right-click “here” to open the map on a new tab.

Opening Worldmap on Node-Red

Part 3: Deploying the ISS & CSS Tracker flow

  1. Click Deploy our flow, and click the inject node to view the Space Stations on Worldmap on the other tab!
Deploying.ISS.CSS.Tracker.in.Node-Red.WorldMaps.-.I.C.T.GIF.mp4

End of Procedure.

🎉 Way to Go! 🎉 We’ve created a flow to view the relative positions of the International Space Station & Tiangong Space Station in real-time using an open-source API from N2YO.com!

Feel free to copy the full code and add your twist to it! ✨

About

Using Node-Red's WorldMap to view the International Space Station & Chinese Space Station—Tiangong via N2YO.com API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors