My son was learning about stars and constellations in daycare and we realized that he is always in bed before it really gets dark outside, so I had the crazy maker-dad thought, lets build a realtime planetarium night light...
The pieces are actually pretty straight forward, big LED, LCD panel, some optics and something to make the pretty pictures (the Raspberry Pi v3). I will use the Pi's GPIO to switch the LED (via MOSFET) and detect light level in the room (via LDR).
- Raspberry Pi v3
- 800x480 5" LCD Panel (or cheap ebay one)
- Adafruit TFP401 HDMI Decoder
- 20W Cool White LED
- Boost Converter to power LED
- Headsink and Lens for LED
- Fresnel lenses x2
You will need to find something to use as a collimating/triplet lens. I ended up taking one from a cheap Chinese LED projector, as the entire projector cost less than a lot of the other options I could find. "Why not use a cheap Chinese projector..." Yeah, yeah, the issue I have was I wanted the crispest image possible, and full control over the throw distance. You could very well skip building your own projector and just go with a Raspberry Pi and cheap projector and call it a day, but you will end up with 1080p input scaled down to whatever crappy resolution the projector does natively, and the kicker is that the projector will likely not run at its native resolution over hdmi, giving you a blurry and out of focus looking star map. Native resolution all-the-way man... Hence the TFP401+800x480 5" LCD panel.
For software there are a couple of solutions that will run natively on a Pi, but I chose Stellarium due to its insane flexibility.
And on to the guide... Firstly, get Raspbian Lite working on your Pi. At this point we don't want any X stuff, we want just the base Lite Raspbian distro installed on an SD card.
After we have a working Raspbian copy running on our Pi, we can get some base things in place...
Setup the Stellarium user:
adduser --disabled-password --disabled-login --gecos "" stellarium usermod -a -G cdrom,audio,video,plugdev,users,dialout,dip,input stellarium
Install the required system packages:
apt-get install --no-install-recommends raspi-gpio xcompmgr dbus-x11 libgl1-mesa-dri xserver-xorg xinit bzr qtmultimedia5-dev
Once you have installed these packages, you should run
raspi-config set your timezone and locale information (this is important, as Stellarium will use it) and then enable the GL Driver (under advanced). Once enabled, you will be prompted to reboot your Pi, do so and then continue.
/etc/X11/xinit/xinitrc to stop your screen from turning off.
BLANK_TIME=0 BLANK_DPMS=off POWERDOWN_TIME=0
xset s noblank xset s off xset -dpms
Now to get Stellarium working. I had issues with font corruption with the standard Raspbian package of Stellarium, so I built it from source.
Install the Stellarium build dependancies:
apt-get build-dep stellarium
Checkout Stellarium using bzr (note: this takes a while):
cd /usr/src bzr co lp:stellarium stellarium
Switch to the a revision that works, when I tried HEAD wouldn't compile.
cd stellarium bzr branch -r8418
Now build Stellarium:
mkdir -p builds/unix cd builds/unix cmake ../.. make -j4 make install
Next we can setup a systemd service to start Stellarium on boot, create a file
/etc/systemd/system/stellarium.service and paste the following:
[Unit] Description = Stellarium After = systemd-user-sessions.service network.target sound.target [Service] User = stellarium Group = stellarium Type = simple ExecStart = /usr/bin/xinit /usr/bin/dbus-launch --exit-with-session /usr/local/bin/stellarium -t -- :0 -s 0 dpms -nolisten tcp vt7 Restart = on-abort RestartSec = 5 [Install] WantedBy = multi-user.target
Note: When building Stellarium by hand, it will be at
/usr/local/bin/stellarium if you are using the package it will be
Now you should test to ensure Stellarium works, you can do this by running
service stellarium start. If something happens, carry on. If it breaks, let me know and I'll fix my guide! 😬
At this point you can play around with Stellarium, I suggest setting your location and FOV, enable/disable things that you may or may not want, and then save defaults. Once you are happy with everything, quit and continue with this guide.
Now we are going to fine tune Stellarium and Raspbian for the 800x480 LCD panel, if you don't want to do that, consider yourself done!
You will want to edit Stellarium's config file, which should now be located at
/home/stellarium/.stellarium/config.ini. These are the settings to change:
fullscreen = true screen_w = 800 screen_h = 480
Edit the linux kernel boot parameters in
/boot/cmdline.txt to force our 800x480 resolution by appending
And using the instructions from Adafruit's guide here. We edit
/boot/config.txt to look like this:
#gpu_mem=256 # uncomment if you get no picture on HDMI for a default "safe" mode #hdmi_safe=1 # uncomment this if your display has a black border of unused pixels visible # and your display can output without overscan #disable_overscan=1 # uncomment the following to adjust overscan. Use positive numbers if console # goes off screen, and negative if there is too much border #overscan_left=16 #overscan_right=16 #overscan_top=16 #overscan_bottom=16 # uncomment to force a console size. By default it will be display's size minus # overscan. #framebuffer_width=800 #framebuffer_height=480 # uncomment if hdmi display is not detected and composite is being output hdmi_force_hotplug=1 # uncomment to force a specific HDMI mode (here we are forcing 800x480!) hdmi_group=2 hdmi_mode=1 hdmi_mode=87 hdmi_cvt=800 480 60 6 0 0 0 #max_usb_current=1 # uncomment to force a HDMI mode rather than DVI. This can make audio work in # DMT (computer monitor) modes #hdmi_drive=2 # uncomment to increase signal to HDMI, if you have interference, blanking, or # no display #config_hdmi_boost=4 # uncomment for composite PAL #sdtv_mode=2 #uncomment to overclock the arm. 700 MHz is the default. #arm_freq=800 # for more options see http://elinux.org/RPi_config.txt dtoverlay=vc4-kms-v3d
Once you have made these changes, you can reboot, and your Pi should restart in native 800x480 and boot right in to Stellarium!
This concludes part 1 of the guide, part 2 will go over my build progress thus far, including 3d models of the prototype components I have designed.