user-img

Mirko Pavleski

  • 112 Projects
  • 33 Followers
  • Sep 04,2026
+ Follow

ESP32 Moon Lamp That Shows the Real Moon Phase

A unique combination of astronomy, embedded programming and ambient lighting that transforms an ESP32-powered display into a realistic real-time Moon simulator.

ESP32 Moon Lamp That Shows the Real Moon Phase
 
  • thumbnail-img
 

Hardware Components

  • Elecrow CrowPanel 2.1inch-HMI ESP32 Rotary Display 480*480

    X 1 fenxiang

Tools, APP Software Used etc.

  • Arduino IDE (programming)

Story

  Recently on the Hackaday portal I came across a very interesting project called Moon Display by author Julian Scheffers. Namely, on a small 1.28 inch (GC9A01) TFT Display very precisely displays moon phase, libration, axial tilt calculation and parallax correction based on the observer's geographic position. This requires very complex calculations that are performed locally on the device, i.e. a microcontroller. 

   As you can see in several of my previous projects, I own a CrowPanel 2.1inch-HMI ESP32 Rotary Display which seemed ideal for this purpose considering that it offers almost twice the display resolution, a powerful ESP32-S3 microcontroller, built-in WiFi connectivity, as well as a push button and rotary encoder that could be utilized for additional functionality.

 The original project uses the Adafruit_GFX graphics library. One of the main challenges of this port was adapting the software to the significantly different hardware architecture of the CrowPanel display. For this reason, the graphics subsystem was completely reworked and migrated to the Arduino_GFX library, which provides native support for the RGB display interface used by the CrowPanel. 

Detailed video description at: https://youtu.be/yv4hqoOiPhg

 When turned on, the display shows a message about connecting to the local Wi-Fi network, and then a beautiful image of the current state of the moon for the given coordinates appears.

So, the major improvement was the visual representation of the Moon itself. The original project uses a relatively low-resolution texture suitable for a 240×240 display. Taking advantage of the larger 480×480 display, I implemented a much more detailed lunar surface texture, resulting in a significantly sharper and more realistic appearance. The higher resolution allows fine surface details and craters to be displayed with much greater clarity, making the device look more like a decorative astronomical instrument than a simple electronic project.

 To compile the code without errors on this new hardware, the following settings need to be made: Arduino IDE Board settings :

Board: ESP32S3 Dev Module

Flash Size: 16MB

USB CDC On Boot: Enabled

Upload Mode: UART0 / Hardware CDC

Partition Scheme: Huge APP

PSRAM: OPI PSRAM

It is also important to install ESP32 core version 3.3.7 because with the latest version an unpleasant flickering of the display occurs. Finally, the following libraries need to be installed:

Arduino_GFX_Library

SerialCommands

and time Library

 During development I realized that the display produces a very pleasant ambient light effect, especially when showing a bright full Moon in a dark room. This inspired me to expand the project beyond its original purpose and transform it also into a functional night lamp. The Moon now provides a soft, warm illumination that makes it suitable as both a scientific display and a decorative lighting element. To support this new use case, I activated the built-in push button and rotary encoder. By pressing the encoder button the device enters a manual mode in which the Moon phase can be continuously adjusted using the rotary encoder.

 This allows the user to smoothly transition between New Moon, Crescent, Quarter Moon, Gibbous Moon and Full Moon, effectively controlling the amount of light emitted by the display and therefore the brightness of the room. The transition is continuous rather than limited to predefined phase steps, creating a very natural and intuitive user experience. Despite these modifications, all of the original astronomical calculations and display features have been preserved. The project still performs accurate Moon phase calculations, libration compensation, observer-position corrections and all other astronomical computations developed by the original author. In addition, all configuration options available through the serial monitor have been retained, allowing users to configure geographic location, network settings and other parameters exactly as in the original project.

   As a final visual enhancement, I added the option to modify the Moon's color temperature. Instead of a neutral grayscale appearance, the displayed Moon can be rendered with a warmer yellowish tint that more closely resembles the pleasant glow of a traditional night lamp. The color balance can be adjusted through the following parameters:

 

fr = min(fr * 1.20f, 1.0f);

fg = min(fg * 1.08f, 1.0f);

fb = fb * 0.70f;

These simple adjustments create a noticeably warmer appearance while preserving the surface details and contrast of the lunar texture.

  The final result is a unique combination of astronomy, embedded programming and decorative lighting. It accurately reproduces the current appearance of the Moon using real astronomical calculations while also serving as an attractive night lamp with user-adjustable illumination. Thanks to the larger high-resolution display and the additional controls provided by the CrowPanel hardware, the project offers a significantly enhanced user experience compared to the original design while remaining faithful to the core concept created by Julian Scheffers.

 

 

Code
  • Arduino Code

    CODE_MoonPase_824259076a9a8c576481f.zip
    Download(1)

ESP32 Moon Lamp That Shows the Real Moon Phase

A unique combination of astronomy, embedded programming and ambient lighting that transforms an ESP32-powered display into a realistic real-time Moon simulator.

8
 
0
0
0

Share your project on social media to expand its influence! Get more people to support it.

  • Comments( 0 )
  • Like( 0 )
/1000
Upload a photo:
You can only upload 1 files in total. Each file cannot exceed 2MB. Supports JPG, JPEG, GIF, PNG, BMP

You May Also Like

View All
Add to cart
Board Type : GerberFile :
Layer : Dimensions :
PCB Qty :
Different PCB Design
PCB Thickness : PCB Color :
Surface Finish : Castellated Hole :
Copper Weight : 1 oz Production Time :
Total: US $
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.

PCB Assembly

PCBA Qty: BomFile:
NO. OF UNIQUE PARTS: NO. of Components:
Country: Shipping Way:
Assembly Cost: US $
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.
Add to cart
3dPrintingFile : Size :
Unit : Volumn :
3D Printing Qty : Material :
Total: US $12.99
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.
Add to cart
Acrylic Type : AcrylicFile :
Dimensions: Engrave:
Acrylic Qty :
Acrylic Thickness:
Acrylic Color:
Total: US $12.99
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.
Add to cart
CNC Milling File : Size:
Unit: Volumn:
CNC Milling Qty : Material:
Type of Aluminum: Surface Finish:
Tolerance:
Surface Roughness:
Total: US $12.99
As a sharing platform, our community will not bear responsibility for any issues with this design and parameters.
Add to cart
Item Price Qty Subtotal Delete
Total: US $0.00
Certified Product | Guaranteed Purchase: Full techsupport