Introduction: LEGO ISS 21321 DIY Smart Lighting

This Instructable will help you light up your own Lego ISS or other brick model, using components that cost a fraction of the cost of commercial kits, but provide much more flexibility.

I show you how I created this for less than £8, and what code I use to produce a simple lighting effect. You can then use other sources to turn that simple effect into smart lighting or an ISS alerter

The tutorial assumes you have knowledge of soldering simple circuits and of using and programming Arduino's or ESP8266's

Supplies

You will need

  • A soldering iron and solder
  • An ESP8266 (preferably an ESP-12F, but a Wemos D1 Mini will also do the job). Alternatively, you could use an Arduino, but the lack of wifi connectivity will limit future 'smart' options
  • 10 or more pre-wired white SMD LED's (search ebay for Pre-soldered micro litz wired leds white smd led 200mm)
  • Some extra wire for running the LEDs to the ESP8266 (I stripped out some from an old network cable)
  • Your preferred way of mounting your ESP8266. In this example I used some PCB board.
  • A PC and USB cable to program your ESP8266 using the Arduino application.
  • Access to a 3D printer, or the ability to order some small 3D prints
  • Translucent round Lego studs to cover and color the LEDs in colours your would like your ISS to glow
  • Optional extra Lego to house your controller and hide your wires

Step 1: Download and Print Your Parts

First, you need to download the two types of brick compatible connector i designed for this project, 'Peg.stl' and 'Stud.stl'.

The longer one replaces the short Technic axle at the end of each solar panel. The small piece can be used like a stud anywhere on the model.

I recommend each piece is printed upside down, so the hole for the LED is on the print bed, using a layer height of 0.12mm.

Once printed, test the fit against your own Lego. These pieces were designed with zero tolerance to fit tightly based on my own printer settings. If you find them too tight or too loose once they come off your printer, scale them slightly in your slicer software and re-print until you are happy with the fit.

Step 2: Fit Your LED's

Each LED will fit snugly in the hole and the wire will go into the gap provided. Place a transparent stud of your preferred color to finish - no need to glue the LED (or the lego) - they will stay put.

I recommend that at this point, if possible, you test the LED by applying 3V

Step 3: Solder Your Circuit

I wired each side of the ISS (each cluster of 4 panels), in parallel on separate circuits. The two LED's on the main body of the ISS are each on their own circuit. This way, I have used 4 pins on my ESP8266 as outputs and have scope to add more lights. However, I recommend you consider what effects you want your ISS to do - if you want the panels to flash independently, you will want to wire differently.

Each LED comes with 200mm of wire pre-attached. This is enough fine wire to traverse the full length of the solar panel to the back of the supporting arm, where you will need to hide your main wiring. Solder the LED's to your main cable run and allow enough cable so that you can route it away from the model to your ESP8266

Avoid mounting your circuit to the ISS at this stage, you need to connect up the ESP8266 first.

Step 4: Connect Your Circuit to Your ESP8266

`In my example, I have used pins D4, D5, D6 and D7 to control the LEDs. You will also need to connect them to ground.

Left and right solar panels are connected to D5 and D6, while the flashing LED's are connected to D4 and D7

The ESP8266 can control more groups of LED's though, and I recommend you prototype your circuit on a solderless breadboard before committing. Its easy to add more LED's, and I will be doing that myself once I complete this tutorial.

As you can see from the (poor quality) photo, I have soldered the wires from the LED's directly to the board. While this works - I only did it because I have ran out of screw terminals. I would recommend some type of push or screw connector, as it will make manipulating the model so much easier in the future. I would also recommend cable runs of at least 50cm so that you can hide the smart brick.

Step 5: Upload the Sketch to Your ESP8266

The following basic sketch will light up you panels (D5 and D6) on fade cycle, and will flash D4 and D7

int ledGroup1 = 12; //D6
int ledGroup2 = 14; //D5
 
int led1 = 13; //D7 
int led2 = LED_BUILTIN; //D4

int brightness = 0;   
int fadeAmount = 5;   

int onoffstate = 1;
int offonstate = 0;

void setup() {
//Set the pins to outputs
  pinMode(ledGroup1, OUTPUT);
  pinMode(ledGroup2, OUTPUT);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
}


void loop() {
//write the current brightness levels to the solar panels
  analogWrite(ledGroup1, brightness);
  analogWrite(ledGroup2, brightness);

//Flash the two middle leds 
    digitalWrite(led1, offonstate); 
    digitalWrite(led2, onoffstate);  

//Change the fade brightness level
   brightness = brightness + fadeAmount;
  if (brightness <= 0 || brightness >= 255) {
    fadeAmount = -fadeAmount;
  }
//Flip the flasher led states
    if(onoffstate == 1) {
       onoffstate = 0;
       offonstate = 1;
    }
    else  {
      onoffstate = 1;
      offonstate = 0;
    }
   delay(1000);
}

Step 6: Attach Lights to the Model.

To attach the circuit to the back of the model, I found 2x1 tiles with single stud useful to route the wires across the back so they were not visible (see the photo of the wiring)

I built a box out of Lego to hide the controller and any wire slack.

Step 7: Improvements

Now you have basic lighting, you can improve your code.

The code I am running is actually based on the ISS Tracker by Pollux Labs. This allows my lighting to change when the ISS is overhead. Take a look at Pollux Labs excellent article at https://www.hackster.io/pollux-labs/iss-tracker-with-an-esp8266-0dd8f4 to learn how to make your ISS lighting change when the real ISS is overhead.