Raspberry Pi Complete Tutorial
Raspberry Pi Complete Tutorial
9)€ background-color: vartuin lings x ranean \Wemate the 5 ele nln I . lor: #fftttt: minutes readable else { color: B byaddngad# =] ig ‘Click on a playlist below: KissFM i} BBCRadio2 BBCRadiot BBCRadiog Capitaixtra BBCEMusic Solder the headers Install Music Player els : ae fone ae ss ough aweb-browser. The following Daemon (MPD) will install pyPlaylist on Raspbian: 0 The pHAT DAC comes with a 40-pin header, which you will Now goon to instal the MPD sudo pip install flask need to solder. We consider a flux 03 Bue ip pen, workelamp and thin gauge 60/40 solder essential fr this. An optional RCA jack can also be bought to give a phono-lead output for older stereos. Install drivers 0: The DAC relies on I2C, so we shave to load some additional kemel modules. if you are running Raspbian then you can type in the following fora one-script installation over secure HTTP. H curt -ss hetps://get.pinoroni. ‘com/phatdac | bash While HTTPS provides secure download, curious types may want to review the script before running it. package and enable itto start ‘on boot. MPD will be the backbone of the project, providing playback of MP3s and internet radio stations. The MPC (dient) software is also installed for debugging and setting up your initial playists. H sudo apteget instal! mpd ape [oxic srsteecet enable apd Clone and install pyPlaylist web-server 4 dePeisareponsve (mobile-teady) web-server written with Python & Flask web framework. Once configured it will python-mpd2 Ba - git clone https://github.con/ alexellis/pyPlaylist Bcd pyrlaylist ./raspbian_install.sh “An optional RCA jack can also be bought to give a phono-lead output for older stereos”Build a networked Hi-Fi with a Pi Zero We have put together a list of some popular radio stations inthe UK which can be run into MPD with the add_stationssh file You can exit this file or find your ow from this site: httpy/radiofeeds.co.uk cd ~/pyPlaylist /add_stations.sh Each of the radio station are added into their own playlists = the mpe ls command shows which of the playists are available as shown in the Ist below. Is mc 1s J BaceMusic | pecradiot | Bscradioz | BacRadiog | copitalxtra | kissrm If you decide that you want to remiove one of the stations then just type in the following: Hine rm pcetusicBuild a networked Hi-Fi with a Pi Zero : Projects Start the web server © Oe /D pypuayist - x ea __| © |} 192.168.0.21:5000 vy @ 0 Now that we have some e stations we can run the web- server from the pyPRayist directory. Then ‘open up a web browser to start playing 2 radio station. The folowing command pyPlaylist radio/music player reveals your P address on Raspbian: Hs sraspbian_get_ip.sh => KISSFMUK 192.168.0.20 ‘Once you know the P address, connect tothe URL ina web-browser on port 000 ie H bttp://192.168.0.20:5000/ Adda custom music playlist BBCRadio2 08 Now put together a sub- cnectory with your music fles unde avibymedimusc/ andesite that mpdaucio has access ro read i stainiaaiian Then we update mpa's database, clear ‘out the current playist and addin all the BBCRadio4 ‘tracks from the new directory (ambient), finaly saving rasa new playlist. Capitaixtra ] mpc update wpciclear BBC6Music mpc 1s ambient | mpc add npe save anbient Finishing uy fecongsitererodos "Now that we have some stations, we can oer oeeareannres run the web-server from the pyPlaylist seuce i wor tispupose Tat directory. Then open up a web browser TBhleakctattecceheeiniags tO Start playing a radio station” tohttps/bit ly/290maiH. Go ahead and enjoy the tunes! aProjects What you'll need... Latest Raspbian Image wararaspemypiorgtounlbads Breadboard Connectors Jumper wire DSLR camera Compatibleshutter cable Set up the Raspberry Pi 0 For this tutorial we'e assuming ‘youre usinga recent build of Raspbian. With the Raspberry Piset up with a keyboard, mouse and monitor, ‘open the terminal and type: [sudo apt-get update Install the RPi.GPIO librai O22 ae make sure your development environments set up. Follow these steps to make sure youte all set. In the terminal type: [= atp-get install. python-dev sudo apt-get install. python- rpi.gpio Set up the Pi Cobbler 032 Used a cheap prototyping breadboard and an Adafruit Pi Cobbler togive useasy access to the Raspbery P's GPIO pins As you can see from the pictute, the Cobbler straddles the centre-point of the breadboard anda ribbon cable connects the two, Time-lapse camera trigger Time-lapse camera trigger Make sho camera with tac dv ice g time-lapse v a cin with our expel Youid be forgiven for thinking that creating mesmerising time-lapse ‘videos lke those of Vincent Laforet (www laforetvisuals.com) or John Eklund (www.theartoftimelapse.com) might be out of reach of the Average Joe. With the help of the Raspberry Piand a sprinkling of Python cade, though, that’s no longer the case In this guide we're going to trigger our DSLR camera to create pixel perfect time-lapse imagery. Full code listing import RPI.GPIO as GPIO import time print ‘\nNelcome to the Complete Manual Time-lapse Tool.” print “Just tell us how many shots you'd like to take and <1 the interval between them. \n” print “Try googling ‘time-lapse interval calc’ help deciding. \n” if you need «1 def mainQ): shots take?\n ->") interval = raw_input(‘tow frequently do you want to ”) aw_input(‘How many shots would you like to «1 if shots.isdigit() and interval. isdigit(): shots = int (shots) interval = int(interval) print “You'll be shooting for %d minutes.\n" % «! (shots * interval / 60) answer = raw_input(‘Are you ready to proceed?(yes/ +! no):") confirm = answer.lower() in ['yes’, ‘y'] if confil GPIO. setmode (GPIO. BOARD) tup(16, GPIO.0UT) print print ‘Starting a run of %d shots’ % (shots)Time-lapse camera trigger Manual focus ewon'tbeeonteliog theautofocus with our Python app, soset the focus tomanualand lect Yyourcamerasettingsin ‘vance ofthe shot 2.5mmto3.5mm \Weteusinga cheap Canon EOS DSLR, soto wgger the shutter wth the Raspberry Pall weneed!sa Simple 2mm to 35mm cable Pi Cobbler We'eusingthnePiCobblerasa breakout forthe Ps GIO pins, ‘making the bul process easier houghitsnotrequred) for i in range(®, shots): print print ‘Shot %d of %d’ % (taken, shots) taken +=1 PIO. output (16, GPIO.HIGH) time. sleep(2.5) GPIO.output(16, GPIO.LOW) time.sleep (interval) GPIO.cleanup() else: print “Let’s try again (or press Ctrl + C to <1 quit):\n” main() else: print “Oops - You can only enter numbers. Let’s try + again:\n” main) print print “Thanks for using the Complete Manual Time- <1 lapse Tool!\n’ ‘again = raw_input(‘Wiould you like to do another time- <1 lapse? (yes/no) :\n -> *) proceed = again. lower() in ['yes’, ‘y’] if proceed: main() else: print ‘\nSee you next time!\n" quit) if name = ‘main main() Projects Configure the breadboard O4 zeta 0% control the camera, we need to eateacircuitbetween a pin on the PIO Gn this case pin 230n the Cobbler ~ buti’sactually physical pin 16) and the pin that connects tothe head orto’ of the camera cable that activates the shutter when connected, The base of the connector cable isahvays ground, so make sure you ground the GND’ pin on the Cobbler and the middle pinon the audio jack With the dreut complete. we can focus on the code. The Time-lapse Photography Tool O5*a: small $5ine Python utility called The Linux User Time-fapse Photography Took which asks the user to input how many shots they/d like to take and the frequency they'd like them taken, It then takes that information and Uses itn a For loop to activate the shutter using GPIO pin 16. If youd tke ‘to use the project ‘n the fel’ wetd recommend using the Android app ConnectBot to SSH into your RasPi forinput and feedback. Don't forget tostart your script with sudo python ‘time_lapse_canera.py Creating a video 0 With your camera packed with images, we need to collect and output themas@ video file While it’s possible on the Pi copy them to an easily accessible folder on a separate Linux PC to make it much faster Wete going to use FFmpeg, With the ‘terminal apen in the folder where your images are stored, type ffmpeg -F imago2 ~i imagexB4d. jpg ~vcodec Libx264 -b 800k video.avi. This assumes you have libx264 installed on ‘your machine and the ‘image%o4d. {ipe’ assumes the fle format and the ‘number of digits it's dealing with (in this case‘picture0001 jpg)Wireshark wwinuinresharkor Picam module or USB webeam Get alerts with the Raspberry Pi baby monitor Get alerts with the Raspberry Pi baby monitor 1 Ra While youre settling down to enjoy a boxset, there's always that nagging feeling at the back of your mind ~ is the baby okay? We need to rely on baby monitors, specifically video monitors, in particular those that display footage on an app or by opening an P address in a mobile browser. Add in some motion detection and alert software, and you've got an incredibly useful tool - which, the Raspberry Pi can do for a fraction of the cost. Al you'll need is a Raspberry Pi (the newer the better), and a USB webcam or the PiCam (the NoIR infrared version is even more suited to nighttime use), and a device to view the streamed footage on.Get alerts with the Raspberry Pi baby monitor Survey the bedroom 0 Before you start installing and configuring your Pi head to the baby’s bedroom and take a look around. Where will you be placing the Raspberry Pi sit within reach cof a power source? Do you need to connect an Ethemet cable, ors the wireless signal strong enough? t's vital at this stage to spend the necessary time planning the Pi’ position in relation to power sourcesand network connectivity Enable the camera 0 I youte using the PiCar, this, ill be disabled by default. You can enable this in the respi-config tool. This can be accessed in the GLI by opening Menu > Preferences > Raspberry Pi Configuration, where you should select the interfaces tab and switch Camera to Enabled Altematively, run sudo raspi-config and choose option 6, Enable Camerafor USB webcams, use [J do apt-get install fswbcon And test with Test the camera OB uerrarsserhs project up tofind that the camera doesr't actually work Whether youtre using 2 USB webcam corthe PiCam, youll need to runa command to test the camera. To confirm, use the GUI to browse to / home/pi and view the image jg fie This is preferable to checking in the command line, 28 you can ensure the image is not corupt Install motion 04ers software, motion, can be installed after an update and upgrade of the Raspbian 05. sudo apt-get upgrade leet avccner install mxion [= apt-get update Older versions of motion will not start automatically, and display the “Not starting motion daemon’ ertor message. To avoid this, you need to make sure you run the update and upgrade commands. fyou'e using the PiCam module, youll also need adhiver. Activate PiCam driver 0 To activate the PiCam driver, you need to enter the following command: Hisudo modprobe ben2s35-vil2 This enables the PiCam to communicate with third party apps, such as mation. However youll need toinvoke the driver everytime you reboot, unless you addi to rclacal Open the fein nano [sudo nano /ete/re.local Find an empty line before exit ="0" Projects and enter. Trodprobe bon2835-v4l2 Then CTRL+X to exit, and ¥ to save Auto-start motion OG arrest een configuration fle [sudo nano /etc/default/notion Here, we need to instruct the software to starteach time the Raspberry Pi boots, Find the value ‘daernon off” and change it to read Hesenon on Hit CTRLIX to exit, tapping ¥ to confirm you wish to save the file, and Enter to continue. Next, confirm the motion daemon ‘works ona reboot by restarting yourPi Bi suco reboot Configure motion O7 Terese swcenique the motion software. This means setting the frame-rate (how ‘often an image is captured), image dimensions (laraer images wil take up more resources, thereby slowing the monitor) and setting the video format How you configure motion really depends on which model of Raspberry Piyou will be using for this project Fist generation devices will 7Projects stil handle low-resolution images comfortably fora hires feed, you should probably use the Raspberry Edit the config file 0 Edit the config fle To begin configuration, just ‘open motionconf Hse nano /etcnotion/nation ear Use the CTRL#W shortcut to open search, find each ofthe following conditions, adding the values as specified a. searais 2 width 640 height 480 Fpeg_video.codee pees stream_localhost off Beontrat tocotiest: or? Hf youte recording in a dark room, you Can adjust the brightness and contrast. With the changes made, hit CTRL+X to exit, confirming with Y and Enter. Assign ownership to target directory 09% find that the camera stops streaming images after a short time. This is a permissions issve, one that causes a few images toappear on your screen before the whole thing times out. Overcome this with IE sudo chown motion: /var/ Lib/motion Get alerts with the Raspberry Pi baby monitor You canalso seta custom file path in motion.cont, Look for target_dir and change as appropriate. Remember to save the fle and restart motion when you're done, Start and test your baby monitor 10 Stee fully working baby monitor. At this stage, all thatis leftto get the baby monitor up and running isto launch the motion: Wiens srcncouscsesre, You should be able to browse to the feed by entering the IP address of your Raspberry iin a mobile browser. This would typically be something like 122.168.0.1:008 Check this on multiple devices on your home network to confirm that itworks Adjust motion detection Pee tao nse motion detection works right away. In order to adjust this forthe ervironment you have the Pi baby monitor set up in, open, BE sudo nano /ete/notion/notion conf and use CTRLW to search for “Motion Detection Settings’ Here youll find various conditions with values that you can adjust, such as threshold and area_detect_value These will equite some patient tweaking for the best results. Make motion beep TD cance detection, you can enable a beep to sound when movementis captured. As a project lke this needs some calibration to get the best results, this isa useful feature. ‘Again, this setting is found in motion.cont. Search for ‘quiet on” and change the setting to read Hause off Remember to undo this when youre happy with the movement capture, as itmay cisturb the little one! Adjust image quality While you can alter dimensions 1 of the images captured by the PiCam board, i's important to be careful with the figures you enterin motioncont For instance, a dimension of 133x255 pixels probably won't work. Dimensions need to be multiples of For larger options, look at 1280x800 or 1920x1080. Notonly will larger images impact bandwidth, they'l make the resulting AM fle largerGet alerts with the Raspberry Pi baby monitor Check saved images 1 To confirm the quality of the images captured by the Raspberny Pi baby monitor, boot into the GUI Grinstalltightwncserver and remote connect) and browse to /var! lin/motion to see how they are tuming ‘out. This should give you the info you need to adjust the dimensions of the captured images Troubleshoot camera connectivity 15 reeiroumeicetat motion will work straight away. Ifo images are found, or you cant connect to the stream, run: [tain -F /var/log/systog and W tinese | t2i2 This will display any issues that the process is currently having, which is intended to (and hopefully wall) help you diagnose and resolve any problems. Most issues will be driverelated, so keep this in mind with USB webcams Press CTRLAZ to end, Name your images 16°" collected by the motion software can be configured with a specific naming convention, based on date and time You can find these listed under “target base directory” in motion cont. For instance, you can specify folder for new images, based on date: BD tnt /10-evtnztras-zq) Note the 7" — both directory and Projects images will be named according to date, with images also labelled with the timestamp, Go beyond your home network 17 eestor your chiles sleep from your favourite restaurant? You can do this by installing the No+P software on your Raspberry Pi. This software enables you to get around the fact that your SP won't giveyoua dedicated IP address without paying a hefty premium, by installing a cient app that enables you to view the baby monitor outside your home network Head to wwwnnoipcom and check their knowledge base for detaProjects What you'll need... Aportable hard drive Raspbian srenanpberporgtioloas Pew Reeth eR Deluge Svadeugeronents External storage Store cmplee leon an eter ard ahve frmore spacer esy wana “The Raspberry Pi makes for a great tiny, low-wattage, always-on torrent box to better manage your files” Build an always-on torrent box Build an always- on torrent box Torrenting your open source software has a number of advantages ~ it can be faster, alleviates bandwidth and allows you to share back with the community. Distros, packages and more are available via torrents, and the Raspberry Pi makes for a great tiny, low-wattage, always-on torrent box to better manage your files. Wired networking Yeufbetanfertng ge amountsof amg rednerwarungeomust Install Raspbian Raspbian works justfine for our 01 Sreroacimcline ase on an SD card and go through the basic setup process, making sure to enable SSH in the advanced options and to disable the desktop, Remote access Type ifconfig into your Bis 02 Sirmardine:oteaher address. At this point you can unplug the monitor and set it up remotely, but either way you cen now access the Pi bytyping Is ssh fuserletip address) and entering your password to login. “Tiny and convenient “Tumyour Minoan ays on torent bonyoucanhiienalwcventaed) sralpsceBuild an always-on torrent box Mount hard drive 0 Unless you plan to reformat ‘your portable drive, youll need toinstall NTFS support onto your P Type in Hs sudo apt-get install ntfs 38 ‘Add the hard drive to etc/fstab (open itwith sudo nano /etc/fstab) by adding the line: I ddewthard drive address] [mount point] auto noatime 0 0 Use fdisk to find the name of the storage, and create a mount point such as /home/pi/torrents with mk. Reboot for it to mount. Install Deluge torrents. Install t with Is sudo apt-get install deluged deluge-console Now start and then siop Deluge soit creates a config fle we can edit with Is deluged Bs sudo pkitl deluged And finally, un the following to copy the configfilein case we mess up $ cp ~/config/deluge/auth ~/confi’ deluge/authold 04“ use Deluge for our Basic configuration O5 fw deluge/auth And add to the bottom: B tusert:fpasswordt:1¢ to estict access Now start it up with: Is deluged Is deluge-console Remote connection Now you'e in the client, 06 typetthe following three commands: [contig -s allonremote True H contig atlow_renote exit Restart the Deluge daemon with Hs sudo pkit1 deluged 88 deluged Now open the araphical cient on your Linux PC © concton Manage Remote interface 07 2rreeee Interface, then disable Classic Mode and restart Deluge. Click ‘Add on the Connection Manager, and enter the IP in Hostname and the user we set up earlier Click Connect to see any torrents you have downloading or uploading. Projects Download location 082” Edit again and then Preferences, and change to the Downloads tab fits not on there already. Set the download location to the directory we mounted the hard driveto, and enable ‘Auto add torrents, setting it to ary destination i youplan to dump torrents to the Fi Start on boot OQ fiesrettonuourucan be used tohave Deluge start con boot. Download it with Hs sudo weet -0 /etc/aefautt deluge-daemon http://bit. Iy/13nKOS} Open /etc/default/deluge-daemon ‘with nano and change the usemame tothe one we set up eater. Save it, then download the full int sert and Update with Is sudo wget -0 /etc/init.d/ deluge-daemon http://bit. Iy/3nkKlz Is sudo chmod 755 /etc/init.d/ deluge-daemon IDs sudo update-re.d deluge- daemon defaultsProjects What you'll need... Raspbian Wheezy HDMI cable Monitor Stream Internet TV to your Pi Stream Internet TV to your Pi ind v Finding the content you'te interested in viewing can take a while Whether youte looking for Internet TY stations, video podcasts, audio podcasts or shows syndicated online, taking the time to find and download them can be slow going, particulary if you have a busy lifestyle. You might even have ne time to watch after you've waited for the download. Thanks to the Miro media management software, we can automate all of this, and with the software running on a Raspberry Pi, you can easily build a compact system for downloading and playing back shows that you have an interest in. We're talking targeted TV on demand, which makes this project ideal for staying up to date with particular news and trends on a certain topic. MMe Set up your Pi with Raspbian 1 eee eee oie sse vate to \Wheezy, available via raspberrypi.org/downloads/raspbian. Ensure your Piis connected to a TV or display via HDMI. AS Mirois a desktop application, you'll need yourmouse and keyboard connected to configure itStream Internet TV to your Pi Projects Above Miro gvesyoua Install Miro decent playback interface hd exelent export options , fer converting videos for (D2 ee ett meu cated you Poms cpen therm ‘Terminal and enter: I sudo apt-get install miro Installation wil take a few moments. Once complete, you'lfind Miro in Menu>Sound and Video Click to get started Set Miro to launch at startup O3 Massrsion configured to launch at startup. Open le>Preferences>General and check ‘Automatically tun Miro when Hog in’ and ‘When starting up Miro remember what screen | was on when I last quit, Also set your Pi to boot into X using the raspi-config utility. Check for content 4 Seishinste res [TG and place acheckinthe box ja LL, Bele labelled Show videos ftom pod inthe Videos section’. On the right- mom hand side ofthe window, set your ferred frequency for checking for new content. Mo will poll your favourite websites and feeds based on this setting,Projects ight lack setings can be ated the evant ab wen secessing Mia's Preferences Stream Internet TV to your Pi (Aaya on na aepae ido L Atrnabcaly anal fir sues hun aval omnes ayback (Ply vdeo and nti tems one erat? Sep ater ideo auto ter Resume Poytock conan playing dee rm nha hy wa at oped 1 concn paying mui es tem where they wer ast taped 1 conan ping pens fis ram wna hey em st gp Conf igure playback settings 0. i Yoeaaw the Playback tab, and check Play media in Miro. This limits reliance on other apps, which may drain resources. You should also click the Play video and audio items one after another radio button, ‘and under Resume Playback, check the first and third items, “The more links you add, the more regularly updated content will be downloaded to your media manager” Source videos and podcasts 06 Wrticnorse ued ready to play back the video ‘and audio content that you want to enjoy it's time to find some! The best ‘way to do this is to just check the ‘websites that you regularly use for video and audio podcasts (preferably ‘the former) and then copy the XIML link. ‘Add Podcast feeds 07 In Miro, open up File>Add_ Podcast and then paste the podcast feed URL into the dialog that appears, clicking Create Podcast when youte done. The more links you add, the more regularly updated content will be downloaded to your P-powered Miro ‘media manager, ready to watch or listen to on demand.Stream Internet TV to your Pi Projects oo Fie Sidebar Plafsts Playbeck Sats Comment Heb ‘ter the Uo ‘Above Youcan subse First time use Avoid YouTube eg vencais nt te 08 mzeatents OO Rzzistnatcs comedy ancinews podcasts tutorial when we instructed to building a video podcast Miro to behave in a particular way streaming center, displaying material hen it aunched? I's time to setthat that youte interested in on demand, behaviour now. i's sadly ust no good for videos on The processis started by opening YouTube. This doesn't really restrict the Videos view in the left-hand pane you too much as there are plenty of of the Miro window, and then playing other media outlets to cover, but it's the first video. Each time you boot worth mentioning if youre a frequent your system, Mico will jump to this YouTube watcher Ths isa shame, but View and immediately begin playing shouldn't impact the way you use your content, making sure youget up _it- your Raspberry Pi now downloads and running quickly and smoothly focused content on demand. Checking for new content 10 Itistempting to seta regular frequency for your content checking in File>Preferences>Podcasts, but note that checking too regularly is {going to resutt in resources being hogged temporarily, which may result in an interruption if you happen to be actually watching something when Miro checks for new content. Limit polling to hourly or daily checks.Projects What you'll need... Raspberry Pi2or3 with Raspbian Jessie Wé-Fi dongle rusingraspbenyPi2) Display total 7neh Teucscren Display ecommended) Phillips screwdriver Frame and/or stand (xitsbe options forthe ofc! ouchscrean ply are avalableat Poors and othe deicated i fardwareandacessorysupphers) Scripts intpstthucomamueleyospbery Phote-tame Make a Pi-powered digital picture frame Make a Pi-powered digital picture frame Digital picture frames that display a selection of your favourite photos were quite popular for a time, but are now seemingly available only as free gifts when signing up to magazine subscriptions. These tabletlike devices often made for interesting talking points, but were often let down by low memory, a poor user interface, or both,Make a Pi-powered digital picture frame Projects We don't have to worry about either of those problems with this project. Here we are going to set up a Raspberry Pi with some photo-displaying software, connect a touchscreen display, place it ina suitable stand, and sit back to enjoy the results. Better stil, with this set-up, welll be able to pull images from a range of online and offline sources, giving us some great variety. Prepare your Pi Oats of time with this project f you ensure that wireless networking is set up, and SSH is enabled, Do both via the Raspbian Jessie desktop - youll find the new Raspberry Pi Configuration utility in "5, et up a Menu>Preferences, where you can enable SSH in the Interfaces tab. . Raspberry Pi Gonenneneeny .. _ with some OD Wreeislonyardeiomac shes comes he eigen photo-displaying the back of the 7” Touchscreen Display, making sure that the eables are software” connected correctly. (Older releases require you to also connect and mount the display board) Secure with screws, and then mountin stand,Make a Pi-powered digital picture frame Lightdn.conf ‘Add this ine under SeatDefauls: ) Naturally, youl need a PD collection of photos to cisplay con the Prpowered digital picture frame. We have different options here (See boxout, page 107) but xserver-commandéX -s @ ~dpns ‘When done, save and exit with CirlaX, recommend you start with photos then reboot stored on your P ones that have been copied via USB, via a network drive, or sudo reboot downloaded through your browser. Nimage viewing software feh () Jj configure the Raspberry =D isthe best option for building JF rasa picture frame,wefrst 4 simple Pi picture frame, so install this need to prevent the sereen from switching off This means editing the sudo apt-get install feh lightdm.cont file , ‘Once installed, instruct feh where to sudo nano /etc/lightdn/ find the images, changing /media/ STORAGE/test with your directory path, eg, [orsetay=:0.0 xauTHortTy=/home/ pi/-Xauthority /usr/bin/feh -q plF-R 6 -¥-D150/ media/STORAGE/testMake a Pi-powered digital picture frame Save the script 0 The previous script should have prompted the Raspberry Pi picture frame to begin displaying images from the specified folder, for 15 seconds each, To force this to start at boot, we need to add it into a script. Greate this with: [sudo nano /tome/pi/start= plcture-frawe.sh ‘Add the following, Devinn DISPUAe8. 9 RALTHORITY=/home/ pirxauthority fos/bin/ten a spar oR 60 -¥-0150/ medi a/STORAGE/test Exitand save, then test with: bash rone/pi/start-picture- frame.sh Make picture frame run at boot 0 The script can now be set to run atboot Open BE sudo nano /ete/rc.local and before exit 0, add: [sexo 19 su - pi -c ‘/bin/bash /home/ pifstartpicture from sh & Save and exit. Reboot your Pi and test 08 youte pretty much done! To testit out, use the Usual sudo reboot command to restart the Raspberry Pi and check that the device boots straight into picture frame mode: Ifyou experience any problems, check that your commands have been entered correctly, and in the right places using lightdm.cont ‘and rclocal Stop the picture frame 0 Should you need to stop the picture frame software at any time, this can be done with the following simple command [sudo pkitl feh ‘As long asthe images you prepared for your picture frame don't take up too much space on the disk, they should load up without any problems. Projects Did you know...Build a Raspberry Pi-powered car oa | Bullda Atoy RC carwith two A channels (steering and drive) eae Raspbe Servo driver jumper cables SV battery power bank ° Ente #0790 Hoowered Car Components from Make use of cutti eda i wavwumodmypicom ebBuild a Raspberry Pi-powered car @ 47 Web technologies are moving forward at a huge pace, cloud technologies are bringing mass computing 1o individuals, and hardware has reached a perfect moment in time where sensors, displays and wireless technology have all evolved into efficient and affordable devices. We truly are at a point where nearly anyone can take an idea from nothing to a working product in a week and at very little cost. Just lke this project, which is fun, quick and easy to build on and a fantastic way to learn, We're going to grab an old remote-control car, rip off ts radio receiver and replace it with the Raspberry Pi, hook it up on the network, fire up a bleeding-edge web server and then get your smartphone or tablet to control it by tilting the device. By the end of this, not only will you have a fun toy, you will have leamt about the basic technologies that are starting to power the world’s newest and biggest economy for the foreseeable futureProjects Build a Raspberry Pi-powered car Raspberry Pi-controlled car build process To help our toy car come to life using the latest web technologies and our credit card-sized computer, we're going to need to make some pretty significant changes to its workings. Fortunately, the most complex aspects of the build can be accomplished with a couple of affordable purchases, namely a servo controller board to take care of the steering and throttle, and a 5V battery pack to keep the Raspberry Pi running smoothly. Identify and remove old radio OTmsece effectively battery forthe electronics, but those supply elsewhere. Many shops sell replacing the car's normal (especially with an electronic speed SV battery power supplies - often as transmitter and recelver.Noticethe controller with BEC) get their SV mobile phone emergency top-ups. three sockets on the original receiver, power supply directly rom the speed www.modmypi.com sells a suitable cone goes to the motor controller controle, saving on components SV battery power bank for under £20 and one to the steering servo.Some _fyoudon‘thavea speed controller and you should get a couple of hours remote-control cars also have separate with SVBEC, youll need to get a5V_—_of use from your Raspberry P Powerup TissVatery packkanns wrt =e Servocontrol ‘Adafrle PWM 2 servodverboard from wmodmypicom powered The Raspbery Pst front andeentretokeep hassafe spossble Pickacar ‘oucan use pretty much ny sfforale carter thi projectBuild a Raspberry Pi-powered car Attach the servo cables to the new controller O2 = 6-channel 12 servo controller board from www.modmypi.com as per its instructions and simply plugged channel 0 (steering) and channel 1 (moto) headers onto it There are six cables in total:the bottom two are ‘ground, the middle two are the power and the top two are the PWM (pulse- width modulation) signals. Thisis 2 good time to thinkof places to mount the extra components and the best fixing ‘method seers to be sticky-back Velcro. Connect the I2C bus to the Raspberry Pi 0 We're using the Raspberry Pi's 12C bus to control the servo interface board, which only needs four cables they all go between the Raspberry Pi and the servo controller board as pictured, Visit httpbitly/ N3nq4j for a tutorial on how to set up BC on the Raspberry Pi From top tobottom we need to use the 1. GND, 2. SCL, 3.SDA and 4 ‘VCC, which map directly to the same ports on the Raspberry Pi Essentially this s power, ground and two communication channels. Find everythi a home Overview of the main components 0 Youshould nowhavethe 0 servo board in the middle Projects Hook it up to the Raspberry Pi 4.3 ee Rate she ‘ables look the same. Though the Rev boards have different labelling, the physical pins are inthe same place. Bottom left (losest to the RasPi ower connection is the 33V power; next to that is the SDA header, which isthe data channel. Next to that in the bottom right isthe SCL channel, which ‘controls the dock of the I2C devices. ‘And finally -on the top-right port ~is the Ground. We recommend printing a labelled image of the GPIO pins. We can now put ittogether. Use plenty of sticky-back Velcro, tie wraps or elastic bands to keep everything secure and find spaces in the car's with the steering servo and speed controller on one side and the Raspberry Pion the other. The motor is connected to the other end of the speed controller (that end should have much thicker wires, the speed controller also has two thick wires going to the main cars battery - in this case a 72V NiCad. We now have two very separate power systems with the high current motors on one side and the low current electronics on the other. Let's make sure it stays that way. body to hide the wires where possible. While itis possible to stick or screw the Raspberry Pi directly 0 the car, we recommend to use at least the bottom half of a case for added protection and ease of access. Insert your SD card, network cable or Wi-Fi dongle and power supply Sit backand admire your hacking skisProjects Control your Raspberry Pi-powered car What you'll need... woncamveg,”” ~— CONtrol your Aninternet connection ‘omy _ Raspberry Picar source code aoe Pipowered car Now that we have our fantastic Raspberry P-powered car all wired, charged and ready to go it's time to make it come alive. We're using the best web technologies that the JavaScript programming language offers, to harness the natural movernent of your hand and wirelessly drive the vehicle Each litle movement of your hand will trigger an event that calculates what the car should do and then sends it over a socket connection. Ifall goes to plan you should have complete control over your vehicle Below Allyou need te frish eff your projects access toa smartphone or able 01= of all you will need to the I2C connectivity ‘working, Next wellneed to find a home for our new project code —how about /var/www/picar Type sudo mkdir /var/wen/picar in the terminal to make the directory and then change into that directory: ed. /var/ ww/picar Now, to download the project using Git, type sudo git clone http://github.con/shaunuk/picar- Ifyou havertt otGit instal with sudo apt-get install git. This will download the custom software for diving the car, but we sil need the webs server and some other bits before we can start buming rubber.Control your Raspberry Pi-powered car Do 2 d install Node. Next were using Nodels and its package tool, the ©. Node package manager nom).Type sudo wget http://nodejs. org/dist /v0.10.21/node-va.10.21-1inux arm=pi.tar-gz. This will download a feily recent version of Nodejs-- the version Raspbian has in its repositories is way too Gd and just doesn't work with the new technologies we're about to use. Extract the node package by typing sudo tar -xvzF node-v0.10.21-linux-arm-pi.tar.gz Below You ncedtoadst some ofthe variables to conto your partic remote conta ar setup To make iteasy to un from everywhere, we wall create symbolic inks for Node and npm binaries. Type sudo In =s. /var/wwn/node-v2.10.21- Linux-arm-pi/bin/nade /bin/node and then sudo In -s /var/www/node-v0.10.21-Linux-arn-pi/bin/ rnpm_/bin/npm. Then, to get the extra modules, type rnpm install socket io node-static socket.io adafruit-i2e-pun-driver sleep optinist Now we have everything, you should see three fies the server (apps), the client (ockethuml) and the jQuery JavaScript library for the client The server nat only drives the servos, butt isa web server and sends the sockethiml file and jQuery to the browser when requested ~itsa really neat and simple setup and just right for what were trying toachieve IE Our handy ttle program (ppjs) has a special mode just for testing. keywords here: beta for servo 0 (steering) and gamma for servo 1 (motor control) Type node apo. js beta=300. You should see the front wheels tur. Now the numbers need ‘experimenting with. On our example, 340 was lef, 400 was centre and 470 was fight. Do the same for the motor by typing node appjs gamwma=400 and take note of the various limits of your carProjects ey Hrme Control your Raspberry Pi-powered car “We're using the best web technologies that the JavaScript programming language has to offer” Configure sensible defaults Now you know what your caris capable OG Sire can sete detutsnappisand socket html Edit app js and find the section that says function emergencyStop!. Adjust the two numbers to your car's rest values. Then open socket html and adjust the predefined values Under’Define your variables here! Going for a spin [8 Acre vactar at hse esata the IP address of your Pi car, so type ifconfig atthe terminal Then fire up the app by typing node app js. Now grab the nearest smartphone or tablet, making sure ison the same network as your PL Open the web browser and go to httpe// [your IP address}8080/socket.html. You should get an alert message saying teady’ and as soon as you hit OK, the gyro data from your phone willbe sent to the car and you'e off. ———— de socket html fe. angle to get var wingomas © 250; //backwards 1 var maxgamma = 400; //forward limit var multganma ctor to multiply the dicate of accelerati