100% found this document useful (1 vote)
541 views134 pages

Raspberry Pi Annual

Raspberry Pi Annual
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
100% found this document useful (1 vote)
541 views134 pages

Raspberry Pi Annual

Raspberry Pi Annual
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 134
Rete ef Annual (> 0 EVERYTHING YOU NEED TO GET / sere a ecitaoN MeUnIa cl eC Smart home ideas » Operating systems » Pi gaming Welcome to Raspberry Pi Annua The Raspberry Pl was fst created in 2012. marking an age where making dlgital creation was accesible to al ince then, mote than 40 milion units have been sold to adults and chikiten alle is of diferent kinds are used in classrooms, research laboratories, and of course, hackerspaces all over the world. Builders, coders and hackers are using this superb device to create ing from doomsday switches to frutsipening detectors, n this volume ofthe Raspberry Pi Annual. well give you some exper tips on how to get the ‘most out of yourP. Well ako show you the best operating systems, how to hamess the power of steaming, pus herexcitng projects ~and so much more. Welcome tothe Raspberry P revolution! 4 L FUTURE 4 r ee Pi Annual “ CONTENTS * @ The best maker projects es, MAME ele eecORUf RUNGE Nia cereal sation send eae Create a Raspberry Pi Caer ue co) Seen ac Ne Teens Secs Rune Emulate the Atari STon your Sree taeda Coen ada Ce uae SMe a CT Peers ia aor Seach e PY ee ey Peres) Meme id Parcs Pamete eee arc} ctr (eau tac} eee ri) Cee Tc Teese! Reet ere RTC) Eee eo ed ec adal Paes Se re Re ead SN CNN Te Cec Pci tg ee aE Sra) Cato Tere eS CO Ce nc Cel Cearr nce Cages eA Dee TE) eal eas ets ee ance eee Er Su Cc? Fee a ec! ee Meco) Cee cua eal Cie eerie Cen er eM ur ur Ewer run) security system x The tiny, affordable computer that you can use , to learn programming with \ YW fun projects! aes PROJECTS: Gather round the warmth of the \Qa>& \ 2) — soldering iron and learn how to sa On “3 make stuff with Jonni Bidwell’s = s winter project selection box. ne aspberry Pi and the wider Maker eee eer sel Orme aces Pr eter? ee a weet tee Siero Sener 4 ete ce ene Ce Se ee eee ee eno) eee nee comprehensive specifications. Ae ie ee ee nen cet eee SO eee put of by beginner projects that seem overly Se ce ret eer Ee ers ont a akskieg tt Pee ae oe eer ce Ce eee tis after utility (ike a low-power NAS box), Cees e ees) exciting projects to inspire you. Maker projects Taking your first steps... Start putting your projects together with breadboards and soldering. Just as programming often begins with a program that prints Hello World, so your first maker project might also bbe something which appears faily trivial, But doo't worry, these humble beginnings can be built upon. It's ‘also common for first tempts at programming to result ina series of baffling error messages, andit's likewise common for one's frst makes to go awry. Don't be put off. Syntax errors will continue to haunt you throughout your programming career, and even seasoned makers melt the wrong thing from time to ‘time. Soldering mistakes can more often than not be tundone, and were they can't it's often only an inexpensive component that needs to be replaced. collaboration between ModMyPi and Buyapi.ca has culminatad in their YouTube Workshop Kit. Ft has 10, _reat Pi projects to get you started, and it comes ina fetching red tin. Inside you'llfind a breadboard and a selection of jumper wires and components. Go to hittp://bit.ty/pi-youtube-kit to check the accompanying video tutorials or download PDFS. The workshop takes you through flashing LEDs and buzzing buzzers, to more complex affairs involving temperature ‘and light sensors. The final project connects all the previous ones to make a full-blown motion detector. Breadboarding enables you to buld circuits without having to worry about soldering. It's still possible to make things smoke, but you have to try quite hard, Every hole in ‘each row and every row in each column of the breadboard are connected, so current travels through ‘your circuit as one navigates a grid system in a town, The first things you'll make commonly involve LEDS and resistors. The resistors are there to protect against ‘excessive current going through the former and also to Atha) 28a) Even you dont doanyatt Propet. the Teng of wire ad tresdboardina| tinal atin be afl iter ~ « protect against drawing too much current from the source (for example, the P's GPIO or 5V pins). LEDs have a positive and negative side. If you connect them the wrong way they probably won't break, but ifthe voltage across them becomes too great (right way or ‘wrong way) then you will. The positive side of the LED almost always is the one withthe longer leg, and circuit, diagrams usually depict the resistor going on this side ‘of the LED, although in practice it doesn't matter. On your electronic travels, youl also encounter buttons, switches, capacitors and many lengths of jumper wire ‘The top and bottom two rows ofthe breadboard are usually labelled positive and negative although there's. nothing special about them. For your first project you'll probably not use the +5V pins on your Pi or Arduino, but rather will use a 3.3V GPIO pin. You'l finish your circuit at @ ground pin, and the convention it to usually ‘connect these to a negative row of the breadboard, tye GD Keer tings clean Ciear a neat space ona heat proot surface. Have asolder sponge to hand, You Can old your tems together in place either ‘wth some elaborate clamp setup, or wth ‘good oleashion ls tack and gravity, Use the right size of soldering ron forthe ob in hand: Heat up your soldering iron and when isnot, clean ton the damp sponge Solder on Gently ser the tip of the soldering ‘ron with alittle solder. Ths will help solder flow nicely off it. Carefully hold the solder reel on top of the join and ever so deftly, tap itwith the soldering iron, Holdit there Until the solder starts to melt. Ifitdoasa't mettnicely, try cleaning and sitvering again Ifitmelts too readily, check the next step. Unsolder any errors ifyoue unhappy with your joint then the solder canbe removed witha desoldering wick Heating this up ontop of the oitwil help remove the solder. Desoldering pens are popular for cleaning up bigger messes. Clek these down and then release the vacuum toiterally suck the molten solder into the pen, Pimp your Pi Turn the lil’ Raspberry Pi into a showstopper! Smart Touch etd cases seo avai for Gobres though that some tle Whe ver, o oo as Wemanagedto ack together th wooden i caeinabout tree ours Gnclasing print tia) sa Brough sound the edges ind x Apart from building wonderful projects, you can invest in some wonderful accessories to make your Pilook pretty. Pimoroni's PiGow cases are extremely popular and come in a range of shapes and sizes. We favour the slimline Coupé models, which allow access to the GPIO pins and have a cutout on the ld so that aheatsink can be installed on the SoC. If you're going to be doing prototyping, you can replace the base with a larger one that accommodates a 400-pin (or two 170-pin) breadboard, This keeps your projects alittleneater and tide, Ifyou have access to a 30 printer, or a3 printing service, then you can go one step further and design your own case. The quality and range of materials, available have evolved significantly over the past few ‘years. Gone are the days where your print, fit worked, ‘would bea lumpy, off white insult to your design. These wood: finish materials are impressive, and you'll find allkinds of designs on sites such as www.thingiverse. ‘com, so you can start with something having the correct dimensions ~ always handy! Hey big spender maker! Forget Chromebooks.PiBooks is whore it’s at Alright, at £260 i's not cheap, but the PrTop puts your Pi (not inchided) ina neat laptop form factorin aright green Tue, Side the keyboacd forward and oul fda whole area for prototyping ard playing wth your Pi. “he Pifop comes with anexclusive inventors kit that includes projects to get youstarted with GPIO, sensors and coding a® TheP Toptanforms your Pinto laptop. Ides nat ow that color inthe dark unfortunatly Image credits Mody Thanks to the enthusiastic maker community there area number of things you can make that require little ‘more skils than putting together LEGO. In fact, here's. Cone that you can even incorporate into a LEGO project. For this outing, we're going to transform the Piinto a fully functional tablet, complete with LEGO-compatible ‘mountings on the back, courtesy of the Smart Pi Touch case (available from ModMyP! for £22.99). This project is enabled by the official display kit for the Raspberry P. There have been a few display options forthe Pi three-tine LCD displays and small low-resolution panels, have been around for almost as long.as the P itself, but these are generally not suitable for normal desktop activities. Larger displays eventually became available, but these required complicated soldering on to driver boards, and often required lots of effort to make them work with Linux. This early generation of displays also Used lots of GPIO pins, so that you wanted to use them anda display, then you were out of luck Seeing the need, the Raspberry Pi Foundation designed a marvellous seven-inch 800x480 display that's easy enough to put together and, thanks to the SI Ribbon connection, doesn't need to use any GPIO pins on the Pi. The Pi mounts nicely on the back of the display, and if you don't want to leech power via the PI's SV pins, then the display driver board can instead draw power via its own micro-USB connection, Maker projects Affix the transparent rubber feet to the base. Stick the two ‘square foam pads on the Pi trapdoor and near the case corner (where the GPIO side of the Pi will rest). Your display may come with a short ribbon cable, in which case you should replace this, with the longer one provided. Fix the case tothe base with the generously provided tool. Don't overtighten the bolts because then your hinge wil lose its vigour. Place the touchscreen carefully into the case and feed the ribbon cable through the aperture. Secure itin place with the four dark-coloured screws. Connect the ribbon connector to the Piand place it in the cavity. Itcan be held in place with one or two ofthe small silver screws. Ifyou use that second serew by the USB ports then you won't be able to use the trapdoor, which otherwise secures that side ofthe Pin place Cross your fingers and plug in the power. An up-to-date Pi 0 will ave all the necessary drivers and the display should fre into life, Note the power warning in the corner. Also note that to change the micro SO card while the Pi is mounted, youll need to tnserew it and flip it over. Use the dual-micro USB adapter to connect both the dlisplay's and the P''s power supplies. I's especially important to have sufficient power to supply both ofthese appliances. APC's USB port can typically deliver 500mA, which explains the thunderbolt in the next picture. ‘The Smart Pi Touch case includes @ LEGO compatible case {or the official Pi Cam. Feed the ribbon cable through the slot Af the top and clip the case on tothe side or on top. Note that Connecting the ribbon through the trapdoor is dificult and so you may prefer toremove it. PaPiRus e-Ink display Use a low-power display to read books, display graphics and more. Pi Supply (https://uk.pi-supply.com) has designed a range of cheap e-ink screens that are easy to install and have the puntastic moniker PaPiRus. A number of different screen sizes are available, ranging from a dinky 44-inch (suitable for Pi Zero projects) toa large 2.7-inch (264x176). I's worth noting that the 27- inch model overshoots the edge of the HAT bboard, and hence the edge of the Pi by a few mm. So the whole shebang won't fit in a standard case, Itwill ston top of a Pibow Coupé case or other open case, though. All ‘models are equipped with a battery-backed RTC (real time clock). There are also four input buttons that sit along the edge of the board, Constructing the kit might be a tiny bit fiddly, depending on how fat your fingers are. For full instructions see https://lear.pi-supply.com/make/ papirus-assembly-tips-and-gotchas. The first step is easy: connect the screen to the board with the ribbon cable, Just make sure all the connectors line up nicely ‘The next step isnot so easy, but is also optional. It involves soldering a springy pin, known as a pogo pin, (on to one of two positions on the board (depending on Which model of Pi you're using, the RUN pin on the 3 hhas moved to the other side of the board, so use CNIS, inthis case, and CNIS for all other Pis).If you don't do ‘number of ‘example Python sols frcidedThis neues the batons tomate amenv sytem. >» CONSTRUCT AN EREADER ‘Amazon's Kindle range may have comered the eReader market, offering devices with lengthy battery lives and the magical abi beam titles from their giant library in the clouds, but i you don't want to buy into that proprietary ecosystem, you can make your own. There are a huge number of DRM-ree books online. Project Gutenberg hosts thousands of classic titles that are out of copyright. ‘There are also licenced works (for exemple by Cory Doctorow ~ see interview LxF222) that are redistributed there with permission. DRM- free ebooks can also be bought from humblebundle.com. Getting PDFs to display on the e-ink screen is likely to be a major effort, but the Epub format is widely used, and Project Gutenberg enables you to download books as plain text too, which will be much easier to parse. Soller sree are ‘valabe and so are cases “The diintve example efor the Pr Zero. nage ret MeasP, this, you won't be able to use the wake-on-alarm facility provided by the RTC, but all e-ink-telated functions will work as normal. Next, push the buttons onto the board and solder their feet from the reverse. They'll work if you don't solder them, but theyll rattle around and possibly jump off. They are small enough that you Could easily lose them forever inthis event. Fix the HAT and screen on to the GPIO pins, place the standoffs in between the board and the Pi, and screw them in place. It's software time Now we need to install the high-level software. Full instructions can be found at https://github.com/ PiSupply/PaPiRus you can choose between an easy ‘curl SL https://pisupply/papiruscode | sudo bash, tne liner. or you can do things manually. As of press time there's an issue installing the dateutil python ‘module, so if you see errors you can rectify them with $ sudo pip3 install dateutil and then rerun the set up script. Ifthe SPI and I2C buses weren't enabled already, you'll need to reboot ‘your Pi before you can start playing with it. Run sudo papirus-config and set the appropriate screen size before you do anything else. These screens are quite fragile, but they also behave like they're broken (alisplaying an odd barcode pattern if you don't set the dimensions correctly. Now quit the configuration utility andrun sudo papirus-test. you see errors about missing Adev/epd version, then the paper driver hasn't loaded. Aside from broken hardware, this could be because the HAT isnt sitting fush on the GPIO pins, which isan easy fix. It could also be because of insufficient power. You can try reloading the driver with ssudo systemetl start epd-fuse . Hopefully you figure it ut. When you do you'l find a whole bunch more ‘examples by typing papirus- and pressing Tab. Using handy Python APIs, PaPiRus can display text, graphics, or a combination of both, Maker projects IqAudiO Hi-Fi HAT Listen to high-definition audio on your Pi, and breathe smart life into your old, dumb hi-fi The P's multimedia capabilities were pretty impressive when it was released, particularly the Videocore engine and HDMI port. But one area where it's always been sorely lacking is the quality of the analogue audio ‘output. Ths isa shame as your Pi could otherwise be used to turn your dusty old hi-fi into a full-blown smart speaker system The nitty gritty runs something lke this (and we encourage auciophiles to write in and correct us if we stray too far from the truth here). The analog signal is, ‘generated from digital signals, and those are limited by the PWM (pulse-width modulation) clock to a resolution close to 1-it (read more about PWM in the box, below). This is fine for beeps and bops, but plug it into your fancy amplifier and things will sound hollow, lacking in range. There headphone jack wil also pick up noise and static from other components. Sounds good ‘To our rescue, then, come a variety of DAC (digital analogue converter) HAT bards that enable faithful audio reproduction for not much money. We tested the IQAuciO DAC HAT, which makes glorious 24-bit 122tHz audio reproduction possible takes the cigtal audio signal rm the Piva the 12 protocol and ‘elversitto its own high-fidelity DAC. There ae other manufacturers too, such as HiFi Berry and lo. which offer a separate reciocking unit to circumvent oddities ‘rom resampling audio signals. Some HATs even feature a builtin amplifier s0 you can make atiny 35 watts per channel boombox. We preferred the idea of Using our quality 90s ampitiers though, and found IQAudlO' offering produced a decent sound, We also found out that our neighbours don lke psytrance. Turing your Pinte a smart audio hu is easy with the Volumiostributin, t's avalible for PCs Pls and other boards; grab it from https://volumio.org/get- started, Once you've flashed the SD Card fire up your Piand connect tt the hotspat it sets up fom anather device. youre Pidoesn'thave wireless (or hasan ‘urfavourte MPO chen the acl titled nempcpp. Music sounds beter rn the teria. Unsupported wireless chip), then use a cable toconnectit to your router. VolumelO has partnered with Allo to make the Nanosound player, Which is made of a Pi and one of Allo'shigh- Hake Audio estoin at trade DACs ited witha Sint Custom OLED display ts all corm yo housed in aie box (available seis th inavariey of eolurs) with shor red playback and power buttons tals comes witha Smpsnd ery remote control whichcan even tun te Pon andott Vas sont thanks to wake-up circuitry in the DAC board. Besides Volumel0, you could just as well use MPD to serve your music. The MPDroid program enables this to be controlled from Android Phones, and a huge umber of clients are available for Linux. Mopidy (www. ‘mopidy.com) combines MPD with a web interface and is another popular choice turning Pis into digital lukeboxes. Better stil, extensions make it possible for ‘Mopidy to connect to services such as Spotity, Soundcloudl and Google Play Music. >> PULSE-WIDTH MODULATION ulse-width modulation is a method of encoding information as, digital signals, Using the frequency of the clock generator we can tencode data based on how much time the signal sow, compared to how itis high. If we send.a sequence that sends a 1 then a 0 (for the ‘same time period) and repeats, then that looks lke a value of one half, This is known as a 50 per cent duty cycle, By changing the duty ‘oycle we can achieve a variety of in-between values, so we can approximate an analogue signal. This method is used to dim LEDs, to adjust the position ofa servo or any number of other things. PWM can also be used to mimic an analogue signal for example having an output decrease while the PWM signal s low and increase \while its high. Going back to the Pi example, if we want to play back a 48kH2 audio file then the number of different values between high ‘and low we can make, or the number of different shapes we can encode in a single sample works out at 2.267 point something. This is Just over two to the power of eleven, so our PWM DAC (assuming it's clocked at the stock 100MHz) gives us, in strictly lay terms, just over Abit audio, ‘Audio hardware has been improved with each Pi generation, in particular the high- and low-pass filtering arrangements. The PWM driver has also been revamped in successive releases of Raspberry Pi (08, most notably in October 2017 which saw output treated to.a Complex three-stage oversampling procedure followed by arun Get started with Arduino Learn the Arduino language and see what this tiny microcontroller can do. Occasionally we get chagrinned readers writing in with complaints about too much Raspberry Pi content. So here's something diferent (hold on to your hats ~ Ed) Unlike the Raspberry Pi, Arduino devices aren't potent enough to run a full-blown Linux distribution. For example, the popular Arduino Uno is powered by a 16MHz chip and has a total of 32KB of flash memory and only 2KB of SRAM (where your programs, known as sketches, get uploaded). However, they do have alot of input and output pins, so their main utility is as ‘microcontrollers: taking sensor readings and switching, fon LEDs, spinning motors or any number of other things in response. More powerful Arduinos exist, but even those rely on other devices for heavy computation, networking and storage. ‘You can download the Arduino IDE from https:// There are heaps of categorie examples for youtodecverinthe IDE. st eadto Flamer and ilyour bool >> TALKING PYTHON TO YOUR ARDUINO ‘Sometimes i's good to talk to the Arduino from Python, rather than ‘trying todo itll in the IDE. Having a Raspberry Pi work in tandem with an Arduino is useful. We stil need the IDE to upload sketches to the Arduino, but we can do more with the data fram the Python side. All we need to do is connect the two boards with a USB cable. We ‘communicate via serial link over USB. On the Python side we need the serial module (installed by default) and the device name of our serial link (check the output of Is /dev/tty" ) Set things up with: import serial port = “/dev/ttyACMO" sl = serial Serial(port,9600) slflushinput) We can then read from and write to the Arduino using the object 1, The following reads a single byte and then writes a1, Changes in Python 3 mean we have to coerce the string to a byte: sLread(1) sLwrite(o"’) arduino.ce, oF if you're using Ubuntu you can do it via Ubuntu-Make, which wil fetch the latest version. Do sudo apt install ubuntu-make then umake ide arduino . You may need to add your user to the dialout group in order to communicate with the Arduino (UbunturMake does this for you, but youl still need to log out and log back in again for this to take effect). If you're feeling avant garde, you can also use the web editor from any modern browser on any platform by registering at https://create.arduino.cc/editor. Don't blink However you do it, let's follow the tracitional pathway and load the Blink example. Go to File>Examples> Basics Blink and have a look at the code. We can see it's divided into two functions: setup() and loop(). In the first we define the LED as an output. I's hard to see how this could be any other way. but we still need to specify such things. LED_BUILTIN is a constant corresponding to pin number to which the LED is connected (usually 13). We need to specify a mode before we can use any pin. Moving on to the loop function, we can see this sets our LED voltage high, waits for one second, sets itlow again, waits another ‘second, and continues in this manner indefinitely. Click the Upioad button in the toolbar and see that this is indeed what happens. If we want to read values from our Arduino program con the host machine, we can do so over the serial connection, We need to set the serial connection up by adding the ine Serialbegin(9600); to the setup() function. This means we can send a whopping 9600 bits per second over the USB cable, which the same speed as modems of the early 90s sent data over phone lines. Suppose we want to verify the statement above about the LED being connected to pin 13. Then all we need to do is add the following line ‘Serial printin(LED_BUILTIN), to the loop() function. That's a lowercase 'U in println (short for print LiNe) by the way. Now when we upload Even simple projet with buzzes and witches can lak ay. bak ret vs wer we ny you ga used toh the sketch the LED will blink as before, but if we go to Tools>Serial Monitor we can see the value 13 being spat out once every two seconds. If you have an exotic Arduino you may see a different number here ‘Sensor ona servo For this project we're using the breadboard just to distribute power. Our servo (Towerpro MG699R) is rated at 500-900mA while moving, which is a fair chunk of power. Its stall current (when i's operating at ‘maximum torque, ie. its movement is being opposed) isa tremendous 6A, but we won't be doing any staling. Again though, it's important your Arduino has adequate power and for this project you should connect.a PSU to the barrel connector rather than powering by USB, The signal pin on our servo connects ‘to pin 9.on the Arduino ‘The HC-SRO4 ultrasonic sensor is a fantastic piece of kit. Send a pulse on its trigger line, and it emits a high-frequency squeak. If this squeak bounces off a nearby object, then when its echo returns to the sensor the echo pin will sent a SV pulse lasting as long as it took between sending and receiving the ultrasonic pulse, This timing, combined with the speed of sound (around 330 m/s in air) enables us to determine the distance between the sensor and the object it just squeaked at. This is very much like the echolocation used by bats, except bats work on a much more complicated range of voltages and are furry. By combining the servo and the ultrasonic sensor, we can do some quite fantastic things. The following code, for example, will sweep the sensor left and right. This makes for a kind of radar contraption: const int trigPin =10; const int echoPin = 11; Servo myServo; void setup() { Serial begin(7600) myservoattach(9); } Maker projects en Serer cndng baccesteenal void 1o0p0 Giaaict rel for(int in15ic-165:++) { asta myservoiwritel veg vt serial print); delay(00}, 1 ) We use the seria link to get the rotation ofthe servo ‘and again this can be viewed from the Serial Monitor. From here we can add some code to get data from the sensor information and instead send this, or better yet the distance calculated therefrom as wel, We'll eave this as an exercise, or ust check the link below. ‘There isn't space to go any further with this, but the possiblities are endless. We were particularly inspired by the Object Detector project described at hetp://bitly/ object detector. There, an authentic green radar display is rendered using the Processing language. The drawing partis pretty involved, and features a nice blurring effect as the sensor sweeps left and right, but the underiying hardware is just the same. It's a great ‘exemple of gathering data on the Arduino, and then processing and visualising it on more capable hardware. BUILDING THE SER' TT eae a ae Mount the sensor Carefully bend the bracket to form a ‘90 degree angle. Try to apply the force evenly so thatthe bottom edge doesn't ‘twist: Youll be lucky ifyou get away with bending this back again. Screw in the Ultrasonic sensor with the connectors facing upwards, and secure with the four small bolts provided, Fit to servo Attach the circular fixture to the top ofthe servo and then screw the ‘mounted sensor in place. Don't worry about it facing straight ahead here. The ‘servo may not be at its resting position and't's relatively straightforward to align it from the Arduino IDE and then adjust the ‘sensor to look dead ahead. Connect the cables ‘Attach the cable tothe sensor and connect the jumper wires tothe breadboard as described above. The darkest ofthe three servo wires (usually brown) isthe negative, the middle one (ed) is +5V and the last (yellow) i the signal Besides power, the sensor has trigger and echo pins (connected to pins 10 and 11), & Further making adventures Let's finish things off with a collection of suggestions for further projects. Having a portable power supply for your Pi or other devices is a great idea, and there are afew options. Of course, a standard USB powerbank (and they can store ‘whole lotta Coulombs these days) is fine for many applications, but there are alternatives f youhave a lot of batteries lying around check out the ModMyPi's BatiBirg, This enables you to power your Pi with four ‘AA batteries. For more demanding situations eight A or 9V battery attachments are available. The BattBorg, defends against voltage drops, regulating power as batteries become weaker and refusing to turn iton if they're too weak ‘The Ultrasonic sensor we used earlier can also be sed with the Pi, but we need to be careful because the i's GPIO pins don’t take kindly to the SV pulses from its Echo pin. We need to drop these to under 3.3V to be safe. We can do this with a potential divider: two resistors placed in series with the GPIO pin in between. them. You can choose the value of one resistor and then work out the value the second needs to be. In this case a IK and a 2K resistor will work. Alternatively, check out the UltraBorg board, which makes it possible to connect, up to four servos and four ultrasonic sensors straight to the i2C bus of your Pi (SDA and SCL).It can use a separate battery supply cay terrane es] Siemon ome Pi Piuice is a crowatunded battery fattorg asthe camponerts en the Popa avlale eacalderedocan ‘rzldered it lois) >> POWER CONSIDERATIONS ‘Thanks to most smartphones in the world standardising on micro USB connections (except those made by a certain fruity company), it's easy to pick up a power supply for your Pi. It's powered by the ‘same thing afterall However, one should be careful: many of the cheaper phone chargers aren't capable of providing the voltage required to reliably power the Pi The same thing is true for the USB ports on your computer. This is especially true for the Pi 3s (and newer 3 B+), whose faster SoCs and wireless chips need extra voltage. Many unsuspecting users of these devices have been traumatised by the appearance of a lightning bolt in the top right ofthe screen. Ths signifies a low voltage and that the Pi has throttled its CPU to keep things stable. ‘The underpower problem is further exacerbated when you start piggybacking other devices (such as motors) onto the 5V and 3.3 power pins. With a good-quality power supply ths is fine: the official ‘touchscreen will draw around 1A, and the Piless than that, We heartily recommend using the official Raspberry Pi Foundation PSU, rated at 2.5A, or some other quality unt. I you need to power a number of devices, hubs that can supply up to 3A per port are also availabe, The Pbie batterypack has an RTC and makes your Ptr portable Youcan even ada sade pelo charge hat for your Raspberry Pi. It comes with a ,820mAh lithium ion (Li-Ion) battery that’s good for up to § hours. of use, but this can be replaced with alithium polymer (L+Po) battery. Further, you can attach a solar panel (a large 40W one is available from ModMyPi and Pi ‘Supply for around £116) to charge the battery, making for a completely isolated solution (unless the sun runs ut). Like the PaPiRus e-Ink display it comes with the added bonus of areal-time clock, which will be useful for keeping time while offline. PiJuice's software enables battery levels to be read, and a shutdown script can be set to run when they get low. This makes for adelightfully simple UPS (uninterruptible power supply) solution If youcan find a small-enough power supply (or a big-enough jar, then connecting it and a camera toa PiZero, and then sealing the whole arrangement in a jar, can make for some nice nature photographiy. The NNo:IR edition of the camera (which has no IR fiter) can. leven see at night time, which makes it great for Utrabarg salves several snc prblams a once Youcan even dg ripe Utrabors together ‘TheUnccen HAT-HDincides sme das effects at hanrkenbckto the 8 demo ra Ah thse halon das of computing capturing badgers, owis (if you're lucky) or other nocturnal species. Making a rudimentary motion detection program in Python is straightforward, so you don’t need to worry about filing up your SD eard with the same photo of the eerie, stil darkness. Have we got to 10 yet? We don’t know, but we're going to keep going because there's no end to the fun (and because you have to fil this page ~ Ed) Unicorn HAT-HD Pimoroni's Unicorn HAT's, which featured an 8x8 ‘matrix of RGB LEDs, proved tremendously popular. So they had to go one better and make an HD edition that quadruples the LED count. It also comes with a nice diffuser whose height can be adjusted to make for different blinkeniight blurring effects Aneat trick which we're still working on is getting this to display a spectrum analyser for currenty playing music. MPD can easily be configured to write to 2 FIFO pipe by adding a section exactly like ‘audio output { type "fifo" name “myfifo” path "/var/tmp/mpd fifo" format “44100:161" } to /etc/mpd.conf. We can then access this buffer in Python thusly fifo = os.open('/var/tmp/mpdfifo',050_RDONLY) and perform the required FFTs to get spectrum data, Or you could use the audioop package to do it for you. Maker projects ‘A good starting point would be to make a simple VU (Volume Unit) meter, and we would get the peak level from the buffer with the following: data = osxead{ fifo, 4096) stereoPeak - audioop.max(data,2) One important thing to be aware of is that you can't Use the 3.5mm headphone jack and the Unicorn HAT at the same time. This is because they both use PWM, 0 youll either see glitches on the LEDs or hear interference in your audio. It works fine with HDMI and. can also work on top of a DAC hat such as the IQAudio, lone we tested. Peak biinkenlights is achieved by the LightShowPi project (http://lightshowpi.org), which supports all manner of LED boards and can make them blink in all kinds of ways, Relax with RetroPie The RetroPie project (https://retropie.org.uik) includes ‘2 number of emulators, including SNES and Gameboy (more can be added later) I's available for the Pis as an SD Card image (the recommended approach) or it can be installed manually. Separate images are available for single (Pi1 and Zero) and multicore (2 and. 3) is. It's also available on Linux for PCs, which are ‘more capable of emulating the newer platforms. Abig part of RetroPie is RetroArch,a front-end for the Libretro API (a cross-platform effort that enables different emulators (cores') to be treated uniformly). Go, tohhttps://launchpad.net/~libretro/+archive/ Ubuntu /stable to see the huge number of Libretro cores available on Ubuntu. Many retro-styled gamepads are available to help your ring-collecting or mushroom eating adventures — we favour the old PS2 style. Gamepads and touchscreens and keyboards andl rodents are all well and good, but sometimes you just want to control your Py shaking your fist att ‘And now you can courtesy ofthe Fick HAT gesture control interface. More accurately, you're supposed to use swipes, taps and ficks ofthe wrist, bu this stil pretty cool ‘And that's all we have space for in this month's ‘maker extravaganza. Special thanks to Jacob and Claire at ModMyPi for generously lending us so many goodies to make this possible. Also thanks to local Bath maker, Luke Ciiford for letting us use his workshop, its many tools and for helping us 30 print our wooden Pi-case. “This Gove sensor measures a quay Kean det carbon mena fermaldchyde at ech types MF eveg out BD vores esthours paring 5 Raspberry Pi 4 B Les Pounder loves a surprise and a Raspberry Pi — so when the Pi 4 was released, he was over the moon! CPU: 15GH2 64-bit quad: arm Cortex-A72 CPU (ARM v8, BCM2711B0) RAM: 1G8 LPODRA (268, 4GB options) Comms: Wi-Fi dual-band 802,11 b/g/n/ 2c; Bluetooth 50; BLE Ports: 2x USB. 30; 2xUSB20, gigabit Ethemet (PoE support) 40-pin GPIO: 2x micro-HDMI (4Kp60); DSI display port: CSI camera port Video: 1.265 (akp60): H264 (1080960, 1080p30 encode) OpenGL es 30 Audio: 35m analogue audio: composite video jack HDD: micro SD card Power: US8-C Size: 85 x 56 x 195mm, 46, ‘The BoM hands peabe Ethernet onthe Ph ‘andthe vice ‘is osdFor USB No shared LANG chp any more. ‘Surprise! June isnot a traditional release date for a Raspberry Pi. Infact. this new version of the Pibreaks a few traditions. Firstly, twas released far earlier than predicted due to the BCM271 System on Chip (S00) being ready for production some rine to 12 months early. Secondly, there's the price: there snow not just ‘one price for a Raspberry Pi Model B, but three. At £34, the basic mode! ‘comes with 1GB of RAM: for £44 there is ‘82GB model; and for £54 there isa AGB. ‘model For this review we have chasen to lookat the 1GB madel as we can directly compare it to previous models of Pi No matter the version of P4, all come with a 1.5GHz 64-bit quad-core Arm Cortex-A72 CPU (Arm v8, BCM2711B0) and all ofthe RAM is now LPDDRA ‘ving us @ much-needed boost in performance, GPU, duties are handled by the new VideoCore VI which supports OpenGL ES30 and provides another handy bboost in performance. Ifyou are a keen maker/hacker then fear not, as the 40-pin GPIOiis present and fully compatible with HAT and pHAT boards. But in a change to previous GPIO Configurations the GPIO of the Pid offers four each of 20, UART and SPI interfaces, enabling more compatible devices tobe connected ~ all by changing the device tree ‘overlay on boot For network connectivity, we are truly spoilt. While the Pid retains the excellent 24GHz and 5GHz Wii from the 38+, we finally have true gigabit Ethernet on a Raspberry Pithanks to the BCM54213 Ethernet chip, which provided a stonking 9S1Mbits/sec in our test ~ around three times faster than the 38+. No more Ethernet through USB! ‘Talking of USB, the P 4 has four USB ports ~ two of \which are USB 2.0 and the others USB 30, which have their own chip that connects to the SoC via PCI-E! Yes, we ‘can now connect high-speed USB drives to the Pi for projects such as media centres and fleservers. We can ‘also boot from USB devices, so adding a cheap SATA SSD via @ USB interface will massively speed up your Pi and 4 ThePiscanbe sed a aol i desktop compster steaphtout of theboe provide very cheap and plentiful storage for server. To power the Raspberry Pi4 there is a USB-C connector in place of the old micro-USB port, The USB-C port provides 5V at 3A (15W), which at ide is approximately 4W and 8W when under oad. Since launch a minor flaw has been discovered with the P's USB-C implementation, soit can't be powered by ‘e-marked USE- cables-such as those supplied with Apple laptops-this will require a board revision to fx ‘While 15W may seem like overkil it provides plenty of power for the Pi 4 and plenty of spare power for use by USB 30 hard drives. The current draw at idle fora Ps, ‘much greater than a Pi 38+ ~ 600mA versus 400mA — {and so that means a bigger battery is required. Infact. from cold the Pi 4 consumes around 960mA during the boot process. If youplan to reuse an older official Raspberry Pi power supply (BV at 25A, 12 5W), you can purchase an adapter to.change micro-USB to USB-C. Power can also be provided directly tothe Pl via the GPIO, but this will bypass any regulators, so check your voltages before connecting, I you need Power over Ethernet (PoE), youll bbe happy to know that the PoE HAT is compatible. ‘With all this new power there has tobe heat, and this is where the P4 cifer to previous boards. To be clear, the Raspberry Pi4runs realy warm at idle: around 52 degrees C two minutes after booting up. The temp increased to 66 degrees when under load during a Sysbench CPU stress-test. The board can reach temps of Up to 80C and so this means that active cooling isa must \We ran the same idle and stress-test sequence on the Pi with a Pimoroni Fan Shim, and this dropped the idle termp t0.36 degrees with the CPU stress-test temp at 46 degrees, We have been advised of an imminent firmware fx that will address these thermal Another new feature on the Pi 4 ara the dual icra HDMI ports offering dual screens at 4Kp30, ora single screen at upto 4Kp60. Video is also decoded by a {dedicated chip, so there's no hit on CPU performance. Featurngtwo miro-HOM ports he Pi ole trv dua ply saltion = bt these prt aetoo ight for adapters But whys this necessary? Well, to be honest isn't something that most users wil take advantage of. But AGB users who may be using their Pid as a desktop replacement can enjoy an extra screen, Typically coders {and writers employ two sereens for reference and work To use the Raspberry Pi 4 we need to be running the very latest version of Rasperry Pi OS; older versions wil rot work with the P4 but the latest Pi OS wil work on ‘every model of Raspberry P. Based upon Debian Buster (unveleased atthe time of writing), the latest Pi OSs, impressive and nimble. t booted on our Pi in just under 1B seconds and, after a few hiccups, detected our dua screen setup, giving us 3840x1080 of sereen for projects lovely tuft ‘The Raspberry Pi OS desktop is very usable with Pi 4 and it feels ust like a traditional desktop computer. We ran cour usual Sysbench single- and quad-core CPU stress- ‘test, and the Pi 4 shaved almast 30 seconds from the Pi '3B+ single-core test: 119.3 seconds for Pi38+,927 ‘seconds for Pi 4. In the quad-core tests the Pi4 scored 23.3 seconds versus the Pi38+ time of 3L8 seconds. The 4 also blazed through our Octane benchmarks with a score of 7274, 26 times quicker than Pi 38+. But where the JGB version will struggles with resource:heavy apps ~ Chromium is the main culprit, Watching a video at 720P ina windows bearable; make it full-screen and 1080P and it becomes a slideshow. There is afuture update planned to address these launch issues, 0 we shoulda't have to wait long fora fix. ‘The questions that the Raspberry Pi 4 raises are "Who is this board for?" and "Why do we need this much power?" To be blunt, the Pi 4 does offer alt of power, but ‘most makers will not take fulladvantage oft. The Pi 4 offers entry-level desktop performance and for £34-£54 ‘that should be applauded. But for most hobbyists who make GPIO-based projects, robots, or who are learning to code, then sticking to a Pi 3B+ and using the latest Pi OS. Itmay look mart thse before books canbe deceving “his boad packs real power Bluetooth with Python | >> ALL HAIL THE Pi 4 “The Raspberry Pi 4 ushers in anew era in the history of the Pi ‘Coming seven years after the original release, we now see a Linux {desktop computer for £55 that can be of real use in the home, office ‘oF classroom. Consuming 8W of power when under heavy load, and ‘offering faster 1O ports, this is an energy-efficient platform that we are sure many will take advantage of Lightweight thin clients for offices, VOIP solutions and desktop computers for the home are where the Pi 4 is destined to be used - the power and size of the board is really remarkable. But is this heralding the year of the Linux desktop? No, and is the desktop stil the battlefield that Linux even ‘wants to win? Linux's key to the server and mobile industries and those battles are over. Rather. the Raspberry Pi 4 signals that alow ‘cost computer no longer needs to have caveats on how it performs. release wiloffer ath latest Debian Buster features tno |The new UB and extra cost Anyone ooking to upgrade Ehret pate ther Respbery Pi would be wisetowaitfora whe unti_ | wend Debian Buster andthe F4sotware gains lite matury. | Peers tase Don't get us wrong.— the teamhave done marvelous compat wth work withthe Pi4,but te sofware hiccups need tobe | olersms Uner ironed out before consumers get their hands on one. thecal see Ifyou have been waiting to run your own low-power Linux home server, then the F4is the board of your dreams! There's lots of power, gigabit Ethernet, USB 30 and Debian stability. The other bonus for all users. no ‘matter what version is purchased, isthe immense library cof support and documentation provided by the Raspberry Pi Foundation, alas DEVELOPER: Raspberry Pi Trading WEB: ww raspberrypiorg PRICE: £34 for 1GB (2GB £44, 4GB £54) FEATURES. PERFORMANCE. 9n0 ‘a/i0 EASE OF USE VALUE ono ‘9/10 Truly powerful with great support, the Pi 4 ofers so much, butt needs ite time to werk aut some hiccups » Rating 8/10 The Raspberry Pi 4 full desktop kit The Pi Foundation has launched a full desktop kit, so you can use your Pi 4 for day-to-day computing. Despite the intial speed-bumps, there's no doubt that the Raspberry Pi 4 sets the standard for single board computers, and the inclusion of 4GB of onboard memory equips a Piwith the memory needed for a day-to-day desktop system ~ though we might have afew words about reliable and fast storage, (CREDIT: Raspberry F Foundation Free physical Training for all, that is. icademy Bytes is a new training scheme launched by the P| Foundation. Think of it as @ mini: Picademy for teachers who can't make the {ulltwo-day course. Taking less than 90 minutes, these promise to get everyone up to ‘speed and the community-led scheme is running all around the country. Find the nearest one at https://community. ‘computingatschool.org.uk/events#. Enter the Raspberry Pi Desktop Kit. a box of fun designed to turn the bare-metal P Ainto a fully usable desktop computer. AS well s a Pi 4, of course, the kit includes all the official add-ons you'd hope for: the Pi 4 case, Pi keyboard and mouse, oficial USB-C power supply, official beginner's guide, J6GB SD card with NOOBS installed, and nat one but ‘wo (classic white) HDMI Im cables. Costing £114 and with regional variants that include the correct power supply and keyboard - UK, US, EU and more - it sounds tousiike an ideal Christmas present for any your Raepherry Piktonebox Scratching itches Conference talks for all veryone's favourite beginner anguage (that's Scratch, incidentally) hadits yearly conference earlier in 2019 at the P's HQ in Cambridge. To help everyone benefit from the talks, the Pi Foundation recorded them all and stuck them up on its YouTube channel, There's a playlist already up so sit back ‘and have a good scratch at hittp:/ /bitly/ixf255scratch Hopefully fal VR recordings fr net ya ght? (CREDIT: YouTube, Raspberry PFoundaton Multi sensor MAX30105 Multi Sensor Nothing gets Les Pounder's heart racing like a new toy. But how can we monitor his excitement? For that, we need the MAX30105! Atiny sensor that can be used to monitor your heartbeat, blood ‘oxygen level and detect particulate ‘matter from smoke, thanks toaneasy to use Python library, Designed to work with Pimoroni's Breakout Garden HAT, but compatible with all models of Pithanks to an I2C interface, itean also be Used with the Arduino. Youcan aac the ‘ance drety at here oruzethe rsh arden HAT board When you want to collect sensor data, the chances are you'l consider using a Raspberry Pi largely due to its ease of use and network connectivity, But using sensors can be quite difficult for those new to the idea, Pimoroni released its Breakout Garden HAT board, hich we reviewed in Linx Formatizsve 43, to tenable anyone to connect a sensor and quickly Use it. The MAX30105 board is from the same range, but it doesn't need the HAT board and canbe directly connected to the Raspberry Pis GPIO pins. But what doas this sensor detect? Wel in ‘such a small package we have sensors for heart rate, oxygen saturation (an oximeter) and.a smoke sensor which measures particulates in the atmosphere. These readings are also reasonably precise at 18-bit accuracy. ‘The MAX30105 comes as a simple board designed to interface with the Breakout Garden HAT. but by soldering the included male/temale header pins we can easily use the board with the standard Pi GPIO. Software installation is remarkably simple thanks to a Python 3 package in the pp package manager this handles installation ofthe board and any dependencies, Pimoronis example scripts are avaiable fromits GitHub repository. Inuse the MAX30105 is pleasantly easy, and within a few minutes we had atest script to monitor our pulse We're glad to say we averaged around 67 BPM at rest We then tested the smoke sensor with alittle solder smoke, which was easly detected. We also tested the MAX3O105 with an Arduino Uno, thanks to a built-in library forthe board made accessible via the Manage Libraries dialogue. The included Arduino examples are easy to understand. In fact, pairing this sensor with an Arduino MKRI000 or 1010, which feature Wi, would enable real-time sensor readings to be sent to remote devices, ‘So who i this board for? Well given its simplicity it would be right at home in schools and in the education plenty of Functor The MAKDONS packs into smal package sector. It provides the ease of use and immediacy that students need to keep their interest. The mixture of sensors provides plenty of options for investigating, ‘monitoring and recording data when used with other Python libraries. That said, the MAX3O105 isnot a serious, ‘medical or Iif-saving device, so its use in any project that depends on this functionality should be avoided. But for investigating the possibiltis of using sensors such as this, the MAX30105 isan entry-level component that serves the learner well The MAX30105 isnot a bespoke Pimoroni creation, but the form factor is designed to match the company’s Breakout Garden. The ability to use the MAX30105 with both the Raspberry Pi and Arduino is fantastic and it ‘means that educators, or thase on a budgat, can use the ‘same component across platforms. Infact. if you are skilled with I2C you could easily use the MAX3O105 wath ‘other I2C-enabied devioas such as the micratit. In all. this isa cost-effective and feature-packed board that will spark the imagination of those eager to learn, We ccan novi easily monitor the pulse and oxygen saturation ‘of test subject, and use that data in experiments and projects. Alle need are a few lines of code and an idea — plus awiling, uh, volunteer. VERDICT DEVELOPER: Pimoroni WEB: http: //bit.ly/)xf250max PRICE: £13.50 FEATURES PERFORMANCE 9n0 ‘9/10 EASE OF USE VALUE ono ‘9/10 The MAXGONS' ease of use enablesthis board tobe a grat entry to using sencors with your Raspbery Por Adina. » Rating 9/10 Supercharge your Raspberry Pi Get the most out of your Raspberry Pi with these performance-enhancing tips and tricks. from your doormat, But are you truly getting the most Use better storage hardware space onthe Ras sacondary dk Use these sotup ang opt thebest performance for your pe Supercharge your Raspberry PI OD Lrvsinetnobest 0 card Various standards of SD card are avaiable, mere expensive designed for bettr aro correction For the best performance on your Raspberry P, choose an SOHC card witha highrating. The sameadvice apalies to MicroSD cards, which you can use on your Raspberry with an SD card adaptor er direct insert intoa Raspoery PIB 3 Naketnemostofyour storage You'l gypieally need 7-268 of storage for your chasan Raspberry F distro, 50 any remaining storage on your SD card wil bused fer undates anddatayou create or sve In Raspberry FOS you can open a command ine and run the configuration uty to gain mera space (ery if your Sf H suse raspicontig Expand the Pi 0S partition “aximising the partition affords the full capacity of Dear, whic 5 lifespan (there ace to write too, co the same sectors arent being rt ith raspi-config running, use the arrow keys to select expand_rootfs in the menu Then vat briefly while the partition resized your wil increase the m OS Witecatatonam Rather than reacing and writing data to your SD cara something that will eventually result on relabilty and performance ~ you can configure POS to write ta the system RAM, which will speed things up slightly and ard performance hiowed using fstab (file 9ystoms table, a system 06 Eatetstbineios Thisis much Uke cresting a RAM skin Isalmost aseasytosetup. Inthe command line, enter: I sudo nano /etertstab ‘Add the fol ngtine tomount virtual fle systom: [tpt s /var/1og tnpfs defaults,noatine,nosuid,node= 0735, size-lo0n @ @ Fellow ths by saving restarting th Pi: nd exiting nano (Ctt¥X), then safely I sudo shutdown -r now Above Theresa eatguldetos0 catdsatelinacort) PLSD cards Buy rated SDcards — ealtotenping animage copies fnsbearatnatyou atpategoutat eur DSLR phone ‘oral theyre Sesame a thatyourchosen SO ‘cardwasonethat Yura bingabout YourRepberry Ps Figaro good ‘note Derormanes,ahigh Fea SbHGeard srpletyfapace Inexponsheandcan etme oe ‘htmakosure yorebupngs 5 fiesetemon suse seks greatfor Seotupsaawelas performanceboosts Picking an external USBdrive speedingup your Raspberry Piby mmgeatingtheroot Fiaystmtoan orafdavie shoud Youuseformenest EUsathamberie Yeulcanaaatiash Eorage upto" G3 wthoutrunming Ineoanyaigieant probieatthe Lrgrcivne ISrequredtoread’ ‘etal Arythng Uargeri expense fdunnecessay. iFyodrepianningto ‘neanextera HDD, avers ownpower stppi tae our Configure fstab for fast performance Upon restarting, the virtual file system wil be ‘mounted and /var/logon the RAM disk. Other directories that, canbe moved to RAM include: tapfs /tap tmpfs defaults noat ine nosuid sizeioan @ @ ‘rpfs Aarftmp tnpfs defaults noatime,nosuid size=32 noe ‘rpfs Aarflog tmpfs defaults noatine posuid node-@75, size-l0an @ 0 ‘pfs arrrun tmpfs defaults natin sud node-@755 size-an 0 0 ‘pfs arspool/naueve tapts defauts,noatine,osuid.n de-070 gichi2,size-tOn 0 @ Ae each to fete/fstabin nano, Move your 0S toa HOD f youre concerned about the lfegpan of the SO card wy not reduce your Raspberry Ps reliance on it Instead of Using the SD card asa sort of budget SSO, change its role and ‘adda HOD or USB stick torun the operating system, leaving the card for bootstrapping, This can plvea marked performance boost to the sDear Back up the SD card Begin by creating a copy of your Raspberry Pre SO card Shut dawn, remeve the card and insert it nto your deekton puta. nthecammandine run ‘The path fdewadb represents the SD card Copying should take 5-10 minutos. When complete, remove the SO cardand connect your USBdevice, CopyPi0Sto USB Using a blank Exté-formatted USB thumb drive (or ‘external HDD) asthe destinationdive, enter: sudo dd if--/backup.ing of=/devisde Leave the backup on your computer, ‘288 wrong. With an SD card and USB storage device sharing ‘nidentical disk image, it's time to consider what youre going berry, Jonext~ create a faster Ras Splitthe PiOS partitions Ideally, the boot partion should remain on the SD card bil the rot filesystem is run from the external HOO or USB ‘thu dive, Using your prefered pation manager Disk Utility Sin most distros, unmount and delete the oot esystem fom ‘the SD card, ensuring youhave retained the boat partion After ;emaving the SD card, connect your USB davce and delete the boot partion, taking care to leave the ret filesystem intact Then resize the root filesystem on the USB device, making sure that 10 MBremains Identify the root filesystem ‘ith this configuration youre goingto have the SD card and the external USS storage connected, so you need to tell, the Pi where the root Flesystem is, Stil on the desktop Linux computer withyour SD cardinserted, run [sito nano /oot/endhine.txt Find root=/devimmctlkOp2 (or similar) and change that to read root={dau/sda2 which is your external USB storage. Save andenit, ‘Add other USB devices You can now restart your Pi with the storage devices attached, but as soon as you connect further USB media youll suffer problems. Avoid this by installing gis sudo apt-get update sudo apt-get install gdisk Then angels I sudo gaisk /dov/sdb Enter 2 to display the options and select Recovery and Transformation options (experts on), followed by Load MBR. land Build Fresh GPT, Tap ? ana last tima and select Write Table to Disk’ and exit, Remove and replace the USB device andrun gdiskagain. Tis timo enter land then 1 to lisplay the Partition Unique GUID, Make your Pifast & reliable Make @ nate of the GUID and then switch to the SD card, Reopen emdline.txt and change roat=/dawimekOp2 + root=PARTUUID=XXXXXX, whore the numerical string from tition unique GUID should replace the X0000% When ‘done, ave and ext, You can then start your Raspberry '. Congratulations, your Raspberry is now faster and more relialetouse! Supercharge your Raspberry PI Boost performance with overclocking Need more from your Raspberry PY? It is possible to overclock the computer, although you should be aware of the risk inherent with this activity. You should also ensure that your Raspberry Pi processor is suitably cooled ~ heatsinks for the CPU, Ethernet controller and power regulator can be purchased alive 1G Deestvourasabeny Overclocking is available through raspi-config. Launch from the command line and arrow down to the overclock cption. Four further options are avaliable: Madet, Medium, High and Turbo. With your ideal clock speed selected, ent ‘asp-configand restart your Raspberry Pi to apply I sudo shutdown -+ now Now you will need to perform tests to see how overclocked, Raspberry Pi founder, Eben Uptr running Quako 2 as a good stress tost. Should the P' fal to ‘boot, hold Shift to boot without overclocking, un rasp-config ‘and select amare modest varciock. Run PiOSwithout the GUI Despite these changes, you may find that the GUI remains slow. you find yourself runing alot of commands in bash, the best thing todo is disable launching into X.In rasp config, choose boot behaviour and select the first (default) fption to ensure your i boots to the command line. Should yourneed the GUI enter‘startin Terminal Above Heatenks fortePlarevidey sableand vsaly ‘oeteeathanG10 Overclock witha heatsink — ovrcting angerust nyeompater ‘yom, whichis hye geatthat TheRaspoory? lps ineeapproved ‘Reload tun yourousigthis Yeature, stains snawatercolng ‘yumsare ‘rable forthe RaspeeryPito Stemecruane Ez Copying files from your PC to your Pi Swapping data between a Raspberry Pi and your PC can be tricky. Christian Cawley shows you all the useful options Christian Cawley ‘Mormer hareware and softvare support engineer Christian has ght Raspberry Model Bsin captivity. He plans toada Mode A QUICK TIP ‘ommanicating witha Raspberry ProverssH from Windows 1nolenger requces PUTTY. Inatead, simply insallthe OpenSSH cent In PowerShell, Dothisin Settings» Apps> Manage optional features. Click ‘Add Feature, thenselect ‘OpenssH ‘hen Reboot Windowsto instal then ‘open PowerShell tostartan SSH sesion One ofthe key aspects of using a Raspberry Pi involves, copying data tot. This could be anything, depending on. your use: perhaps you have a Bluetooth audio streamer project on the go, ora digital picture frame. Youmay heed to send over a directory of MP3 files to play, of PNG images to view. Dumping the files to a USB stick on your PC then dragging them from the flash storage on your Piis one. option. It's straightforward, but lacks finesse, and adds too much physical interaction. Instead, i's smarter to tse anetwork option, taking advantage ofthe local network to beam the data wirelessly or over Ethernet from your PC to your Pi You might even set up a network share and make your Pi available to move data to.and from, using any device on your network. These ‘methods should work with all Raspberry Pi models, although some will be more suited to the later devices. You can stick it! Before we look at the high-tech alternatives, however, it's worth going through the basics. Say you have a bunch of files you need to copy from a PC to your Raspberry Pi. Allyou should need to doisinsert the USB drive in to your PC, wait for itto mount, then drag, thefiles toit Safely eject the USB stick once the data has been copied, then insert it into your Raspberry Pi. At this, point, it should be automatically mounted in the Raspberry Pi OS operating system ~ the results may vary with other OSes, though: Ifthe USB stick doesn't ‘automatically mount, open the terminal and find the LULID (Universal Unique Identifier ofthe device: 1s-1/deviisk/by-uuid ‘The USB device will probably be labelled sda; keep a note ofthe name regardless. Next, create a mount point ke this ‘sudo mkdir /media/usb Next, set the Pi user as the folder owner, ‘sudo chown -R pi-pi/media/usb Finally, mount the drive with: ‘sudo mount /dev/sdal /media/usb-o widepi.gidepi Allyou need to do now is open the fle manager. find the device in te left pane, and click to browse. You can then drag the files from the USB flash device to the intended directory on your Raspberry Pi. When you're ® OSB Dem [Beeson [Mccomyers ao 88 BS S Tom aati oer ad attacrat eis wl prevent ou fo sharing too rch data From yourPC to your RaspberyP so keep an eyecn le szes lone, use the eject button inthe fle manager to remove the USB stick. If you manually mounted. enter sudo umount /media/usb ‘With microSD cards, things are ate different. Sure, you can use the /boot directory to copy data from your PC without disrupting the main filesystem, then drag it into place when the Pls running, But if you want to use SD storage with a USB adaptor, youl need to instal software that lets Pi OS access drives in the exFAT format. SD storage is almost ahways formatted inthis way as the file table has been optimised for SD cards. The tools you need are exfatfuse and exfat-utils, These work together to mount exFAT drives as well as format in exFAT format. As ever, start with an update and upgrade: sudoaptupdate sudo apt upgrade Once complete, install exfat-fuse and exfat-utils ‘sudo apt install exfatfuse ‘sudo apt install exfatutils This s particularly useful f you'e planning to set up 22 Samba server or any other project that requires removable flash media, Browsing by Another straightforward option for copying fles from a desktop computer to your Pl ist use the browser, Two easy choices are available: email and cloud storage ‘Simply attach the fils to an email and send it to ‘yourself, or upload to your cloud account from your ‘main PC. Then, on the Raspberry Pi, open the browser {and download the attachment or cloud upload. You right not even need to wait forthe email to arrive ~ simply check the Sent Items folder to find and download the fe. This should work without any problem, although it does of course require internet access. You'll also need to be running the Chromium browser for the best results, especially if you're using Gmail. not, youl find Chromium preinstalled in Pi OS Buster. You can also install it on other operating systems with ‘sudo apt install chromium-browser yes ‘Aithough Chromium willrun on older Raspberry Pi ‘models, the best results from this method can be enjoyed using a Raspberry Pi3 or later, However, be ‘aware that popular cloud storage options are slow on ‘the Pi, even the Pi 4. This isnt a smart option for larger files, but if you have afew photos you need to quickly ‘move from Pi to PC or vice versa i's worth itas a simple solution Keep it secret, keep it SSH ‘SSH is one of the key technologies for remote access to Linucbased devices, To use tfortransferrng data, the Secure Copy Protocol command scp canbe used Start of by ensuring SSH is enabied in POS. The easiest way to dots in advance is toinset the SD card into your PC's card reader browse tothe /aoot directory, and create an empty text fe simply called ssh After safely remoung the SD card and replacing it inyour Fi booting up wll enable SSH, and youl be able to start a remote session over SSH. “Another way to enable SSH ison the desktop. Simply open the Menu, then go to Preferences, Raspberry Pt Configuration, Here, elect Interfaces then cick the Enabled button for SSH, Click OK to confirm. Finally, youcan se ragp-coni on the command line tonable SSH Launch wth sudo raspi-config then open interfacing Options. Use the arrow keys to highlight SSH tap Enter then OK to confirm, You'lbe prompted to reboot te Pi With SSH enablec, SCP is ready to uso. Start by establishing an SSH connection ssh [email protected] Enter the password when prompted To send data from your PC tothe Pi, use sepifile xt [email protected] Be sure tonclude the colon # a the end ofthe command, Nte that your Raspberry Pll ypicaly havea dffeent IP address! This wl end the file to the Praccount's Zhome rectory. To send it elsevnere, spect afl path ‘sepile at [email protected] 0.85x Meanwhile you want to pula fle from your Pito your desktop PC, use seppi@I2168 0. tet ‘ain, te default destinations the Zhome directory forthe user. Spety ale path and flename ater the File transfers Chen dot ply have app forth Put you snl be sbltascesstham he rom owe QUICK TIP Byrow ts should go witht saying bitryoute requ ping dtato Strom your colon, Any device with commanchine SSH can use this ‘method. You're not limited to desktop operating systems, ether for example, an Android or iPhone with, a terminal client app can move data to and from a Raspberry Pi using scp in the same way. Network sharing is caring With your Raspberry Pi setup on your network (irlessly or over Wi-Fi, you might consider a Samba share. This particularly Useful f you plan to regularly transfer data between your PC and Raspberry Pi This method basiealy establishes @ network share onthe accessible from anywhere on your network Easy to set up, this options particularly useful f your main PCis running Windows, For the best resus, this >» DIRECT ETHERNET CONNECTION You're not necessarily reliant on USB flash sticks and router-based network connections to share data between your PC and Raspberry Pi, Amore straightforward option is available: just hook up an Ethemet cable. Raspberry Pi Model A and 8 devices with an Ethernet port can be ‘connected to your PC. Once hooked up. you can communicate with the Piover SSH, copy files using scp or FileZila as described, and disconnect by removing the Ethernet cable, (On Linux, start by installing avahi-daemon. This is a package that includes the zeroconf software needed to detect the Raspberry Pi ‘on your computer: sudo apt install avahi-daemon If your main computer is a Mac, zerocont is baked in, Windows, Users will need to install Bonjour = this s easily done by installing, ‘Skype. iTunes (arrg!-Ed) or Adobe Photoshop C53 (or later),Zerocont vill assign a name to your Raspberry Pi (raspberrypilocal) wich ‘can then be used by any device on your network. Just boot your Piand connect it to your PC with the Ethernet cable. ‘Wait a few minutes for it to be detected, then open your SSH tool or SFTP client and connect to raspberrypltocal, entering the Pi user ‘and password when prompted. Raspberry i, ahigh-rated tele card ‘encoded, will need to be set up to share a regularly QUICKTIP } een on yur tonsa MRR || eters reams ores Renda, | foucewann we yartnesto | ster upatng an uprading OS ‘know the IP install the Samba software: address, These sudo apt install samba samba- catetiz | | commonbin’ 2 fae ‘Next, if you need a new folder to trdytoreal | ave ase wt some | ae Fal pre BESEDT, | smncontte Onn ts cur oot Seoccont” | {SRsSuSannoS Scaarspr_ | "haath lowing ines ote botor Fatih, [your network share name] Leek) path « /home/pi/shared Steen writeable-Yes ra eee een ere ees >» WHY YOU MIGHT COPY DATA {At the top of this tutorial we briefly considered Bluetooth strearning ‘and digital photo frame projects as reasons to copy data to your Raspberry Pi Of course, these are just two examples; many more reasons exist that you might not have considered, For example, if you're running Kodi, custom add-ons can be added to your Pi, Retro gamers wil nd SFTP an excellent option for copying, ‘game ROMs to their RetroPie or Recalbox systems. Using your Raspberry Pi for nature time-lapse photography? At some point youl need to remove the photos from your device, Hosting a website on your Raspberry Pi? If so, you'll need to copy the files from your PC, unless you build it completely from scratch on the Pi. This can take time, so being able to prepare the files, begin the ‘copying process and then go and do something else is convenient: ‘Meanwhile, a Pi set up as an loT project can benefit massively from ‘complete remote access. This might be to manually update software, ‘add configuration files and so on, Or you may need to access and retrieve a database populated by data collected using the project's ‘sensors, for instance. ‘Similarly, you might have an older non-wireless Raspberry Pi robot project that needs some files updating from your PC over Ethernet. You'll no doubt find mary more reasons of your own. = fae | Rertgetert tam seer nh sever BT ether esarasen ‘te copy data to and froma Raper ‘Theconkltons are self: explanatory Setting writeable to yes means data canbe written to the network share. The ereatemask and Airectory mask settings allow read, write, and execute Permissions. Ensure publiéisset to no tomantain secunty and censure that the Ps username and password are needed to access ‘the folder Save the file by pressing CtrH¥X than Yo ‘confirm, and create a Samba user account and password: sudo smbpasswd-api Enter the password you wish to use wien prompted, Next. restart Samba: ‘sudo systemetl restart smd ‘Your Piis then ready to be accessed remotely, a litle like @ network drive. Youll be able to connect toitin the. ‘same way as you attach a network drive in your usual operating system. This method is available Linux, ‘mac0S and Windows. Using more acronyms... Final there's the reliable option of FTP This method spectcally uses the SSH File Transfer Protocol. which {you might think of as FTP over SSH: Ths is the preference of many Fuser, thanks to being so simple tosetup ‘il you need to dois instal an FTP application that supports SFTP, such a Filezila(httpsi/ftezila- project.org) ensure SSH is enabled on your Pi. an the Job'sdone, Stat by installing FileZilaon your PC. For Ubuntu frst upgrade and update sudo apt update ssudoaptuporade Next, install the FieZila FTP software: sudoap instal ilesila ‘You should have followed the steps earlier to enable SH on your Raspberry i before proceeding, Once ‘that’s done and the Pinas rebooted. run FileZila and open the Site Manager Here, select New Site. then in the right-hand pane enter the PIP adress inthe General tab Host el, For Server Type, select'SFTP ~ SSH Fle Transter Protocol Below this, Set the Logon Type to Normal and input Bias the user. input the matching password forthe account. then perhaps leave ete inthe Comments flan case you forget wat the eannacton is for (seul you use FeZila regularly for multple machines). Final. click Connect to establish the secure Connection to your Raspberry Pi Swapping tes between machines fs straightforward The ethane pane represents the local machine (your whereas the righthand pane displays a browsable fie structure for your Raspberry To copy esto the Pi, browse to them nthe left pane and drag ther to the desire folder in the right pane. To copy fies from your Pi to your PC, move them from right ett Using an SFTP client to copy your files is probably the most user-friendly option. Like a Somba share, the Pican be accessed from any platform. You're not lite to Linux, macOS or Windows either ~ mobile devices wth SFTP clients can access data stored on thePitoo File transfers AUR a eas] ea The benefits of SFTP With so many options for copying data to and froma Raspberry Pi, you might wonder which is best, Easiest to set up and compatible with software on all platforms s SFTP (SSH File Transfer Protoco)). The best software for this the FieZila client, available on Linux, macOS, Windows and more. Once installed, simply drag and drop data to and from your Raspberry Pi Install an SFTP Client The open source FileZilla FTP client features SFTP functionality. This allows you to move data from your PC to your Raspberry Pi using SSH, but with the mouse-driven interface of a desktop app. To install on your desktop PC, head tohttps://filezilla-project.org, On Ubuntu, install with ‘sudo apt instal filezilla 8 Copy data to your Pi Copying data with FileZilla is simple. On the lett, youl see files on your PC. On the right are those stored on your Raspberry PL To copy data to your Raspberry Pi, browse for it in the lft hand pane, then select the fle you want to copy, and double-click it.The transfer will commence. Youcan also right-click and choose Upload, or simply drag and drop. 8 ‘Set up SSH Start off by enabling SSH on your Pi. You might use rasp contig (Interfacing Options > SSH) or create an empty text file called ssh in the boot directory before booting. But its easiest Via the desktop. Open Menu > Preferences > Raspberry Pi Configuration > Interfaces and set SSH to ‘Enabled’ Click OK to finish, then reboot the Raspberry Pi to ensure SSH is set. Set up a site in FileZilla Touse SFTP, setup your Raspberry Pias stein FileZilla, Open File> Site Manager, then New Site. On the righthand pane add your Pr's hostname or IP address. Below tis, set the SFTP option, then input your Ps username and password. Finally, click Connect. As longas both devices are connected to the same network, aremote connection should be established Edit remote files locally AAs wellas copying files from the Raspberry Pi, you can also edit them on your PC, This creates a temporary file thats then re-uploaded once saved. Right-click a ile, then select Edit to {download and open tina suitable app on your PC. After saving FileZilla wil ask you if you want to copy it back to the Pi. Click OK toproceed. gE Optimise your Pi for better performance Christian Cawley presents his tips and tricks for squeezing as much juice out of your Raspberry Pi as possible. Christian Cawley has spent the past years teling people how tod the same computing tasks but sti hasno idea how cars work Has your Raspberry Pi slowed down? It's common problem ~ it doesn't matter which version of the Pi You're using. performance always suffers ifthe ‘operating system isnt correctly configured. Using a lightweight operating system such as Pi OS Lite, DietP, fr piGore can help, but there's much more you can do, Performance boosts can be gained from overclocking, changing how RAM is used, and ditching bloatware, ‘among other things. Power rangers The wrong power supply can wreak havoc with your Raspberry P's performance With insufficient power to deal wth processing requirements, botienecks can ‘occu soning the computer right down, Lov power can also result in read/write issues, which in turn can damage the microS0 card (more on thet ate), Then there's the usual end result ofa frozen Raspberry Pr pulling the power lead and rebooting To avo this, youneed to ive the Raspoery Pia reliable power supply. This means using good-quality PSU (it not theofficial deve) rather than a spare USB port onyour PC, TV or power ba. “The oficial Raspberry Pi power adapter has 100-240V input, and 51V2.5A output If you're not Using the ffeil PSU, you should ensure that your supply matches this, and thatthe micro USB cable is of good quality in working order and fits the Raspberry Pi correctly, Super-size Pi Using PiOS Lite or some other ightweight distros a ‘g00d option fora stripped-back experience. but if youre Iooking fora more feature-packed operating system. the standard Pi instalation your best option. ‘Aful gigabyte of storage space can be freed up by removing unused tls such as LtveOfice the Wolfram Engine, Minecraft and Sonic P To benefit from tis uly however, you need fo have the full eapacty ofthe SD card, This means using the Expand Filesystem option in the raspéconfig ool, othe Raspberry Pi Configuration imenuon the desktop, You'l find this onthe System tab Removing what might be unfairly termed “bloatware oni OS iseasy. Open a Terminal prompt and type sudo apt purge ibreottice* sudo apt lean sudo aptautoremove “This wil remove LbreOfice from Pi OS. Replace the Ubreofice* command with wolfram-engine rinecraftpi and sonie-pi to remove those tools ‘With these four options removed, youl have the advantage of increased storage space on your Pi without having the limitations faite distro. Kill JavaScript dead While it’s wise to limit the number of tabs you have open in your preferred browser, further performance boosts can be gained by disabling JavaScript. How you do this will vary. In Chromium, use Menu>Settings> ‘Advanced>Privacy and security>Content settings> JavaScript, Here, switch Allowed to Blocked Disabling JavaScript can improve overall performance, as well as speed up some any pages that rely onit. While this might mean pages become less functional, it will also help to reduce the load on your Raspberry Pi from adverts and trackers. Note that ‘exceptions can be added to your browser settings to allow JavaScript to run on specific sites, Underclock, overclock, Pi-clocking’s free Massive performance boosts can be enjoyed by your Raspberry Pi by overclocking the processor. Pi OS offers. this as a builtin feature that can be found in the raspi config tool (other distros may require additional software), Access the overclocking tool by selecting, Overclock on the main raspi-confg menu. Depending on ‘your Raspberry Pi model, you'll have several options here. The default option is None, with the clock running at the basic 700MHz, but you could ramp things up to 1000MHz and above with Turbo mode. Using the overclocking menu means you can avoid having to worry too much about stress testing as the values on offer have already been tested. However, ‘Turbo mode might cause problems, so it's a good idea touse a cooling solution (see Quick Tip. righ) ‘ith 3 Raspberry Pi3 and above, you can also edit ‘the contig.bet file in nanoto specify values forthe four overclock settings: arm_freq, core freq, sdram_freg, and aver voltage. The usual overclacking rules of taking ‘baseline reading and increasing incrementally apply ‘The benefits of overclocking your Raspberry Pi Include increased performance for video decoding in ‘Kodtor playing more games from the fifth and sixth _generation consoles that can currently be emulated on the Pi, Emulation of Windows apps with the ExaGear software is also improved Ditch the cheapo SD card Finding the right microSD card for your Raspberty Pi can be tricky, but with the ight capacity and speed it can make a huge difference to how your Pi runs ‘The secret here isto stick to named brands such as ‘SanDisk, Samsung and Kingston, while keeping an eye fon the card's speed and rating. A higher rating indicates better speed and error connection, which will improve your Pis performance. ‘Once you've added a quality SD car, it’s time to start looking after it. By know you should know how to correctly shutdown a Raspberry Pi. Doing 5o wil prolong the lifespan of the SD card, saving you further ‘outlay (however inexpensive a replacement might be) and the fuss of setting up your Pi again from seratch, From the desktop environment, be sure to shutdown from the main menus If you're using a Kod media centre distribution or a retro gaming suite take the time to find ‘the shutdown option and use this. It’s quicker or you're connected to your Pi over SSH, it’ easier to shut down from the shell: ‘sudo shutdown -hnow Youcan also schedule a time to shut dawn the Pi: ‘sudo shutdown -hO246 ‘An orderly shutdown will ensure your SD card's integrity is maintained, as well as avoid data loss. Zippy ZRAM RAM configuration options for the Raspberry Pi mean. that you can easy designate a portion of RAM tthe GPU # necessary or reserve for nom graphics tasks. Using the Advanced Options sub-menu in asp confg nd the Memory Split option and use this to Speciy how much memory the GPU should have. For txample f youre not using a desktop environment. then you can setts to 16MB, allowing the Raspberry Pi's processor to benefit fom extra memory. For Optimise your Pi Twaakthe RaspbaryPis ramon slit ‘sgn more RAM, tothe CPUar the GPU whichever takes your pi _graphic-intensive tasks, however, our GPU will need more of the RAM. Note that even with a Raspberry Pi3 | QUICK TIP 8+ (which has 1GB of RAM), youl be unebetoasign | Prong ‘more than 256M to the GPU. pertonance Perhaps the best performance tweak forthe Brod om Raspberry ican be made tothe RAM. utisng unused | overokng Space for swap dota Byntating ‘As explained by YouTuber NovaSpirit Tach, ZRAM heatsinks can be used as a swap disk. While the data won't persist | onthe Sot folowing areboct this can speed your Raspberry Pi | andrawork Up considerably. chips For the Begin by grabbing the scrip rom GitHub ena sudo wget-O fus/bivaram sh hps://a¥ Raced aithubssercontent.com/novaspiivrpl sram/master/ | tancoong zamsh sehen Next. make the fle executable and edt relocal torun | vale for the sept when youeboot dr 0 sudo chmod +x /us/bin/aramsh sudo nano etfrclocal Look forthe ex tine, and above it dt ‘ustfbinvaramsh & Hit Ctrl+X to save and exit the file.ZRAM swapping is. far faster than relying on even the fastest microSD card, with an instant performance boost. >> DON'T PUSH YOUR Pi ‘As versatile as the Raspberry Pils, is a good idea to be certain that it’s the right device for the project you have in mind. You might just be using the Raspberry P for retro gaming or Kod It might be acting as a desktop replacement, or as the main component ‘of an loT project. f your Raspberry Piis up tothe task, then it should ‘work fine. The problem is when you choose a task that the Pi just can't do, even when the hardware appears to be a good ft. Conversely. the Raspberry Pi might be far too advanced forthe task. you have in mind, such as flashing an LED over the web, or something, equally ow-spec, Pethaps there isn't quite enough RAM; or maybe the issue is with the ARM architecture, Whatever the problem, all the configuration tweaks and tricks in the world won't help ifthe hardware ‘can't handle the project. Even the Raspberry Pi3 B+ isn’t powerful enough for some situations, So, what's the alternative? Well, you could look at some of the P's nearest rivals, such as the ASUS Tinker Board, Pine64, or even ‘Odroid-XU4, Rather than trying to do everything with the Raspberry Pi, choose the right device for the job. Custom embedded Linux images Tam Hanna guides you through creating a custom — and very small — Linux image for your Raspberry Pi using Yocto. Uy EXPERT ‘Tam Hanna certified electrical engineer witha fancy forprocess computers. One of is current projetsimohes anembecked Linx sjstem used track school buses, veeto atomatially determines when 3 new configraton as tobe created, e The Yocto Project (Yocto) wwwyoctoproject.org is 2 system that uses the Linux kernel and packages Contributed from the Openémbedded software team. The Yocto team points out that its product isnot a Linux distribution, but instead builds custom distributions: nevertheless, it can still can be extremely useful for Creating a custom image. “The main contribution ofthe Yocto developers is ‘a build system called Bit Bae. It fetches code from a variety of sources, can manage all kinds of compilation processes and can also take care of exporting the results in aready-to-burn format. ‘AYocto-based system consists of recipes and configuration files. Configuration files have a cont suffix and contribute attributes which govern the build process, BB files are called recipes, and are responsible for creating the actual components of the distribution; ultimately, running a recipe leads to the creation of a package. Yocto differs from other embedded systems in that itdivides its software stack into a set of layers. Images are created by combining layers, with Bithake determining the compilation process. This approach ‘might sound exotic, but it works well For example, adding a new software stack such as Qt to an existing Yecto project can be accomplished by adding a reference tothe .bb file to the configuration, This ability isnot only beneficial f youneed to change the composition of the image. Projects based 10n Yocto are easy to maintain, as changes ofthe kernel and other things happen automatically This does not ‘mean Yocto isa silver bullet against all ils, though: if specifi program cannot be compiled forthe target due to cross-platform problems, there is nothing BitBake ccan do about it. Get baking Aswith al other build systems, a relatively recent version of Linux s recommended — we'll se Ubuntu 1804, Star-up involves donnioading a batch of packages which are required for running the various tools contained in Bitbak: 8 sudo apt-get install gawk wget gi-coredifstat unzip texinfo gee-multiib\ ‘uild-essentia chrpath socat cpio python python3 python’ pip pythons pexpect \ se-utis debianutilsfputils-ping libsdl2-dev xterm Should you fel Ike using a non- Ubuntu distribution for compilation, see htp://bit.y/ix25tyoctobuild — the Yocto team is glad to provide package installation ists forall commonly used versions of desktop Linux. inthe next step, the actual Poky ules need tobe downloaded, Tiss best accomplished via GitHub: ~/yoctohouset git clone -b thud giti/gityoctoproject. org/poky When git has done its ob, your workstation is the proud owner ofthe basic Poly distribution alongwith Compilation tools. nthe next step, a configuration needs to be created ~it contains the various settings files which decide, among other things, the recipes required. Create a new configuration by sourcing the ‘output of the oe-init-build-env utility: Iyoctohouses cd poky /yoctohouse/pokyé source oe-init-bulldenv Invoking the program fr the fist time leads tothe output shown in screenshot et), Note that the current working directory ofthe terminal also was changed to the home folder of the newly created configuration, With that out of the way, the tei ripe for stating the compilation process, Change into the newly created folder, take a quick ook around the eont folder to find both the configuration and recipe fe and fie off the compile command! /yoctohouse/poky builds bitbake core-image-sato ‘When invoking BitBate, a parameter describing the typeof image is required, We instruct the creation of an image based on the Sato GUI stack - a simple graphical User interface intended for resource-constrained devices, Unlike other build systems, BitBake is highly ‘optimised, so don’t worry if CPU usage is low at first ~ especially when being run for the first time, the tool needs to invest abit of time downloading various packages from the internet, Once the intial downleading process has completed, CPU loads of 100 per cent are not unusual, even on machines with tight or 12 cores. On our machine, compiling a basic ‘BitRake image takes more than three hours and downlcads about 3GB of information ‘When done, the product will nform you about the execution results NOTE: Tasks Summary: Attempted 5794 tasks of which S didn’t need tobe rerun and all succeeded, ‘Summary: There was 1 WARNING message shown, Freshly downloaded property distributions are configured to create an image intended for the QEMU ‘emulator, Taking a look atthe spoils of our work is easy’ ~/yoctohouse/poky/build# rungemu gemux86 ‘rungemu INFO - Running MACHINE-qemux86 bitbake-e.. rrungemu - INFO - Continuing with the following parameters: Don't worry it QEMU asks for your superuser password a new network interface needs to be ‘mounted so that the virtual machine can access the internet. After about two to three minutes, the desktop shown in the sereenshot (above right) will appear. Baked ina Pi Creating a desktop image for QEMU is not particula interesting, Yocto would be able to demonstrate its strengths f we were able to move to new architectures with minimal effort, so let's download a layer supporting ‘the Raspberry Pi 3: ~/yoctohouse/poky$ git clone git//aityoctoproject. org/meta-raspberrypi Cloning into ‘meta-raspberrypi'.. remote: Counting objects: 6109, done. ‘The drivers andl adaptations required to run Linux on a specific target are known as board support package or BSP In the case of the Raspberry Pi, the Yocto project ‘manages its own board support package which has just bbeen downloaded. Experienced Yocto developers should not send a letter at this point: we intentionally omitted ‘the -b parameter to download the latest version of the ‘modules, for learning purposes. Next, a new configuration must be created: ~/yoctohouse/poky/buildé ca. ~/yoctohouse/poky$ source oe-init-build-env piHouse ‘Changing into the home directory of our project, we ‘once again invoke the oe-init-bulld-env utlity. Ths time, we passin an addtional name for the new configuration. When the tool has done its job, the folder contains an additional subdirectory. Here is @ quick look atts contents: ~/yoctohouse/poky/rpiHouse/conf Is bbblayers.conf localconf templateconf.cfg Note the configuration file lacal.conf, which is what we want. Open itn your text editor of choice, and scroll, Custom embedded images “The Sato GU stack woritwinany bruty pageants to the following block #MACHINE ?-"edgerouter” # 4# This sets the default machine to be gemux86 ifno other machine is selected: MACHINE 7?- "gemux86" ‘BitBake requires the presence of the MACHINE variable its value is used to determine which target platform the image should have. Lines beginning with an # are comments, while the 2 operator is responsible for setting defaults. Given that we want to target the Raspberry Pi, the following declaration is needed: ‘MACHINE ?- "“raspberrypi” BBMASK "meta-raspberrypi/recipes-multimedia/ \ibavimeta-raspberrypi/recipes-core/systemd” Inadition to setting the machine variable to target the Arm system, we also passed a BBMASK .This is 2 regular expression for excluding recipes from the build process; the string used here is commonly found in Raspberry Pi builds bbblayers.conf isthe top-level recipe defining the steps BitBake needs to take. By default, its content starts out withthe following declarations: 4# FOKY_BBLAYERS. CONF VERSIONis increased each time build/cont/bblayers.conf # changes incompatibly POKY_BBLAYERS CONF VERSION ="2" STRESSING OUT ‘Compiling Yocto images puts extreme levels of strain on your hardware and your net connection, When we started experimenting, with Yocto, we purchased a high-performance workstation based on ‘an FX8320 octa-core processor from AMD, along with 16GB of RAM ‘and a 128GB SSD. When work on this tutorial started, the machine had about 90GB of foe storage: when done, we were down to zero. RAM usage stayed below 8GB most of the ime, however: having an additional &GB made sense due to our penchant for playing around with virtual machines. Keep in mind thatthe Yocto build process is CPU- and disk intensive, so running desktop applications while the process is taking, place in an uncomfortable experience. This makes Yocto ideally ‘suited asa stress-test for your hardware. fa workstation has any kind of thermal issues, a Yocto run is very likely to find them, unless they are caused by the graphics processor. Developers seeking to experiment with nice values and other ‘scheduling tweaks can also use a Yocto build itis among the most ‘comfortable ways to load your system quickly while simulating QUICK TIP ‘Should you stil find yourslt onahard-dke based machine, stop drinking ber or Red Bull ‘ntl you ean afford an SSO to ‘work with Yet, Tutus when we say thatthe productivity fainsare more than worth realistic behaviour. BBPATH =“@{TOPDIR}" BBFILES?="" ‘The BBLAYERS variable isresponsible for setting the layers required. Modify it to make our newly downloaded layer part of the project: BBLAYERS?="\ ‘rome tamhan/yoctohouse/poky/meta \ ‘Trome/tamhan/yoctohouse/poky/meta-poky \ ‘aome/tamhan/yoctohouse/poky/meta-yocto-bsp \ ‘some tamhan lyoctohouse/poky/meta-raspberrypi \ ‘This modification usually doesn't cause problems for ‘experienced Linux developers. The main oddity involves the syntax; each line needs to be terminated with a N (Once done, it stime to invoke BitBake: -/yoctohouse/poky/rpiFfouse¢ bitbake core-image- ato BitBake does not limit itself to performing the actual ‘compilation process, but also runs various checks to ensure the plausibly ofthe image at hand. In the case of our current configuration, the compilation cannot be done as the “ibmms' package is missing NOTE: Resolving any missing task queue dependencies ERROR: Nothing PROVIDES ‘libmms’ (but /home/ tamhan/yoctohouse/poky/meta/recipes-multimedia/ ‘gstreamer/gstreameri0-plugins-bad 1144.bb DEPENDS on or otherwise requires it) Close matches: liber ibfm bcomps ‘While you can force BitBake to compile if packages are missing, the resulting images usually wll nt work fon the target system. Instead, open the readme file of our newly downloaded layer. It contains the following statement, informing us that 2 few additional layers from the main Openémbedded distribution are needed: * URE git//gitopenembedded.org/meta- ‘openembedded >» YOCTO WILL NOT SAVE YOU MONEY ‘When optimising the bill of materials for a process computer system, ‘opting for smaller memory card sizes always seem like a good idea But reducing the amount of memory used in a process computer Usually does not lead to significant cost savings. ‘Three issues are responsible: first of all, permanently falling memory prices caused by Moore's Law and semiconductor industry factors quickly diminish savings. Secondly, memory card cost is but a small part of the TCO. ‘Optimising other parts tends to give significantly more savings: a .g00d example would be switching the Raspberry Pi 3, which sets you back £35, for an Orange Pi which can be had for much less. Finally, the appearance of a pesky customer asking for an extra feature after release is almost preordained. If your system is space: ‘constrained, implementing simple software changes can turn out to bea huge nuisance, requiring 3 recall ora complete redesign. ‘This. of course, should not discourege you from using Yocto for any of the reasons mentioned in ths article. However, switching to Yocto purely in order to save space on the microSD card almost always turns out to be a waste of time, with costly side effects, Don't ‘say we didn't warn you! me "layers: meta-oe, meta-multimedia, meta-networking, ‘meta-python. branch: master “revision: HEAD Froma technical point of view, you should know what happens next. Change back into the main folder, and obtain the openembedded folder via the following command. The disclaimer about missing parameters from the BSP layer also's valid here - we'll find out ‘more about it quite soon. For now, however, simply burden your internet connection with an additional download command: Iyoctohouse/pokys git clone git! ‘openembedded/meta-openembedded Enumerate the contents of the folder once the download has completed: /yoctohouse/poky/meta-openembeddeds Is contrib COPYINGMIT meta-demo meta-filesystems ‘meta-gnome meta-initramfs meta-multimedia meta- networking meta-oe meta-perl meta-python meta- webserver meta-xfce README ‘The openembedded folder contains a set of ‘additional layers, each of which provides packages dedicated to one function, Return to conf and add the ‘missing lines to the bb file in order to-add them to our compile process: [BBLAYERS =" ‘Taome/yoctohouse/poky/meta\ ‘rome /yoctohouse/poky/meta-poky \ ‘faome/yoctohouse/poky/meta-yocto-bsp \ ‘rome! yoctohouse/pokyy/meta-openembedded/meta- oe\ ‘rome yoctohouse/poky/meta-openembedded/meta- ‘multimedia \ ‘rome yoctohouse/poky/meta-openembedded/meta- networking \ ‘rome/yoctohouse/poky/meta-openembedded/meta- python \ ‘rome yoctohouse/poky/meta-raspberrypi\ ubcom/ Adjust the paths to sult your local situation. In theory. we should be good to go. Return tothe project. directory and order another BitBake run, Sadly, it wil fail with an extremely odd error message: ‘WARNING: /home/tamhan/yoctohouse/poky/meta- ‘openembedded/meta-oe/recipes-dbs/postgresq/ postgresql 112}bb: Exception during build_ dependencies for PERL ARCHLIB | ETA: 0:00:27 Following the stack trace reveals that BitBake was Unable to satsty a local variable pointing to the Perl distribution. This is a feature which was added to a later version of Yocto; we intentionally downloaded a slightly older version of Yocto. The two layer download commands, however, fetched the most recent versions. from GitHub ~ this turns out to bea problem, as our version of Poky cannot satisfy their demands, Layer mismatches are among the most common problems faced by Yocto engineers. Fortunately, fixing itis not hard, Firs, delete the folders met openembedded 2rd meta-raspberrypi. Next, re-download them while passing a =b parameter: Iyoctohouse/pokys git clone -b thud git//aithub. com/openembedded/meta-openembedded ‘One of the most pressing issues when dealing with embedded software involves licensing the various ‘components. When working with automotive companies, developers should not be surprised if they spend a day or two getting aucited for compliance. Yecto aims to simplify your life by integrating a licence ‘management system into Bitfake, The idea behind itis simple: while sifting through the various recipes. Yocto analyses the declared licence flags. Its configuration contains an additional variable specifying the allowed licences: ia recipe hasa licence which was not \hitelisted, compilation is aborted. Dealing with licensing As ofthis wring the Yocto Sato version of the Raspberry Pi image Includes sucha package - when building the image, an error shows up ERROR: Nothing PROVIDES ‘faad2’ (but /home/_ tamhan/yoctohouse/poky/meta/rcipes-multimedia/ gstreamer/gstreamer1.0-plugins-bad_1.14.4.bb_ DEPENDS on or otherwise requires it) faad2 was skipped: because it has a restricted license not whieisted in LICENSE, FLAGS. WHITELIST For now, sae time by working around the problem Use the folowing command to create a simpler image whch makes do without the GUI stack ~/yoctohouse/poky/rpiHouse$ bitbake core-image- base BiBate contains extensive lope to minimise compilations whenever possible twillreuse most of the packages bul for the GUi-ess version when we return fobulding Sat. While your workstation runs the cross compile process ~ittakes longer, as cross-compilation is computational intensive ~ ls start tracking down the probiem, ‘Our violation was caused by the package faad2, which esices at htp//bt ly x251faad nit we tne the folowing code SUMMARY «An open source MPEG-4 and MPEG2 [AAC decoding brary” HOMEPAGE “http/fwnrwaudiocoding com/faad2. himt” SECTION = "tbs" LICENSE «“GPLI2" LIC FILES. CHKSUM- “fle//COPYING:maS-281eBcbe TTiaTocee22e6083204958" LICENSE FLAGS= “commercial” SSRC_URI-"${SOURCEFORGE MIRRORY/faacifaad2- src/faad2-2.8.0/$(BP}.targz” SRC_URI[md5sum] « "28f6116efdbe9378269186221767 ar SRC_URI[sha256sum] « "985¢3fadb9789d2815eSOf4f17 16511c79e270ac2TabaaatScOC2667161626a" {inherit autotools ib. paclage Inadaition to spectyng were the sourcecode iso. be obtained, we als ind that the LICENSE value i et to commercial. As we cannot change conf ies during 2 comple, wait unt the bul process has run, Whitewashing our problem Should you have closed down te terminal window by mistake start out by reconfiguring the various local Ynables loaded by oe-ini-buc-env. Invoking the command with thename of known bul folder leads to the rerintialsation of the build environment ~/yoctohouse/poky$ source oe-init-build-env tpiHouse Custom embedded images Thorens of ‘#8 Shell environment set up for builds. #88 bldg the Sto You can now run bitbake ’ RspberryP Inthe next step, return to local.conf andl add the image following to permit the use of commercial packages: #tvariable as required. LICENSE_FLAGS WHITELIST="“commercial” Running a compile ofthe larger image in the current state would deplete the storage capacity of our workstation. Fortunately, the image created for QEMU is no longer needed: as we passed no filename to ‘e-nit-build-env, is contents are located in /home/ ‘tamhan/yoctohouse/poky/build/, The contents of the /tmp folder amount to a impressive 28GB: delete them wholesale. As long as the contents of /builel/ conf remains untouched, BitBiake can rebuild the image from scratch (burning CPU hours in the process). This, of course, also assumes that the various GitHub repositories remain available ~ a problem you should keep in mind when working on legally sensitive projects requiring build reproducibilty ‘At this point, order BitBake to run another ‘compilation, The build system will inform you that a few hundred packages were found from the previous run, {and will set about finishing the new image. Look for the file core-image-sato-raspberrypi-rpi-sdimg, rename it to core-Image-sato-raspberrypl.img and burn it toa ‘memory card of choice. When done, Ubuntu wil reveal the folder structure shown in the screenshot above. Sadly, the 64-bit processor of the Raspberry Pill reject the image. Fixing the problems easy: return to local.conf, and adjust the value of the MACHINE variable lke so: MACHINE ?- "raspberrypi” This time, the rebuild will work significantly faster — ‘given that the Raspberry Pi 3 shares most ofthe instruction set with its predecessor, many packages ‘get Ticked at’ without compilation. Going further Getting Sato booted onthe Raspberry Pi but part of the job the distrbution should be used practically. the next stp involves adding ayers containing recipes for the contrel task athana Yocto simplifies this by letting you_teate an ADK. ast of compiler and software Components forthe newly created target. Sadly, we haven't got the space hereto delve into these topics. However, the infrastructure constructed inthis article simplifies further experimentation. We hope that you erjyed the de! Keep track with Status Board Monitor your internet connection, detect who's home and keep track of your finances with this handy Pi add-on The Pi Hu’ latest add-on, the Status Board is simple yet powerful lke the Pl iteef and witha board, you can nonitor anything you want at a glance. The Status Boar has five customisable strips, teach with @ green and red LED. The eptions are almost imitlase. Oo you want tobe able to quickly checkif your home server is onlin? Or perhaps youd prefer to ‘value, such as your whethar your investments have gane up or down? Each strip can be written on with adry- wipe marker, 80 you can keap reassigning them, In this guide, well focus an basic setup of your Status Beard, along with some example seripts coded by LUBD ‘and the fol atthe P Hut. These sample scripts can be Used to check your internet connection is working, ping devices, as wel as check ifyour shares have gone up or ‘down in value, Youll also discover how to customise the crip to your needs and how to design: This tutorial assumes you have a cloan install of Raspberry PS Stretch on your Raspberry Pi. Make sure torun sudo apt-get update and sudo apt-get Upgrade before proceeding, Connect your Pi Status Board Head over to the Pi Hut and purchase the Status Beard for your either your Raspberry Pi or Pi Zoro (nttp//bit.ty/SBoardbuy), Setup is incredibly sims you only need to connect the Status Board giectly to the 6GPI0 pins on the Pi. Disconnect the P's power cable while connecting the board, In order to use the Status Board you'l nee the GPIO Zoro Python library. This shaula 3S but if nat, open a Te apt install. python’-gpiozero he latest be pre-installed in i window and run sudo python-gpiozero ~y. Test Status Board Open a Terminal on your Pi and launch the Python shell by typing pythond. First, import StatusBoard madule by entering from gpiozero import ‘StatusBoard(). This wl as they'l be shorter, StatusBoard. Next, enter sb ‘make it easier to type command Next, switch onal the LEDS on all strips by running sb.0n(). Sitch them off again by typing sb.of FO. Now let's take a look at how to turn on a ingle L instance, toilluminate the green LED on strip three, type: sb.three.Lights.green.on(). Next, ty makinga ight blink: sb. Five. Lights. blinkO, Test naming strips By default, the strips on the ramed ‘one, tv, three’ and ea on, To you can name strips individually in Python, Do this by etining the StatusBoard values; for instance if you're singit to detect motion in rooms in your house, you couldenter:sb = StatusBoard(kitchen’, "lounge "pasement’, ‘study’. youre composing a seript, you Could switch on the red LED forthe ‘study strip withthe command: sb.study.lights.red.on(). rd are oid contusion, ype exit() once you've finished testing Download ping script Ina Teeminal, un get https://rau.githubusercontent.com/nate- rake/pistatusboardsanples/naster/ping.0y critusas the fst two strips on twill show @ linking green light nd checks ris example pin Status Board, The f the Pi can connect to the internet. The sec the IPaddress ofa certain device such as a motile phone work, To start editing, run Is connected to your local n Status Board nano ping py in the Terminal or better yet, open it with ‘Thonny Python IDE to ensure text is formatted correctly. Note thatthe frst two strips ave been named ‘google! and ‘seviee. OB rrr tneunen nach ong "ingServer(‘google.com'). Under the current ‘configuration, the PingServer module will check ifitean ‘connect to http:/igoogle.com every three seconds. (You ‘can change this by amending sleep (3)) Ifthe connaction is euecessful the eerptwilleause the green LEDon the first strip to start blinking, otherwise itl switch of. The advantage of using a domain name here is that PingServer will not only check that your intemt connection is working but that your DNS settings are correct toa, Configure domain settings +4 OB BEBO on = sectoral pe’ OG Sentzure device settings The ping py script also tries to locate a device ‘on tha same network such as a family member's mobil ‘Touse this feature, you need to know the device's IP (the ‘eross-platform, free mobile app Fing is perfect fr this) Find the ine which reads device PngServer("182.168.1.28') and amend 192.168.1.29 to ‘the IP address ofthe device you want to detect. fit can be pinged, the green LED en strip twa lights up, otherwise the reg LED will hoe: Run the serpt from Terminal with python3 ping.py. 0 eget https//ranglthibusereontent.con/nate- Grake/pstatusboordamplesmostr/Finanee py Download finances script, Reopen Terminal and run: “This second Python example script focuses on the third and fourth strips on the Status Board, and uses the yahoo finance module to monitor your financial data, The first part ofthe script chacks whether the value of your shares have gone up or down. The second part checks ‘the current exchange rate fora currency par. Tostart editing, run nano_ping.py in Terminal or better yt. open it with Thonny Python IDE to ensure the text is formatted correct OG centers sere rcs settings Ifyou dabblein the stock market, youl know that shares are identified by a ticker symbol. f you find Fie eV Bu To Hp #55 OB BEBO the line which reads share = Share('AAPL',youtl 00 that by default the script wil check the value of Apple shares. Amend this to the ticker symbol for the shares you hold. youre not sure what thisis, visit httpsi/inance yahoo.com to search for a company. Make sura to amend tha line share_price = 150.53 to the actual dolla value you paid per share originally too OQ Senter curcency settings ‘The script can also check the value of @ currency par Find the line reading eurrency_pair ‘Currency(’BTCUSD), By default the script checks the current value of Bitcoin in USO: however, you can change this to another pairifyou wish, e.g, EURPLN, Whichever currency you choose, make sure to amend theine currency.price = 4087.45 to reflect what you paid for the base currency; @.g, you may have paid 4.2894 ‘euros por Polis zoty. Run the script with python3 finance.py.Itcan run simultaneously with ping.py. 10 further stens We have intentionally not addressed the fifth strip 0 that you canuse it for whatever purpose has popped into your head while reading this. Head over to http bit.ty/SBoardexamples fora few code examples. Tese include a script to check the London tube lines, ‘one for checking the weather and even a program to check for names in the news. Make sure you name your fifth stripin the way outlined above to reflect your chosen purpose. If any rogue LEDS ‘witch on, goto Step 2 and repeat the commands up to sb.off() to turn thom oft. Dear cy + MPU-6050 consiingavens secoermeterandaMeMegyroscope, hiseensorreace them anda¥e \Veroboard verboorsi reat otayupwiresingrctects eth, anerethygtintnewaybuteant really berantvoughabresdboae —————— Raspberry Pi Model B Maplin Robotic Arm Kit With USB PCInterface IELMPU-6050 Six-Axis Gyro and Accelerometer #3 Mini Push Button Switches mVeroboard mYelcrostrap lm imRibbon Cable <<< i q E Robot Arm ssazbietromsapin comestheotaretarcoatoen before yougethe P-S00inohed LeftThisrobatearmisons ofthe most uses ones andere aetonnas of gudea‘orit Below One a these buttons cont thetight fontheendftheebotlearm,whethe cher ‘ogpen and covelta gripper What fist inspired youtobeginyour robot arm project? The robot arm tea was one IS seen years ago and | really wanted ft because it's something you can contol yourself = it really captured my young imagination, | was volunteering ata science museum down hare in Harlow and tie club based around the Respberty Pi sprung up, and | boughtthe robotarm because wanted. SSothen had the Raspberry Pthing going conatthe same time and thought, Why not meld thetwo? | had this complicated system of key preaoes to get it to do anything, which was a bit boring, and then James Dal lone of the people who helps out with the club) gave me the idea of shoving an accelorometeron the top oft to gh an ida of whore ts. teokthatand thought, "What if Thad the aecelerometar on me and sort of used to merr the mation of mm hand?" So looked around, searched Up the accelerometer he was using tthe 'MBU-6050) and then found it for about £50 eBay — i's normally about £30 from ‘SparkFun but Tm on a student budget. ‘Alot of the code Ive used ie borrowed but open source, and people have sald It's fie, so then | went through and had ‘two programs ~ one that could contol the azr, one that took the inp in from ‘the accolerometer ~ and kind of just smushed them together It's not that nice ‘olook at, butt works and thats all that realy matters Sowhatexactlyareyoureading with ‘hat MPU-6050? There's the gyroscope and the aceeleremeter in the code I found ~ you can use one of tho other, but the yroscope is very good for degrees ‘over time and it tends to dfft, while the accelerometer is good for sudden turns and for measuring gravity, If you compare the two to each other then you can get a rough angle al ofthe time, 80 its essentially the accelerometer and the gyroscope used together to correct ‘the faults with one or the other. t's got ‘woaxes of motion - pitch and ol How | made: How | made: robot arm Robot Arm Get to grips with natural motion control Takeusthrough thecodeitselt So in the frst bt it finds where the actuall2Cintorfaceisandthere'saquick setup ~ Ive got three buttons on there to control the gripper and the lights, 30 Itsets those up ~ and then there's abit wich using the USB library tofind the robot arm, then spitting tout if that’s an issue. There are a couple of definitions for some functions to actually move the arm, gots atte bt easier ~ each motor direction is a. cifferent binary umber — and then there are more Gefinitons for setting up reading data from the accelerometer and a bit of maths for making sure the gyro and the accelerometer are both giving the correct angle. Then there's this while loop with a try inside that just pulling the accelerometer for data, spitting out the maths stuf , bofore just checking that the angle given is within @ certain range. If ts, move this motor lft (for example} ori a button is pressed then ittums alight on. The only problem Ive had with itis that to actualy move it, requires a change in ange ~ so there's notacontinuous thing, Ihave towave my hand lite bi, but there's that agree angiandif trp ithen ttt move around Haveyouconsideredaddingany more formsofcontrol? Yeah, te done a lot of research nto thi Intermsof other waye tocontroit, quite Uke the intutiveness of It ~ to rotate land move this arm you are moving your ‘wn arm, 80 that's something Ive boon focussing on and trying to get even more intuitive. Trying to get some sort of ~ | bought an Arduino at some point - trying ‘0 build an actual robotic han and then spreading out from there. Eventually, iy big plan ~ many, many years in the futuro~istohave an enti sort ofhuman body thats controled by the movements of the user, but that's a very large plan Which 1 haven't put t00 much into just yet! But essential, the prototype that people have done before is sortof having ot sensors — potentiometers - on the fingers just to measure the actual rotation and closing of the fist, then having that represented with servos and then possibly doing that with actual pieces of string to sort of emulate the tendons, Soyau'shaveasinglesorvo,ora couple af servos, nan arm bit that would pull string which would close each fingor inten Another ides, which seems to be fone of the most viable, is having it Completely brain controlled... Ther 2 fair amount of interest in reading brain activity ~ you can do it with the NouroSty, for example. Theres quite a rice open source project which | might ‘end up using because it has four inputs, ‘0 yoU can measure atleast two things ‘at once and that seems to be a fairly interesting place to go. It’s expensive ‘though, and if you're going open source then they have alot of warnings on the ‘websites saying that you do thi at your ‘ow risk, this is not a medical product, you may fryyour brain, Whatisthenextstep then? Further projects would probably be replacing the motors. Because i's motor-driven, i's. timing-based, so having something with servos instead where | can have a definite angle would be lot more useful, alot more precise land wouldn't tend to go.. one of the probloms with itis that i you tol it to keep going in one direction, i will keep going in one direction whethor it wants {oor not, and there's this awful grinding of geare as it attempts to go in one direction and can’. So that will probably be anew arm, a new robot, trying to get itto.bea bit more nice-looking and abit more precise. Another idea is having the arm be completely brain controlled Joseph. Thomas isasudontheting toninafaspbery ‘Abfromasciencs Imueeumin ron ‘heretoy have verte onpreets ‘anette Like it? Therobatarm that Josephs usingean bevousnt tom Mapinein he uk toey/toag6| crorteredtom Aiatrtetsewnere inthe ora ‘wynt00e. Tree Sremany gules Sntneto get you up srndrunning such sathigone Bityranso0U. Further reading NouroSny asa hae product. ‘amiyGeceated toeEbandEOG Biosensors, Inetuing he Popular tanawave Fekcsotsneurosiy com andthere Sreatew hacks Seataie toot. iyncrwose. Speen Burgeoringopen soutoeprojet ‘Seoteatedt brain ompaterinerfoces iopentecom Remotely control your Raspberry Pi Use a web interface to control your Pi and employ it as a fileserver or media centre from a remote location using any web-connected device. Uptime 26 Processor cruName ‘Bogemts Comer speed) Overclocked speed (ts Top CPU processes systam_nfosh PO: 2619-70% ‘plgd MO:2417 02% org PO. 2051-02% Memory usage = eed 61.08 a (16%) Disk usage es Total HOO space 35.68 ied 27668(70%) Fre S79290B(10%) me ot e1yon2 008 the Raspbery Pi What you'll need lie Sue svn os sn Raspberry PIOS set to ‘command line portabilty, it can be located almost fanyubere that i can be powered and 1S widely used as a filo sorver, mada mRaspCTL centre and for other nontvadonal internet connection appitcat easy u well, Some ofthese use ‘alow access toa manstr fo tes and maintenance, While you can always SSH in its abit slower than a full we intecface that allows for custom commands an a view ofthe Ps performance, Were usingsoftware called RaspCTL which is stil in development, butnerke just finefor now. Commands crestecustam ‘commands forrunning your Rpt Ph | Other utilities sesngtrournyour snandsetnganalam art no ivoral ingsyoucandewitnyourP | ‘Main window cctinesutaetaisot ‘thecurentyruningsystamfrom thee Update your Pit Te make aura tha Rasebercy works as best tan, youl need to update PiOS,Dothiswtha sido apt-get update 8 apt-get upgrade, followed by a firmware update with sudo rpi-update, Final, if youre booting to LXDE, enter raspi- configanc change ttoboat to command linet save power Remotely control your Raspberry Pi Eaitthe iP Raspberry Fitoha networking conf work more easly you should a staticIPof yaur choice. Todo this, eit the using Is sudo nano /ote/etwork/iterfaces and changeifaceth0 inet dheptoface othDinet static SetupastaticIP Add the folowing lines under the face Line with you levantdetalls address 192.168.1.F) netmask 255.255.255.0 network 192.168.1.0 broadeast 192.168.1.255 gateway 192,168.1.(Router TP] Readyto install ul need to grab the public hays forthe software ngto install by usingthe flowing commands. The first wil take just a moment to download the software, while the ther quichy installs $ wget debrepo.krenel.org/raspetl.ase S cat raspetl.asc | sudo apt-key add ~ ‘Add the repositoryand install Add the repository t the source's file with the following command: Is echo “deb http: /debrepo.krenel.ore/ raspeth main” | sudo tee /etc/opt/sources.list.d/raspctl list and finally install the softwarewith S sudo apt-get update $ sudo apt-get install raspctl Please sign in ‘Access your Raspberry Pi Now the software is installed you can start to access your Raspberry frm anywhere on your network. Te do this 'ypethefollowinginto your adress bar, withthe Pbsingtheone Tieeec3-986 Change your password ‘The default username and password is admin for both fields, and you should make aura to change that before doing anything ese. Goto Configuration along the top bar and find the Authentication fild at the bottom of tha page, Input the ariginal password (admin), followed by your new passwords ha useenamewillremainasadmin, First command Go to Commands on the top bar to begin creating ammands to run, Here youll need to add @ defined way tofiter your com raft the way it’s cun ~ a name forthe command and the actual command itslt. The commands wer’: noessarly un from the gi usar unlessyou tweak the confgfles sands that More functions The web interface has afew extra functions apart from runsingcommands, suchas the ability to view the webcam and connect to radio services, Updating the software every soften wil also allow you to make sure it keeps working. Pay around withitand sa what best its you, Build your own streaming stick No Chromecast? One solution is to use a mobile app and Raspberry Pi to cast media across your network. Christian Cawley shows how it’s done Christian has sent the past 15 years teling people howto do the sare computing tasks but stil has noidea how cars work QUICK TIP Isyoor streamed video too quiet? You canboost the volume from the Advanced ‘options screen. Look for Audio volume offset and increase thevalue ‘nerementally ‘nti’ loud ‘enough, Camtinea simple sideshow us wether inferaton tol sndmada casing totum your Pinta a Chromecat th = Google Chromecastis a great way to get media from your phone to your TV. Unfortunately t's not ideal in ‘some cases. For example, certain routers such as the Virgin SuperFiub 3 won't work out ofthe box witha fist Beneration Chromecast, Meanwhile, the Chromecast is lew spec and limited in many ways. Fortunately, the Raspberry Pis ready to come to the rescue, providing a Chromecest-lke experience when paired with a dedicated mobile app. With a just few terminal commands, you can configure the Raspberry Pito accept video, music, and audio content streamed from your Android phone or tablet, and dress it up with, aslickhome sereen, ‘While this should work with any of the main Raspberry Pi models, we used a Raspberry Pi3 B+, which delivered fast, stable streaming of high-definition Video from the Android handset, Streaming video, not apps It's important to emphasise that the Raspberry Pi plus. Raspicst setup sta complet replacement forthe Cchromecast. For example, there's no VR support or Google Home; there's no ambient mode. although its tency enough to configure asirilar home scree, which weil also look at below. Inshort media streaming is replicated, Everything else youl need to add yourself, rely on existing streaming options. or cuietyoverook Enable SSH Start by ensuring the Raspberry Plis connected toa display. and you have a mouse and keyboard attached. I ths isn't possible, you'l need to set this up remotely controling your Raspberry Pi over SSH. RINE era] Todo this, you'll need to activate SSH on the Raspberry P If this isnt aready enabled, you have two ‘options. The firsts to connect a keyboard, open the Raspberry Pi Configuration tool inthe Preferences submenu on the desktop, click Interfaces and select SSH, clicking OK to confirm. Areboot may be required. ‘The second option isto insert your powered -down Raspberry Pi's microSD card into your computer, browse to the /boat/ directory, and create an empty text file called ssh, with no file extension. Eject the card, replace in the Raspberry Pi and reboot: SSH will be ‘enabled, ready for remote access. Note that you'll need to know your Raspberry P's hostname or IP address for ‘SSH access, You'l find the hostname by entering that word as a command. To see the IP address, either check your router's admin sereen or enter ifeonfig Look for an entry for ethO (Ethernet) or wifi (wireless), and youl find the IP address labelled inet. Fruit upgrade It'stime to update your Raspberry Pi. We'e assuming you're using the latest version of Raspberry Pi OS for this, although other Pcstros should work ine. Open the Terminal (or connect va SSH) and enter sudo apt-get update suudoaptget upgrade ‘With your P's repostories refeshed and any upgrades downloaded t's time to stall some prerequisite packages: ‘sido apt ge instal libjpeg?-dev ibpngl2-dev Two graphics base packages are installed here libjpeg9-dev and libpngl2-dev. These enable JPEG and PNG images tobe streamed from your Android device to your Raspberry Pi. an displayed on your TV. Streaming to the (Open)Max Aso required is Open described by its developer as ‘GPU accelerated image viewer forthe Raspberry Pi Italo includes graphic branes for GIF and EMP images. Get Opentaxby cloning the Gitub directory: ‘itclone https//ithub.com/HaatigerHaralé/omaiv Once downloaded, change directory atone Next, use the make command to bull the software. make ielient make Chromecast: Build your own streaming stick wn ‘A Chromecast deve isice enough butts moresstishingto cai your Rspery to do the sare jb. You! need to wait a while for this to complete. This is ‘2 good time to install the Raspicast mobile app. as per ‘the boxout (below right. Once the tools ready to install se ‘sudo make install \Wait while this completes before proceeding, ‘ith everything ready to roll on your computer, and ‘the Raspicast app installed on your phone its almost ‘time to start casting. First, open the app and tap the ‘menu tofind the SSH settings. Here, input the hostname or IP address of your Raspberry Pi.You'l also need to add the username and password. Click OK and prepare to start streaming media from your phone, “Two options are available: streaming content stored ‘on your phone from within the app, or by sharing the content from another app. To stream from Raspicast, ‘tap the Cast button, and browse the media on your phone. Select the one you want to view, tap the Play button, and your Raspberry Pi will display the content ‘on your TV. For sharing (perhaps from YouTube), simply cue a video or song, tap the share button, and select Raspicast You'll spot two options: one to play immediate, and one to queue the clip to play later ‘As versatile as ever, the Raspberry Pi makes a great Chromecast replacement. Raspicast isnt the only ‘method to achieve this, however. Ifyou have Kodi installed on your Raspberry Pi, several remote apps for the media centre, including the official option Kare offer casting from your mobile, This fs useful, because Raspicast won't work on Raspberry Pi-based Kodi systems anyway. Take me home You might have a Raspberry Pi that receives media, Chromecast-style, from your Android device, but i doesnt quite look the part. Chromecast has a slideshow of curated images for you to enjoy, for example, along, with weather, and date and time information, ‘Want to make your Pi more like Chromecast? You need a kiosk app ~ one that enables custorn images to be displayed as a slideshow. Many of these are available, but the simplest to set up is Andrew Delph's Python slideshow with time and weather which ison GitHub, Get started by adjusting the Raspberry P's video ‘memory. Open the configuration too! with ‘sudo raspi-contig Next, browse to Advanced Options>Memnory Spit Here, change the value to 256, This ensures that the P's GPU has enough available memory to handle the slideshow images, Click OK to continue, then follow the instruction to reboot. Upon restarting, open a new terminal window and clone the slideshow files from GitHub: dit clone https//github.com/andrewdelph/python- slideshow-with-time-and-weathersgit, Once this is downloaded, rename the directory toa snappier title, such as pyss with the mv command. ‘sudo mv python-slideshow-with-time-and-weather Youll aso need the pyowmtool. This isa wrapper for the OpenWeatherMap, which brings the necessary weather data onto your Raspberry P's desktop: pip install pyowm ‘Some additional configuration is required to get this to work. First, youll need to remove some images. Open the pyss directory first and remove the four JPG files starting WIN_20160220, Next, edit the ss.py file sudonanosepy Here, look for the line that reads ‘observation = owm.weather_at_place(‘Ottawa,CA’) Change the city and country tomatch your awn location, For example, a Londoner might use ‘observation = owm.weather_at_place(‘London, UK") Press Ctrl+X to save and exit. Inthe terminal launch the slideshow: python sspy ‘Agallery of stunning images, the date and time, and current weather will be displayed on your Raspberry Pi Chromecast replacement! >> INSTALLING RASPICAST ‘To cast to your Raspberry Pi from your Android phone or tablet (a (lal Phen or Pad aerate exe oes) you ned Raspes rom the Google Ply toe Once tale al permis grt rsre your phon adhe aspheryPare Comte tothe sare network Yuet ine spect stern inter our pone oa Rssbery oher Wihinte app ye id standard cont (yas, ad top tibrewee Guten rd sme epons tv cares ow Rasps crears your cote Torr dd ovat to reply the cura le, opa the rene recto Reps oe Meanie apa catpt to Cra he au tensin the caert way. Fo eo, tls cay bea the HOM pt Bt you mht rete sind ply on ur Al dele (oa) er evn veg oth Vaca asetae AL Shenton poo the fiewaudo rene PETS AN port Seal aed ols can asaberaund Usetnensverces I pts sents cones these wichnelide he ity to chang th decal of noc cco a HO SDanderenaulo or) Youcan asus the econo chong the Rapesstapps Roxx thae st aplyit toy, cone the spose sities anderen tate dy tropa iskn isi onaleanow mages panacea ere eee oor >. Raspicast

You might also like