Michaela Merz's personal blog site

Doing something useful with your PI – the easy way

The Raspberry PI is a cute little machine. It’s easy to do a lot of useful things with it. And it’s easier than you might think.

There are plenty of web sites out there explaining how to configure and run a Raspberry PI. And once you have your system up and running, you may ask yourself .. what now?

raspiWell, if you know how to code HTML and JavaScript, the world is open 🙂 You don’t need a bloated desktop to run stuff, you might not even need a keyboard or a mouse. I set up my RasPi with a small touch screen. Its job is to pull the MJPEG streams from my security cams allowing me to overlook my pets (Rollo the dog and Gina the goose) while they are outside doing what they do so well.

I coded everything in HTML/JavaScript including a touch screen ‘zoom’ option allowing me to make a camera feed ‘full screen’ on a tap. I also coded a music selection interface with “cell phone like” swiping action on the touch screen as another RasPi is planned to go into my jukebox. But that’s another story.

So – now you have your HTML-file and your JavaScript code – but how to start everything on boot? Here’s what I did:

1) Modify .xinitrc

DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 0 1
DISPLAY=:0 xset s noblank
DISPLAY=:0 xset s off
DISPLAY=:0 xset -dpms
cd raspweb
chromium --kiosk start.html

Go ahead and try it. Type

$startx

on your RasPi to start the magic. If you’re happy, make it auto-start:

2) Modify /etc/inittab

#1:2345:respawn:/sbin/getty --noclear 38400 tty1
1:2345:respawn:/bin/login -f pi tty1 < /dev/tty1 > /dev/tty1 2>&1

This will log-in the user ‘pi’ automatically after boot, no password required.

3) Modify and add or create a file “.profile” in pi’s home folder

tty | grep tty1
if [ $? -gt 0 ]; then
        echo "NOT AUTOSTARTING..."
else
        /usr/bin/startx
        echo "AUTOSTARTING..."
fi

Here’s what happening. The user ‘pi’ is auto logged-in. But only on tty1. And that’s the only time you want your environment to start automatically. If you ssh into your RasPi, it will not be on tty1 and the auto-stuff won’t start.

Happy coding.

Leave a Reply

Your email address will not be published. Required fields are marked *