I’m the Moon

For Christmas 2012 I received a Moon in my Room. This is effectively a moon shaped night light for kids that includes an IR remote you can use to cycle through 12 unique phases of the moon. It a cool 3D, dome shaped, textured surface representation of the moon. I decided it needed to be a little more aware of the real phase of the moon.

Moon in My Room

Concept

It seems that I am not the only person to receive one of these for Christmas or think about doing a little “enhancement”. There are at least two other people who were thinking similar thoughts and documented them early 2013. These had similar thought, use an Arduino and a real time clock to calculate the current phase of the moon and display it. These were implemented to just show the expected phase of the moon for the specific calendar date. My idea differed a bit from these implementations.

I wanted my moon to display the current phase relative to my location. I wanted it to come on at moon rise and go off at moon set. This proved a little more difficult than I first thought. In addition the Moon in my Room is divided into 6 vertical pie segments each with an individual LED. The original moon and the mods that I found were just cycling the LEDs on/off as needed to represent the 12 phases. I wanted to take advantage of the PWM functionality from the hardware I selected and fade each LED on or off which would give me 3072 (12 * 256) distinct phases of the moon. In the end I thought this was going to make it 10x cooler, but in practice I think it only scored a 2x. This is most obvious when my Moon powers on, it goes through a demo mode which shows off this feature.

Following is a video demonstrating the “Demo” mode when it powers up.

Hardware

wpid-wp-1409161569416.jpegwpid-img_20140717_184740.jpg

The following parts were used (along with estimated costs):

 

 

 

Software

The software was thrown together using the Arduino environment and random information on the internet. I have included some of these resources below, and will hopefully update more in the future.

There are some easy methods for calculating current phase of the moon for a given date. Many approximations can be done and you can still get an accurate enough answer. On the other hand to calculate the actual rise, phase, and setting of the moon for a specific location takes quite a bit more effort. You need to know the time of day. This is done with a DS1307 RTC clock module. In addition you need to know your longitude and latitude. It would have been cool to include a GPS in this project so that it determines its current location. That would have been overkill for something that is likely to hang on the same wall for the majority of its life. So the latitude and longitude is configured in the source code. Easily changed for an occasional move, but not so convenient if I was going to travel around the world with it.

The original moon rise/set code was somewhat convoluted with many global variables. I attempted several times to refactor and make it less convoluted. I did not succeed. Though I think it was better than when it started. In general it seems pretty accurate in comparison to various online calculators for the same info, which often are off by several minutes from each other anyway.

Current Features

  • Lights on/off at Moonrise/Moonset
  • Lights on shows current phase of moon
  • Phase of moon displayed using PWM using 6 leds
  • DST compensation
  • Power on demo sequence
  • USB powered
  • Current status vial USB serial
  • Parameters configured in Sketch

Future Features

  • Configure date/time/location via serial
  • RTC correction configuration and calculation
  • Manual invoked mode that will display phase of next moonrise
  • Clock mode?

Wiring

Teensy Nano Moon DS1307
PB7/D4  D3 Brown via 100-150 ohm resistor
PC6/D9  D5 Red via 100-150 ohm resistor
PC7/D10  D6 Orange via 100-150 ohm resistor
PD7/D12 D9 Yellow via 100-150 ohm resistor
PB5/D14  D10 Green via 100-150 ohm resistor
PB6/D15  D11 Blue via 100-150 ohm resistor
PD0/D6  A5 SCL
PD1/D5  A4 SDA
VCC VCC VCC VCC
GND GND GND GND

Resources

Project Firmware

https://github.com/slackmasterstan/Moon-in-my-room

Similar Projects

 http://calebcohoon.blogspot.com/2013/01/hacking-moon-in-my-room.html

http://www.imagitronics.org/projects/rc-moon/

http://channel9.msdn.com/coding4fun/articles/Remote-Controlled-lunaring-with-Arduino

DS1307 & Arduino

http://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit/arduino-library

https://github.com/adafruit/RTClib

http://arduino.cc

Moon Phase

https://github.com/calebhc/lunar_phase/blob/ad41f6c52b2807b632c6831c37970f7406695797/lunar_phase.ino

http://channel9.msdn.com/coding4fun/articles/Remote-Controlled-lunaring-with-Arduino

http://www.imagitronics.org/projects/rc-moon/

http://en.wikipedia.org/wiki/Lunar_phase

http://aa.usno.navy.mil/faq/docs/moon_phases.php

Moon Rise/Moon Set

http://iz6rdb.trentalancia.com/en/moon.c

DST calculations

http://stackoverflow.com/questions/5590429/calculating-daylight-savings-time-from-only-date

Serial clock setting example

http://www.glacialwanderer.com/hobbyrobotics/?p=12

http://wiring.org.co/learning/libraries/realtimeclock.html

Final Thoughts

I completed this project about May 2013, but I am only getting around to documenting it August 2014.  Slacktastic.  I have enjoyed this on my wall.  I find that it makes me more aware of the cycle of the moon, and often I see it lit up and go outside to see what the real moon looks like.  This was a very satisfying project.

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>