Lunar Phase Weather Station

Parts List:

  1. WeMos D1 Mini, (Under $3.00 on AliExpress)
  2. SPI or I2C OLED Display, 0.96″ or 1.3″ (Under $5.00 on Ebay)
  3. 18 leds from 1 meter WS2812 non-waterproof strip, 60 LEDs per meter ($6.00 on Ebay, enough for 3 Lunar Phase Weather Stations)
  4. 3D Printed Parts from G4lile0. I used TinkerCad to make two versions of a bigger electronics box.  I also tinkered a Moon Support with a larger opening for a 1.3″ OLED
  5. Temperature / Humidity sensor: DHT 11 or DHT 22 or DS18B20 or SHT 30 ($1.50 to $5.00)
  6. Momentary Pushbutton ($0.50 on AliExpress)

Total for electronic parts ($2 worth of LEDs) = $12.50


Arduino IDE, version 1.6.12

ESP8266 Arduino Core version 2.3.0

FastLED library, Daniel Eichhorn’s ESP8266 Weather Station library.

I’ve pasted the code in my Github Gist.




(EasyEDA was used to create the schematic)

For about the last year, my programming platform of choice is the Arduino IDE using a piece of hardware called the ESP8266. It’s a microcontroller that sports a WiFi chip, and costs only a few dollars. There are a bunch of boards available that break out the pins of the chip to make it friendlier to experimentation, and my favorite such board is called the WeMos D1 Mini. I like using this board because it’s small enough to plug into a breadboard, and it has a voltage regulator and a USB interface chip, and you do NOT have to press a button each time you flash a new program to it.

A few weeks ago my friend, Rick, convinced me to get a 3D printer. I have wanted one for a while, now the price for a quality printer has dropped below $300. I ended up getting Monoprice a Maker Select V2 on a black Friday sale for $250. When it arrived, I found that I really enjoyed this new hobby. Before I got it, I told myself that I would resist the urge to make trinkets that just sit on your desk, I would print parts that actually did something! The trinket urge is great. After I gave in and printed some useless things, I started looking for something useful to print.

While surfing through some 3D designs on Thingiverse, I came across a lunar phase clock that ran on an Arduino Nano and a separate Real Time Clock board to keep time. Using G4lile0’s printing guidance, the printing went well, but I was having trouble fitting everything into the tiny electronics box. While cramming components in there, I must have shorted some wires together and I released some magic smoke. Having two boards and three buttons seemed silly to me, so I decided to start over and begin with a project that used an ESP8266 that could use WiFi to retrieve network time.

I chose Daniel Eichhorn’s ESP8266 Weather Station because in addition to displaying the time, it also gathers and displays weather data. I just needed a way to get the lunar phase code from G4lile0 into the weather station project, and add one button for changing between moon display modes. My first few attempts using interrupts to detect a button press were unsuccessful, the program kept crashing. I also tried using two different button libraries, neither of them worked. Then I just added a digitalRead() command to the main loop, hoping it would loop around frequently enough to get suitable button response. It worked! Adding the FastLED library and the 18 LEDs was relatively painless, and soon I had a working prototype.


Here’s how it works: Plug the clock into a USB port or phone charger. If it does not know your WiFi SSID and password, it will set up a new WiFi access point that you can connect to (In my phone WiFi settings, I disconnected from my normal home WiFi and found the new access point). There is also a message displayed on the OLED screen which prompts this action. Once connected, point a browser to and it should show the WiFiManager screen which walks you through setting your SSID and password. Once complete, the ESP8266 should restart, keeping those credentials in its EEPROM, and it should start displaying the current time and weather. You can now restore your phone to your normal WiFi network. The moon will light up with the current moon phase. Pressing the button causes the moon to illuminate one of the six sections for half a second, then start displaying a new LED pattern. During that half second indicator flash, it lets you know what LED pattern is selected:

1) Moon phase mode

2) Rainbow with glitter

3) Confetti

4) TwinkleFOX

5) Juggle

6) BPM

The Lunar Phase Weather Station code can be updated to add more functionality, or just to change the LED progams. You can use PlatformIO or the Arduino IDE. So far I’ve only used Arduino IDE. By following these instructions, I added the ESP8266 as a “board” with the boards manager.

Programming Notes:

  • I haven’t tried connecting the Lunar Phase Weather Station to my work WiFi. On that network, it requires that you click “agree” to the internet usage terms before internet access is granted. This is similar to WiFi networks found in hotels and airports. I do not think the Lunar Phase Weather Station will be able to connect to these networks since it can’t click “agree”.
  • I’m planning to incorporate some extra screens like this: Sun & Moon Screen.
  • Since the Juggle pattern looks a lot like TwinkelFOX pattern (when using only 18 LEDs), I am hoping to program a pattern that adds variety, to replace Juggle.
  • G4lile0’s program had a mode called “Crepuscular”. I had to look up that word. It means a creature that only comes out at Twilight. This could be a new mode for the clock, a moon that only begins illuminating at twilight. I wonder how hard that could be to program? Definitely use the sunset time from Daniel’s Wunderground API.
  • When I designed the 3D model of the electronics box, I made it a lot bigger so you could fit a mini breadboard inside. I have some ideas for expanding the clock’s capability. My first idea is to add a barometric pressure sensor (BMP180).

Hardware Notes:

  • I am working on refining my version of the electronics box. I would like to have two versions: one with a platform that holds the WeMos D1 Mini up from the bottom of the box, and one that accommodates a mini breadboard (170 tie points) or medium breadboard (460 tie points). The adhesive foam pad that is almost always on the bottom of these boards would hold it to the bottom of the electronics box.
  • In the photos, I show a box that uses a metal lid. I haven’t designed one, but the lid can be 3D printed as well, and plastic may block WiFi signals less than a metal lid.
  • When I printed my first half-moon, I used white PLA, and followed G4lile0’s advice, using the Cura slicer with 1mm wall thickness. This resulted in a bunch of thin strings that were left on the moon’s interior that I removed. I have also tried using Simplify3D slicer with a wall thickness of 3 layers. This produced no interior strings, but did not form the top of the hemisphere well, it left some large gaps. Instead of throwing this print away, I squirted and smeared around a little white silicone to fill the gaps. It looks OK, but I will stick with using Cura for future moon prints.

I’ve pasted the code in my Github Gist.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s