YOUR OFFICIAL RASPBERRY PI MAGAZINE The official Raspberry Pi magazine Issue 47 July 2016 raspberrypi.org/magpi BLUETOOTH AMAZING TAGGING OPTICAL Automate just ILLUSIONS about anything Master persistence with a Pi 3 of vision with Pi Zero LEARN TO CODE IN C TERRAFORM MINECRAFT Our latest expert series starts this issue Another amazing Minecraft Pi hack MISSION ACCOMPLISHED Celebrating Tim Peake & Raspberry Pi’s amazing space mission Also inside: PET PROJECTS! > SKYCADEMY: TAKE YOUR PI TO THE EDGE OF SPACE > START BUILDING A PI-POWERED ARCADE MACHINE 10 fantastic > THE ULTIMATE RASPBERRY PI KARAOKE PROJECT Issue 47 • Jul 2016 • £5.99 Pi-powered makes > THE MOTOZERO ROBOT BOARD REVIEWED for your furry friends 07 THE ONLY PI MAGAZINE WRITTEN BY THE RASPBERRY PI COMMUNITY 9 772051 998001 Welcome WELCOME TO THE OFFICIAL PI MAGAZINE! n December last year, British Army I Air Corps officer Timothy Nigel Peake stepped aboard the Soyuz TMA-19M to start a six-month mission aboard the International Space Station. It was a small step across the ISS hatch for Tim, but as the first British European Space Agency astronaut it was a giant leap for the United Kingdom and especially the children that dream of one day going to space. Tim wasn’t the only UK-born passenger aboard SEE PAGE 30 FOR DETAILS the ISS, though; two Raspberry Pis joined him on his mission to carry out experiments developed by British schoolchildren. While Tim returned to Earth on 18 June, our two intrepid Raspberry THIS MONTH: Pis, Ed and Izzy, remain aboard to continue their ongoing mission to inspire and educate children 14 ASTRO PI: MISSION ACCOMPLISHED all over the world via the Astro Pi programme. We look at this amazing collaboration, but it’s not over yet! You can learn all about Astro Pi in our massive cover feature starting on page 14, and how Astro 32 THE ULTIMATE RETRO PHONE Pi and other educational programmes Tim has Martin Mander is back with another stunning Pi project been involved with have touched the lives of and inspired more than a million schoolchildren. 46 TERRAFORM MINECRAFT Enjoy the issue! Become the destroyer of worlds in Minecraft Pi Russell Barnes 72 YOUR PET PROJECTS Managing Editor 10 amazing community creations for your furry friends FIND US ONLINE raspberrypi.org/magpi GET IN TOUCH [email protected] EDITORIAL DESIGN PUBLISHING Managing Editor: Russell Barnes Critical Media: criticalmedia.co.uk For advertising & licensing: [email protected] Head of Design: Dougal Matthews [email protected] +44 (0)7904 766523 Features Editor: Rob Zwetsloot Designers: Lee Allen, Mike Kay Publisher: Liz Upton Sub Editors: Laura Clay, Phil King, Lorna Lynch Cover photography: Gareth Halfacree CEO: Eben Upton DISTRIBUTION SUBSCRIPTIONS CONTRIBUTORS Seymour Distribution Ltd Select Publisher Services Ltd Sam Aaron, Dan Aldred, Wesley Archer, Mike Cook, 2 East Poultry Ave PO Box 6337 Lucy Hattersley, Richard Hayler, Phil King, London Bournemouth Simon Long, Alan McCullagh, Matt Richardson & EC1A 9PT | +44 (0)207 429 4000 BH1 9EH | +44 (0)1202 586 848 Richard Smedley, Lucy Rogers & Francesco Vannini This magazine is printed on paper sourced from The MagPi magazine is published by Raspberry Pi (Trading) Ltd., 30 Station Road, Cambridge, CB1 2JH. The publisher, sustainable forests and the printer operates an editor and contributors accept no responsibility in respect of any omissions or errors relating to goods, products or services environmental management system which has referred to or advertised in the magazine. Except where otherwise noted, content in this magazine is licensed under a been assessed as conforming to ISO 14001. Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0). ISSN: 2051-9982. rraassppbbeerrrryyppii..oorrgg//mmaaggppii AJpurlyil 22001166 33 Contents Issue 47 July 2016 raspberrypi.org/magpi TUTORIALS COVER FEATURE > PI 3 BLUETOOTH TAG 42 Create automated events with a Pi and a smartphone > WAKE DINO WITH NODE-RED 44 Email a dinosaur to let people know dinner is ready > MINECRAFT TERRAFORMING 46 Program Minecraft to change its landscape > EGG DROP GAME 48 Make a Sense HAT game that uses the tilt sensor > SONIC PI 50 Create randomised drum patterns with Sonic Pi’s creator > PI BAKERY 52 14 Build yet another amazing machine with Mike Cook > ARCADE MACHINE BUILD (PT 1) 58 ASTRO PI Start building your own arcade cabinet from scratch > PERSISTENCE OF VISION 60 Tim Peake has returned to Earth; let’s see what he accomplished with Astro Pi Create an optical illusion with a fast-spinning Pi Zero > RASPBERRY BERET 64 PI WARS 3 CoderDojo Put a camera on your head in this Pi-powered Prince tribute Young people show off their projects at the Coolest Projects IN THE NEWS awards in Dublin 9 6 Pis in the sky Pi Wars returns in 2017 to give 10 Everyone’s talking about Raspberry Pi in the sky. people more time to make even Skycademy returns as records are broken with HABs cooler Pi-powered robots 4 July 2016 raspberrypi.org/magpi Contents THE BIG FEATURE In association with 72 95 RASPBERRY PI SALES THE BEST PI PET PROJECTS Cute critters and the Raspberry Pis that people use to control 8 An amazing 500,000 Raspberry Pis were them or make them famous on the internet sold in a single month YOUR PROJECTS REGULARS 32 >NEWS 06 The biggest stories from the world of Raspberry Pi >TECHNICAL FAQ 70 Got a problem? Maybe we can help... >BOOK REVIEWS 86 The best reads for coders and hackers >THE FINAL WORD 97 More musings from Raspberry Pi’s Matt Richardson COMMUNITY ALEXAPHONE >THIS MONTH IN PI 88 We round up other goings-on in the Pi community This very Seventies telephone has been souped up with a Raspberry Pi >EVENTS 90 Get involved in a community gathering near you Karaoke Box 34 >YOUR LETTERS 92 A tiny karaoke box that lets you belt out Talk to us about the magazine or Raspberry Pi your favourite pop song at full volume Beekeeping Server 36 REVIEWS Raspberry Pis that bring you honey, although there are some bees involved >MOTOZERO 80 >PI ZERO MOTOR SHIM 82 Bitcoin Clock 38 A clock that keeps track of Bitcoin stats >RASPIO HAT 83 and can store some money in it as well >CHICKBOT 84 raspberrypi.org/magpi July 2016 5 News FEATURE The balloon reached almost halfway to the edge of space, and only a few metres short of the 42km prediction HIGH- FLYING PI Everyone has been talking about high-altitude ballooning this month; here’s why… f you’ve paid attention to you don’t want pictures, then a I high-altitude ballooning smaller/lighter/simpler AVR or (HAB) within the Raspberry PIC microcontroller will easily Pi community, you’ll have no doubt do the job, and with less battery heard of Dave Akerman. He’s power. I felt that the CSI-less Pi broken records thanks to Pis in Zero was a missed opportunity. HABs, specifically ones involving Eben agreed, and said he would the highest altitude amateur live- try to make it happen.” transmitted pictures. It’s very New records specialised, but still spectacular. It probably comes as no surprise, On launch day, Dave had to wait then, to learn that he’s broken the for the weather to clear before record once again, this time thanks filling up the balloon, contending to the recently released upgrade with some unexpected gusts of to the Raspberry Pi Zero. The new wind in the process. The predicted camera port is a big deal when altitude for the payload before the you’re doing something like this. balloon burst was 42km (26 miles), “I’d been pleading with which is about double the altitude Eben [Upton] since I first saw a of the U-2 spy plane. Predictions prototype of the original Pi Zero. weren’t far off; the last photo Its low weight would be ideal for sent from the camera before the live-imaging HAB applications, balloon burst records an altitude if only it had a camera port,” of 41,837m. Dave believes this Dave writes on the Raspberry Pi breaks any previous record he’s A basic case with the bare essentials needed to make things blog. “The camera is the entire made, and any others that have work, which is important when you’re trying to save weight reason for using a Pi for HAB; if been made since. SKYCADEMY 2016 Last year, Skycademy helped teachers around the UK to learn about performing HAB experiments in their schools. It was a huge success, so the Raspberry Pi Foundation is launching a new Skycademy course. The course will take place over three days, with the second day dedicated to launching and tracking a HAB. You can find out more information, and apply, online: magpi.cc/28J5Vma 6 July 2016 raspberrypi.org/magpi News HIGH-FLYING PI A glimpse of Earth from space as Sam’s SkiPi reaches DAVE’S FLIGHTS high into the atmosphere Pi in the Sky The reason we didn’t name this news story ‘Pi in the Sky’! Dave Akerman came to the community’s attention when he originally broke that altitude record, using a Pi and a webcam, in July 2012. The Pi Camera Module went as other members. Completing missing as the balloon burst, so his research, Sam built his if you have a very thorough search SkiPi on the provided budget, around Shropshire, you might just using the skills in electronics find the highest-flying Pi camera and programming that he had ever/so far. developed for the task. After two months of work, Sam A boy and his Pi took his payload and balloon to a While Dave might be breaking field and filled it up with helium more records, a 17-year-old for its ascent over Monmouth. student from Monmouth School, Dave even came down to spectate Sam Sully, was taking his first and give a hand if needed. Babbage’s big jump steps into Pi-powered ballooning “I programmed the camera to You may remember Felix Baumgartner, who managed with his own HAB project. After take a picture every minute,” Sam to fall with so much style he broke the sound barrier. seeing Dave’s original Pi in the Sky says. “These were stored on the Pi Dave tried to recreate this feat at a greater altitude, blog in 2012, Sam was eager to give Zero. Then the Pi selected the best but with a Babbage bear as a passenger. it a go, but didn’t have the skills to photos and transmitted them back do so at the time. to us. But my focus was on making “Now, four years later, I’ve sure I couldn’t lose it.” gained many more skills,” Sam The balloon reached a very tells us. “Last year I received respectable altitude of 32km an Arkwright Scholarship, in about an hour, before falling giving me £300 to spend on back down to Earth. It took some anything to further my interests finding, but Sam managed to in engineering and computer retrieve the payload and the rest science. I decided after a while of the photos. that I could now do this project, “The pictures are beautiful,” and so I started my research.” effuses Sam. “I’ve already shared His research brought him to them with people and set one the forums of the Raspberry Pi as my desktop background. Heston Blumenthal’s potato Foundation and to members of It’s an amazing view from up As part of top chef Heston Blumenthal’s Great British the UK High Altitude Society there. People have reacted with Food episode on pies, Dave launched a Heston-esque (UKHAS), where unsurprisingly amazement: they are really potato from a HAB. The potato survived its descent, he bumped into Dave as well impressed that it actually worked.” but not Heston’s plans to mash it up for dinner. raspberrypi.org/magpi JJuullyy 22001166 77 News FEATURE RASPBERRY PI 3 SELLS 500K IN FIRST MONTH Biggest monthly sales of Raspberry Pi ever, following the Pi 3 launch hen the Raspberry Pi 3 achieved in four years, with the W RECORD TO BEAT was launched in February, vast majority of these Raspberry Pis one of the topics that was built in the UK as well. The eight million number for discussed at the press conferences It seems the talk of sales during the Raspberry Pi was a big was that the Raspberry Pi had the launch of a new product didn’t milestone, confirming that the reached eight million sales. jinx anything, as the Raspberry Raspberry Pi was the bestselling This makes it the bestselling Pi 3 went on to sell almost 500,000 Below 2,000 of British computer ever. The the original batch British computer of all time, units in March; the previous record next record to beat is the of Raspberry overtaking the Amstrad PCW line was in March of last year, which Pis as they were Commodore 64, which has sold delivered in 2012 of computers. All of this has been saw the release of the Raspberry anywhere between 12 million Pi 2. Looking at combined sales and 17 million units, depending of all Pi models in March 2016, it on what data you believe. Actual was the bestselling month for the sales data seems to suggest SoC computer in its history. You the 12 million number, whereas may remember that it took about Commodore itself used to a year for the Raspberry Pi to sell insist that the C64 sold 400,000 a million units, so this shows the units a month consistently increased reach the Raspberry Pi for a few years. and its educational mission has achieved in the last three years. With the possibility of different models of the Pi 3 coming out, it will be interesting to see how these exponential increases in sales affect the Raspberry Pi. MILESTONES JAN OCT FEB 1 MILLION 2 MILLION SALES 5 MILLION SALES 2013 2013 2015 SALES AND A MOVE TO THE UK AND A RECORD The Raspberry With news that Premier Farnell Nine months after breaking Near the Raspberry Pi’s third Pi has been had sold 500,000 Raspberry Pis the million mark, the birthday, the Foundation received selling ever itself, estimates for sales from Raspberry Pi hit two million figures that confirmed the faster since RS Components suggested that a sales in the last week of Raspberry Pi had sold five million its release million had been sold in all, which October. 1.25 million of these units, becoming the fastest-selling was confirmed later. With the Pis had been made in the UK British computer of all time. From Raspberry Pi only launching in at this point, eclipsing the a million in one year to four million February of the previous year, it overseas production of the over two years: the sales have was an impressive achievement. original run. been impressive. 88 JJuullyy 22001166 rraassppbbeerrrryyppii..oorrgg//mmaaggppii News PI WARS RETURNS! PI WARS RETURNS! The popular robot rumble is confirmed for another outing, but you’ll have to wait until 2017 he past two Decembers instead of doing robot building T have borne witness to during curriculum time (how naive tremendous robotic was that?!), they were doing it in competitions of skill and power after-school clubs, and September as part of the CamJam’s Pi to December didn’t give them Wars. Mighty robots built by the enough time. So, we hoped that community proved their worth we’d get more schools interested through gruelling challenges such by giving them more time. We’ve as following lines, bowling, and so far had over 80 teams register stopping at the right time. It’s their interest in competing and a huge amount of fun for those about a third are schools, so it competing and spectating, so it’s would appear that the change no surprise that a new Pi Wars has of date has been successful – been announced. at least it has to the extent that Missing its usual December slot, there’s interest!” Pi Wars 3 will be taking place on You can register your interest by Saturday 1 April 2017. This change heading to the Pi Wars site here: of date has been made for a very magpi.cc/25UHMEp. With new good reason, though. challenges such as the Minimal “We decided to move it a few Maze, Pi Noon, and Slightly months to allow more schools to be Deranged Golf, it should be a lot able to compete,” Michael Horne, of fun. Check out our motor board co-organiser of the CamJams and reviews this issue if you’re looking Pi Wars, tells us. “We found that for some inspiration. PREVIOUS CHALLENGES Here’s some of the things the robots had to do in Pi Wars 2 ROBOT DUEL OBSTACLE COURSE STRAIGHT-LINE SPEED TEST Taking a page out of Mario Kart’s A classic test of manoeuvrability and Your robot’s gotta go fast in this book, these Pi-powered robots skill as the robots needed to navigate speed challenge, testing out all its duelled to the pop in this non- a testing obstacle course, including power in a sprint to the finish. More destructive battle to see which was the giant rotating platform created motors and wheels and a bigger the victor. The full details were kept by PiBorg. It was more fearsome than chassis mean a heavier robot, secret until the day. it sounds. though, so build wisely. raspberrypi.org/magpi July 2016 9 News FEATURE SEE CODERDOJO’S COOLEST PROJECTS This Pi-vision system was designed to help blind Young people convene in Dublin people, using an ultrasonic distance sensor to show off their best projects n Saturday 18 June 2016, impressed by both the projects and O Raspberry Pi Foundation their presentation.” CEO Philip Colligan and There were a lot of Raspberry community manager Ben Nuttall Pi projects on display, including headed to Dublin for the CoderDojo websites, Sonic Pi demos, robots, Coolest Projects awards. Here, and even an arcade machine: loads of young people gathered to “We arrived at a beautiful Pi- show off their excellent projects powered retro gaming console and for everyone to see. Philip gave a spoke to the maker’s dad. He was Pi-based presentation to start the excited for his son to be able to morning, and then it was time to show his project to people from A bigger see the displays. the Raspberry Pi Foundation, and arcade cabinet than “As we walked around the asked if we could stick around most people venue, we grew more and more to wait for him to return.” Ben make with a Pi, you can impressed by the projects on requested Mega Drive classic just see a show,” Ben mentions in his blog Golden Axe, which was quickly cheeky Pi sticker above about the event. “We asked each loaded up for him to play. On this the screen exhibiting group to talk us through page are some of the amazing their project, and were genuinely projects that Philip and Ben found. Where there are Raspberry Pis, you’re sure to find robots. This one is controlled Using mirrors and good code, a group managed to make a 3D with a Wiimote experience in Minecraft Pi, with Sonic Pi linked up to it as well 10 July 2016 raspberrypi.org/magpi
Description: