In this Instructable we will be building a dynamic lunar lamp with the Raspberry Pi. With your very own lunar clock you'll always know the current phase of the moon, no matter the weather!
Step 1: History and Theory
Budding astronomer? Recently bitten by a werewolf? Whatever your lunar-phase-knowing needs, the Lunar Phase Clock has you covered! If you're interested in getting started on the build, move on over to the next step. Here we'll talk about the astronomy behind the project.
So what are the phases of the Moon?
Just as the Earth orbits the Sun, so too the Moon orbits the Earth. The Moon is tidally locked to the Earth, which means that because the Moon completes its own rotation in the same time it take to orbit around the Earth, we always see the same side of the Moon. While we may be stuck to the same view of the Moon, the relationship between the Earth and Sun as the Moon completes its orbit is constantly changing. This means that it will be illuminated to varying degrees (or not at all!) and will take on a distinct shape. These distinct shapes are what we refer to as the lunar phases. The Moon completes a cycle around the Earth every 29.53 days; this is referred to as a synodic month.
Step 2: Materials
Raspberry Pi (RadioShack #277-196)
protoboard (RadioShack #276-168)
(2x) LED strip (RadioShack #55065456) web only
(8x) n-channel MOSFET (3V3 Gate-Source level or lower) Mouser
(8x) 10K resistor (RadioShack # 271-1126)
12V AC adapter (RadioShack #Catalog #: 273-318)
USB wifi adapter (RadioShack #55044156) web only
USB power supply (RadioShack #55075817) web only
Micro USB cable (RadioShack #26-2738)
22 gauge wire (RadioShack #278-1218)
(2x) 4/40 nut (RadioShack #64-3018)
(2x) .75" 4/40 machine screw (RadioShack #64-3011)
(4x) 2" 6/32 screw
(4x) 6/32 nut
Step 3: Configuring the Raspberry Pi: OS and Networking
For these next steps, you'll need to have the Raspberry Pi set up with an operating system and hooked up to a full keyboard/mouse/HD monitor setup or connected to a computer via SSH. Click through the link below to see my brief companion guide for setting up the wireless connection Netgear Wi-Fi adapter. This guide also includes a link to a great Instructable for setting up the Raspberry Pi. Since the RasPi doesn't have a hardware clock, we'll be using the internet as a consistent time source. We'll also need to install a few things in order for us to use the GPIO on the pi. Setting up an internet connection varies depending on how your network is set up. For this Instructable, we'll be using a wireless connection via USB.
Step 4: Configuring the Raspberry Pi: Python Program
Initially, I had considered having the moon-clock pulling the lunar data from the internet over wifi, but as luck would have it, there's an algorithm for calculating the current lunar phase for a given date. Math to the rescue! I found the algorithms here. The particular algorithm we'll be using was written by John Conway, whom you may know as the person behind the cellular automata program "Game of Life." The lunar phase algorithm was written in java, but it was not too difficult to translate this over to python.
Before we can run the Python program we'll need to install the GPIO library and developer headers.
Type the following into the terminal:
sudo apt-get install python-dev
sudo apt-get install python-rpi.gpio
We'll need to install and run the Python program as soon as the Pi boots up. Download the attached program "moonlight.py" and copy it over to the Pi. Make sure it's in the directory "/home/pi" (some info on moving the program over)
We'll make the program into an executable with:
sudo chmod +x moonlight.py
Next we'll need to open up another file. Type in:
sudo nano /etc/rc.local
Comment out any text below by putting a "#" at the start of the line. Below the text type in:
sudo python /home/pi/moonlight.py &
Hit ctrl+x to save and then "y" to confirm the changes to the file. Now when the Pi boots up our program will run automatically.
Step 5: Build the Circuit: Design
Here is the schematic for our LED driver board. We're using N-channel MOSFETs to connect the 12V powered LEDs to ground. I chose N-channel MOSETSs as this setup has logic "high" pulses from the Pi activating the lights, which was more intuitive to program.
Step 6: Build the Circuit: MOSFETS
Space the MOSFETs evenly on the circuit board all facing the same direction.
Step 7: Build the Circuit: Resistors
Bend the leads of the resistors over so they'll fit into two adjacent holes on the board. Place one resistor from the gate pin of the MOSFET (the leftmost pin when looking directly at it) to the power bus in the middle of the board.
Step 8: Build the Circuit: Terminal Blocks
Place the terminal blocks along the edge of the board so that one of the pins is aligned with the drain pin (middle pin) of each MOSFET.
Step 9: Build the Circuit: Wiring
Using the clipped leads of the resistors, make tiny jumpers with a pair of needle-nose pliers.
Step 10: Build the Circuit: Light Strips
Unroll the LED spool and cut the strip into 16 pieces of 3 LEDs. The strip has copper pads every 3 LEDs for power and ground.
Step 11: Building the Frame: Design
The Lunar Phase Clock is made of stacked sheets of laser-cut plywood for the body and the base. I designed the frame in Illustrator and used an Epilog 120 watt laser to cut out the pieces from 1/4 inch ply and 1/8 inch acrylic. The body plates are stacked together with segmented ribs that organized the light into eight distinct segments. This gives us enough resolution to display the main phases of the Moon. The LEDs lay flat along the back panel and shine light through a sheet of paper that has an image of the Moon printed on it. The paper acts to diffuse the light for more gentile progressions as the segments light up. The body is held together with 4 screws along the top rim. This allows it to be easily disassembled if the LEDs were to be damaged or the face replaced.
The base of the clock is made of three stack pieces of ply that have slots for the body to slide into. The holes are designed with tight tolerances so that the body and base can be held together with a "friction fit." The quarter-circle edge pieces serve to support the weight of the body and hide the wiring and electronics from view.
Download and cut out the attached .ai files.
"MoonFrameComplete" should be 1/4 inch wood. (Note that the ribbed piece should be cut out three times)
"MoonClearPlates" should be 1/8 inch clear acrylic.
Step 12: Glue the Frame
Lay the three base pieces out on a large surface. With course sand paper, remove the unsightly laser burns and charred sap from the edges. Making note of the proper layout, flip the two top pieces over and coat with wood glue. Lay the middle piece upon the base, using the finger holes as a guide to properly align them. Lay the top piece upon the middle plate, using the large rectangular body slot as a guide. Clamp the base pieces together and allow to dry for 24 hours.
Step 13: Moon Graphic
Print out the attached Moon graphic and cut out along the white line. Place the new piece between the two circular pieces of acrylic.
Step 14: Finish the Frame
Lay the solid base plate down with one ribbed piece on top. Using a pencil, outline the inside segments; we'll use this as a guide for properly placing the LED's.
Take the eight elongated LED strips and fish the power wires through the holes near the middle of the base plate. Bend the white wires between each segment so that the strips follow the curves of each segment. Glue the underside of the strips in place.
Place the next two ribbed body plates, followed by the plates with the hole large enough for the acrylic circles. Place the acrylic containing the Moon shape into the body, using the straight edges of the paper to properly align the Moon with the edge.
Place the face-plate over the acrylic sheets. This holds them in place and covers the edges of the paper. Fasten the panels together with the 2 inch screws.
Step 15: Mount Electronics
Mount the Raspberry Pi over the two left holes with the 4/40 screws. Attach the wires from the strips to the driver board, referring to the schematic on step 7 (The leftmost wires while facing the back are attached to the lowest pin number).
Step 16: Power Supplies
Cut off the plug of the 12 volt power supply and plug the wires into the terminal block of the driver board.
Plug the micro USB cable into the Pi and the USB adapter. Plug in the 12 volt supply into the wall.
Step 17: Finishing
The Lunar Phase Clock is fine and dandy on its own, but a touch of color could certainly improve upon its laser-cut appearance. I decided to give my clock a dark stain and a few coats of polyurethane to seal it in. There's lots of open flat panels to coat, so it would make a great canvas for some custom artwork too.
sleepingseva made it!