Logo
×

Projects

About Me

Render Gallery

Digital Art

International Space Station Tracker

Front End Web Development

Javascript

Raspberry Pi

Python

  • I used Javascript to retrieve, transform and display the latitude and longitude of the International Space Station every 3 seconds.
  • I setup a Raspberry Pi to send me an email whenever the International Space Station is over London.

How it Works

The Javascript code below is running on the client device. It polls the ISS API every 3 seconds, converting the returned latitude and longitude into a mercator projection. Further code uses the P5 library to display the graphics on the webpage.

complete: function (data) {
if (data.readyState === 4 && data.status === 200) {
    Lat = data.responseJSON.latitude;
    Long = data.responseJSON.longitude;
    Velocity = data.responseJSON.velocity.toFixed(2).toString();
    Altitude = data.responseJSON.altitude.toFixed(2).toString();
    var x = (parseFloat(Long) + 180) * (MapWidth / 360);
    var latRad = (parseFloat(Lat) * Math.PI / 180);
    var mercN = (Math.log(Math.tan((Math.PI / 4) + (latRad / 2))));
    var y = (MapHeight / 2) - (MapWidth * mercN / (2 * Math.PI));

The Python code below sends an email if the latitude and longitude values are within a certain range. The "findISS" function works in a very similar way to the javascript implementation above.

server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
while True:
    data = findISS()
    sleep(0.5)
    if (Latmin < float(data['iss_position']['latitude']) < Latmax) and (Longmin < float(data['iss_position']['latitude']) < Longmax):
        mmessage = """\
        Subject: ISS Tracker
        ISS overhead"""
        server.sendmail(sender_email, receiver_email, message)
        sleep(20)

The complete code can be viewed on my Github.