Looking for something?

In Starndard
3D Printed, Raspberry Pi Powered, Planetarium Projector Nightlight - Part 1


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).


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.

Edit /etc/kbd/config and /etc/X11/xinit/xinitrc to stop your screen from turning off.




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:

Description = Stellarium  
After = systemd-user-sessions.service network.target sound.target

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

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 /usr/bin/stellarium instead.

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 video=800x480 after rootwait.

And using the instructions from Adafruit's guide here. We edit /boot/config.txt to look like this:


# uncomment if you get no picture on HDMI for a default "safe" mode

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border

# uncomment to force a console size. By default it will be display's size minus
# overscan.

# uncomment if hdmi display is not detected and composite is being output

# uncomment to force a specific HDMI mode (here we are forcing 800x480!)
hdmi_cvt=800 480 60 6 0 0 0


# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display

# uncomment for composite PAL

#uncomment to overclock the arm. 700 MHz is the default.

# for more options see http://elinux.org/RPi_config.txt

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.

0 Comments 10 August 2016
Daniel Chote

Daniel Chote

Daniel Chote, the Code Monkey, Cat Herder, Maker, H4x0r, uav pilot, sim racer, bullshit artist and dad. Made in Hastings, New Zealand... Now living in the USA!

Related Post

Comments powered by Disqus