Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Michael Guerero
Created June 9, 2021 © GPL3+

ISS Tracking Globe

Follow the International Space Station as it makes it's way around the globe on your very own globe!

IntermediateWork in progress15
ISS Tracking Globe

Things used in this project

Hardware components

NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
Red Laser Diode
×1
ezrobot Micro HDD Servos
×2
NTE962 Voltage Regulator
×1
Roller Bearing
OD - 22mm ID - 8mm Height - 7mm
×1
14cm Desk Globe
×1
9V 1A Switching Wall Power Supply
9V 1A Switching Wall Power Supply
×1
Connector Adapter, DC Power - 2.1mm
Connector Adapter, DC Power - 2.1mm
×1

Software apps and online services

VS Code
Microsoft VS Code
Programmed in C++ (Arduino language)
Fusion
Autodesk Fusion
Ultimaker Cura

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Code

ISS Tracker Globe Code

C/C++
//https://randomnerdtutorials.com/esp8266-nodemcu-http-get-open-weather-map-thingspeak-arduino/

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>
#include <Arduino_JSON.h>
#include <stdlib.h>
#include <string>
#include <Servo.h>

const char* ssid = "********";
const char* password = "********";

unsigned long lastTime = 0;
unsigned long updateInterval = 5000; //Update every 5 seconds

Servo lat_servo;
Servo lon_servo;
int lat_servo_angle;
int lon_servo_angle;

String jsonBuffer;
double lon_float;
double lat_float;

String httpGETRequest(const char* serverName) {
  HTTPClient http;
  http.begin(serverName); // Your IP address with path or Domain name with URL path 
  int httpResponseCode = http.GET(); // Send HTTP POST request
  String payload = "{}"; 
  if (httpResponseCode>0) {
    Serial.print("HTTP Response code: "); Serial.println(httpResponseCode);
    payload = http.getString();
  }
  else {
    Serial.print("Error code: ");
    Serial.println(httpResponseCode);
  }
  http.end(); // Free up resources
  return payload;
}

void setup(){
  Serial.begin(9600); //Initialize serial monitor baud rate
  lon_servo.attach(12); //Pin 6 (GPIO 12) (YELLOW)
  lat_servo.attach(13); //Pin 7 (GPIO 13) (GREEN)
  lon_servo.write(0); // Start at International Date Line (180W/180E)
  lat_servo.write(95); // Start at Equator (offset)
  delay(5000);

  WiFi.begin(ssid, password);
  Serial.println("Connecting");
  while (WiFi.status() != WL_CONNECTED){
    delay(500);
    Serial.print(".");
  }
Serial.println("");
Serial.print("Connected to WiFi network with IP Address: ");
Serial.println(WiFi.localIP());
Serial.println("Timer set to 10 second delay");
}

void loop(){
  if ((millis()-lastTime) > updateInterval){
    if (WiFi.status()==WL_CONNECTED){
      String serverPath = "http://api.open-notify.org/iss-now.json";
      jsonBuffer = httpGETRequest(serverPath.c_str()); //Serial.println(jsonBuffer);
      JSONVar object = JSON.parse(jsonBuffer);

      if (JSON.typeof(object) == "undefined"){
        Serial.println("Parsing input failed!");
        return;
      }
      
      lon_float = atof(object["iss_position"]["longitude"]); //Convert String to double
      lat_float = atof(object["iss_position"]["latitude"]); //Convert String to double

      Serial.print("Longitude: "); Serial.println(lon_float);
      Serial.print("Latitude: "); Serial.println(lat_float);

      //lat_servo_angle = int(lat_float + 90);
      lat_servo_angle = int(map(lat_float + 90, 22, 152, 0, 170));
      lon_servo_angle = int((lon_float + 180)*0.4285);
      //lon_servo_angle = int(map((lonfloat+180)*0.4285, to_min, to_max, from_min, from_max));

      lat_servo.write(lat_servo_angle); delay(500);
      lon_servo.write(lon_servo_angle); delay(500);
      
      Serial.print("Longitude servo position: "); Serial.println(lon_servo_angle);
      Serial.print("Latitude servo position: "); Serial.println(lat_servo_angle);
      Serial.println("");
    }
    else{
      Serial.print("WiFi Disconnected");
    }
    lastTime = millis();
  }
}

Credits

Michael Guerero
3 projects • 44 followers
Earned my BS in Mechanical Engineering from Cal Poly Pomona in 2018. Currently working for the California Air Resources Board.
Contact

Comments

Please log in or sign up to comment.