ISS lamp - Blinks When The ISS Passes Overhead



Howdy! If you are interested in astronomy and look up at the stars and not down at your feet, you'll surely know the ISS. The ISS or The International Space Station revolves around the earth around 16 times per day. Being an aerospace engineering student, I'm very keen about things like the ISS. If you're too, then I bet you'll love this project.

Meet ISS Globe - a smart lamp that can notify you whenever the ISS is passing overhead. Basically, it's a small (and cute looking) hemispherical lamp that gives a mild glow when connected to a power supply. If the ISS is passing overhead, the lamp starts blinking for about 30 seconds (you can customise the duration).
It's also very pleasant to look at when it just sits on the table like any other mood lamp.
This project has gained quite a lot of popularity on instructables.
Sounds complicated to build, but nope, it's an easy microcontroller project. No soldering, no glue gun, just a microcontroller and an LED for the main part. Let's get making!

Supplies:


NodeMcu WiFi development board
An LED
Cardboard
Female- Female jumpers (optional)
Cellophane tape
Adhesive

Besides these, you'll have to install two free apps- Blynk and ifttt
Play store links:
 Blynk
 IFTTT

App Store Links:
 Blynk
 IFTTT

Build the structure:





To make the globe, I used the top portion of an old LED light. It can disperse the light very well. Popping it out of the light is simple, use a screw driver to push it out of the bottom plastic part.
To make the base of the lamp, I cut a strip from black cardboard and rolled it into a cylinder.



 The height of the cylinder (thickness of the strip) should be a tiny bit more than the height of the NodeMcu when it is standing on its pins. I cut a circle with diameter equal to the diameter of the top globe from the cardboard and stuck the cylinder on it with adhesive. Great! The building process is complete. Now let's move to the electronics.

 

 

 

The code: 

The heart of the ISS globe is the NodeMcu, and we need to code it to make it work as we want it to.
I shall do a code walk through at the end. You can refer to understand the code.
Make sure you have the blynk and node mcu libraries installed. Then, replace the part of the code saying "ssid" with your WiFi name and "password" with the WiFi password. You also need to replace the part saying "Auth" which I'll explain in the coming steps. After doing these modifications, you can upload the code to your NodeMcu.




#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "auth";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "ssid";
char pass[] = "password";

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  pinMode(D5,OUTPUT);
  pinMode(D6,INPUT);
  pinMode(D1,OUTPUT);
}

void loop()
{
  Blynk.run();
  if(digitalRead(D6))
  {
    for(int i=0;i<15;i++)
    {
    analogWrite(D1,0);
    delay(1000);
    analogWrite(D1,1023);
    delay(1000);
    if(i==14)
    {
    digitalWrite(D5,LOW);
    break;
    }
    }

  }


A little electronics:


 


This step is an easy one. I'll keep it short. Connect pin D1 of the NodeMcu to D7. Connect the positive electrode of the LED to D5 and negative electrode to GND of the NodeMcu.
I sanded the top of the led to disperse the light and  stuck it to the bottom of the NodeMcu so that it doesn't occupy much space. Now the NodeMcu can be placed upside down in the cardboard bottom we built earlier and the hemisphere can be stuck on top.

Yify! The major part of the build is done! Now the only things left are configuring the two downloaded apps. Go ahead and download them if you haven't because I shall be explaining how to configure them in the next steps with screenshots. So it'll be easier for you if you follow along.

Setup Blynk:

 
 

Make sure you've signed up for blynk and logged in to the app.
 Create a new project and the Auth token will be mailed to you. You'll need to enter this token in the "Auth" part of the code that I was talking about earlier. 
In blynk, click anywhere on the black screen to see the widget box appear. In the widget box, click on "button". You'll find that a button widget has been added. Click on it and select "PIN". Select gp5 from the list. 

It's worth noting that gp5 means gpio pin 5 of Arduino which mapps to pin D1 of NodeMcu. Also, make sure the button is set to "push", which should be set by default. So when the button is pressed, D1 of the NodeMcu will be triggered. Anyway, we're not going to press the button, let the IFTTT app do the job. 

Setup IFTTT 


Again, make sure you've signed up and logged in to the IFTTT app. Click on the 3rd tab (bottom right) and select the "+" symbol on top right. From there, click on "this" which should be in blue colour. Search "space" in the search bar and click on it. Click on "ISS passes over a specific location" and select your location. 

Now click on "that" and search for "webhooks" on the search bar. Click on "make a web request" and enter the URL. Select "put" in the method section and select "application/json" in the content type. In the body, type ["1"]


I know what you're thinking, I didn't elaborate about the URL section. Well, here you go.
The URL format is https://IP/Auth/update/D5
Replace Auth with the Auth token of the blynk project and IP with blynk cloud IP of your country. To get the IP, open command prompt and type "ping blynk-cloud.com". For India, the IP is 188.166.206.43
Woah, that was a lot of configuration. But good news. We're done! We've completed making the ISS tracking globe.

Look up at the sky 




There you go. Your very own ISS overhead indicator is ready to roll. From now on, every time the ISS hovers over your location, this cute globe will let you know. From what I've seen so far, the ISS crosses my location once or twice most days. There are a few days when it doesn't show up at all, but that's kinda rare. Somedays it even crosses three to four times.





 Well it's always good to know there are people working up there and really feels exiting when they hover overhead. And if it's after sunset, you can even run out and have a look at it sweeping through the sky, and may be wave a hello!

Code Walk through: 

Here's all that's going on in the loop() function (since outside it is all initializations and some other basic stuff to get the development board running)

We begin by starting blynk using Blynk.run()

First step is to turn on the led by using digitalWrite() and setting pin D5 to HIGH

Now when the ISS passes overhead, ifttt is set to trigger gpio pin 5 i.e. D1 to HIGH and since D1 is connected to D7, D7 will read D1's state. 

So when D7 reads HIGH, the if() block is executed

Inside the if() block, a loop runs through setting D5 LOW then a 1 second delay and then D5 HIGH and again 1 second delay and so on fifteen times. Which means the LED will blink for 30 seconds. 

When the value of "i" is 14, the blinking can be stopped. So we break the loop.

 

0 Comments