Tag Archive for Python

The Official Raspberry Pi Beginner’s Guide

The Official Raspberry Pi Beginner's GuideToday sees the release of The Official Raspberry Pi Beginner’s Guide, my latest educational book on the remarkable single-board computer and its software and the first to be made available for free download and redistribution courtesy of a Creative Commons Attribition-ShareAlike-NoCommercial licence.

Written in partnership with Raspberry Pi Press, The Official Raspberry Pi Beginner’s Guide walks newcomers through a tour of the Raspberry Pi and what it can do, setting up both the hardware and the software, learning how to navigate the Raspbian desktop, how to write programs in Scratch 2 and Python 3, and even building custom circuits that use the Raspberry Pi’s general-purpose input-output (GPIO) header. If that weren’t enough, there are chapters on using the Sense HAT add-on board, the Raspberry Pi Camera Module, and a handy list of additional resources for when you’ve finally exhausted the book itself.

While it’s my name on the cover, this book is very much a team effort. I’d like to thank everyone at Raspberry Pi Press who was involved in its creation, from the authors of the original projects pulled in and updated in this new publication to eternally-patient project editor Phil King, fantastic technical editor Simon Long, amazing illustrator Sam Alder, and a whole host of others without whom the book would be nowhere near as good as it has turned out.

The book is available to buy now in all good newsagents, supermarkets, and bookstores, or direct from Raspberry Pi Press. The digital edition, as a Creative Commons-licensed PDF without any digital rights management (DRM) restrictions, is available from The MagPi website now.

Benchmarking the Raspberry Pi 3 Model A+

Back in March, the release of the Raspberry Pi 3 Model B+—the Pi 3 B+ to its friends—brought a chance to take stock and review just how far the project had come since its launch via a series of benchmarks. Now the launch of the Raspberry Pi 3 Model A+ brings a bold claim: a dramatic drop in size, weight, and price over the Pi 3 B+, but without any loss in performance.

In other words: it’s benchmark time once again.

Read more

Custom PC, Issue 166

Custom PC Issue 166Readers of my regular Hobby Tech column this month will find a BBC micro:bit-driven tutorial alongside two reviews covering the remarkable Raspberry Pi Zero W microcomputer and the fascinating Delete by Paul Atkinson.

The idea for the tutorial came about while working on a chapter of my upcoming Micro:bit User Guide, and seemed like a perfect fit for the readers of Custom PC Magazine: turning the low-cost yet extremely flexible micro:bit into an addressable USB-connected 5×5 LED matrix and having it display current CPU load in a constantly-updating bar graph. Naturally, the same technique could be used to graph almost anything.

The secret lies in MicroPython’s REPL, an interactive interpreter which can run on the micro:bit and accept commands via the USB serial port. By switching the micro:bit into REPL mode, it can be slaved to another system over USB. The result: the entire program code, written in Python using the serial, time, and psutil libraries, exists purely on the host machine. A quick bit of Blu-tack later, and my monitor was wearing a CPU monitor which worked even when the display was off.

The Pi Zero W, meanwhile, was a device to which I had been looking forward for quite some time. An upgraded version of the original £5 Raspberry Pi Zero microcomputer, the Pi Zero W differs in only one respect: it has a built-in radio module, the same BCM43438 as found on the far larger and more expensive Raspberry Pi 3.

While the addition of the radio module, which offers Bluetooth, Bluetooth Low Energy, and 2.4GHz Wi-FI connectivity, almost doubles the price of the Pi Zero W to £9.60, it’s money well spent. In almost every Pi Zero project I have built, I’ve ended up using a USB OTG adaptor and low-cost USB Wi-Fi dongle to add network connectivity, and having it on-board – even at a slightly higher cost compared to a USB-connected solution – makes life considerably easier.

Finally, Delete. Billed as “a design history of computer vapourware,” Paul Atkinson’s coffee table book is packed with high-quality photographs – and, for the rarer machines, the occasional rescaled JPEG exhibiting unfortunate compression artefacts – covering machines from an upgraded Sinclair QL to a bright yellow IBM that never left the drawing board. Each comes with pages on its history, with interview subjects detailing features and failures alike, and while not all machines were strictly vapourware few are likely to have a place in the average vintage computing collection. In short: if you like old computers you’ll like Delete, which is available now from Amazon and other bookstores under ISBN 978-0857853479.

As always, you can read the whole column and a whole lot more by picking up Custom PC Issue 166 from your nearest supermarket, newsagent, or electronically via Zinio and similar services.

Custom PC, Issue 165

Custom PC Issue 165This month’s issue of Custom PC Magazine marks a milestone: four years since I started writing my Hobby Tech column. To celebrate, three reviews spanning its five pages: the Ryanteck RTk.GPIO, the Kitronik Micro:bit Inventor’s Kit, and the Pimoroni GPIO Hammer Header – the only piece of electronic equipment I’ve ever reviewed installed with a hammer.

First, the RTk.GPIO. The brainchild of Ryan Walmsley, interviewed back in Issue 129, the RTk.GPIO is designed to bring all the joy of the Raspberry Pi’s general-purpose input-output (GPIO) header to any PC with a free USB port. A surprisingly sizeable red-hued circuit board, the RTk.GPIO includes a Pi-compatible 40-pin GPIO header with pin-out on the silkscreen. A quick pip install of the Python library later, and you can pretty much take any RPi.GPIO program and have it run natively on your Windows, Linux, or macOS machine.

Perhaps the biggest power of the RTk.GPIO is in assisting with the development of software for Pi add-ons, using the extra computing power of a desktop or laptop to make your life easier then allowing you to transfer your program to a real Raspberry Pi with minimal changes once complete. Its only real downside, in fact, is price: it’s more expensive than picking up a Raspberry Pi Zero and turning it into a USB device, though undeniably smoother to use.

The Kitronik kit, meanwhile, is one of a range of add-ons I’ve been playing with for my upcoming Micro:bit User’s Guide. Based around a GPIO expansion board for the micro:bit’s edge connector, the kit comes with mounting plate, solderless breadboard, jumper wires, and all the components you need to work through the included full-colour tutorial book – plus, in the version I picked up, the micro:bit itself, though the kit is also available without for those who already have the BBC’s miniature marvel.

In the years I’ve been playing with hobbyist electronics, I’ve seen these kits go from the most hastily thrown together things to extremely polished collections of hardware – and Kitronik’s kit definitely sits at the right end of that spectrum. There are nits to be picked, such as the lack of a handy plastic parts box for storage and no use of the lovely breadboard overlay sheets that make the Arduino-centric ARDX kit so easy to use, but it’s hard to imagine someone buying the Kitronik kit and being disappointed.

Finally, the GPIO Hammer Header. I’ve long been a fan of Pimoroni’s products, but the Hammer Header is by far both the simplest and the smartest I’ve seen. Designed for anyone who has purchased a Raspberry Pi Zero and wants to make use of the unpopulated GPIO header but who doesn’t fancy firing up a soldering iron, the kit makes use of cleverly-shaped pins which can make a suitable electrical connection purely mechanically.

The kit gets its name from the acrylic jig used for installation: assemble the jig with the Pi Zero in the middle, then give it a few sharp raps with a hammer to push the pins home. Male and female variants are available, allowing you to quickly install headers on both the Pi Zero and compact pHAT add-on boards, and to my surprise both installed quickly, easily, and without a single poor joint – and in a fraction of the time of soldering all 40 pins by hand.

For all this, and more, pick up the latest Custom PC Magazine from your nearest supermarket, newsagent, or digitally via Zinio or similar services.

The MagPi, Issue 43

The MagPi Issue 43It’s a special week for the Raspberry Pi Foundation: it’s celebrating its fourth birthday with the launch of the new Raspberry Pi 3. It’s a special day for me, too: the latest MagPi magazine boasts a total of thirteen pages of my content, including the cover splash: a detailed and thorough look at the new model.

Boasting on-board Wi-Fi (a community request since the original model launched four years ago), Bluetooth 4.1, Bluetooth Low Energy, and a faster 64-bit ARMv8 processor, the new Pi 3 is a bit of a beast. My cover feature for the magazine begins with a look at those behind it with a double-page spread featuring interviews with project co-founder Eben Upton and the Foundation’s director of hardware and the man responsible for circuit design James Adams – and a massive thank-you to both for sparing the time to talk to me at one of their busiest ever periods!

The feature then moves on to a look a the board itself, with a hero photo of the board spread across another two pages. Each major feature of the board, from the shiny new 64-bit BCM2837 system-on-chip (SoC) processor to the BCM43438 radio module – which required me to get out the microscope in order to capture its markings – has a call-out with close-up photography and an explanation of how it has changed since the Raspberry Pi 2.

Next up is a benchmark spread, which required me to come up with a detailed suite of tests. After some experimentation, I settled on a selection of classic benchmarks – SysBench CPU in single- and multi-threaded modes, Linpack with and without NEON support, Whetstone, Dhrystone, SysBench memory read and write, Ethernet throughput, Quake III Arena timedemo performance, and power draw at load and idle. As an added bonus, I also came up with a way of measuring general-purpose input-output (GPIO) performance under Python, writing a simple benchmark to toggle a pin on and off as quickly as possible and measuring the speed with a frequency counter connected to the GPIO header.

The next double-page spread looks at helping the reader get started with the new device. I walk readers through modifying an existing Raspbian installation to boot on the Pi 3 by editing config.txt, setting up the Wi-Fi module, enabling true OpenGL acceleration on the graphics processor, and how to write programs to get the best performance on the Pi 3. Sadly, I was unable to explain how to use the Bluetooth 4.1 and Bluetooth Low Energy features, as software support was not available at the time of writing.

The spread then ends with a look at five things you could do with a Pi 3 in order to take advantage of the new features and boosted performance. My work for the magazine continues, though, with a review of the Proster VC99 multimeter and Pimoroni pHAT DAC, before coming to a close with a one-page news piece regarding the production status of the popular Raspberry Pi Zero – helping to explain why it has been so difficult to get hold of and settling concerns that it may be bumped to the back of the production queue now the Pi 3 is out.

All 13 pages of my content, and plenty of other stuff by people who aren’t me, are available from your nearest supermarket or newsagent, or as a free PDF download under a Creative Commons licence from The MagPi’s official website.

Custom PC, Issue 130

Custom PC Issue 130This month’s Hobby Tech column for Custom PC magazine is something of a Pi-extravaganza, featuring a tutorial on how I built a Python-powered doorbell so I wouldn’t miss deliveries when I’m in the upstairs office and a review of the Wolfson Audio Board add-on. If you’re not a Pi-fan, fear not: there’s also my write-up of the first RetroCollect Video Games Market event in Leeds.

That’s a good place to start, in fact. The brainchild of RetroCollect founder Adam Buchanan, the RCVGM brought sellers and buyers from across the UK under the roof of Leeds Town Hall to see what happened. The turn-out was far higher than expected, with a queue snaking through the building and half-way around the outside, but those who stuck with it and got inside were in for a treat.

Exhibitors at the event included people selling 8-bit inspired Hama-bead art, hand-made game-themed jewellery and clothing, and hardware and software from the early 8-bit era right the way through to modern day. Personal highlights included a tour of BetaGamma’s Bas Gialopsos’ latest creations, including hot-rodded Spectrums and a composite video adapter for the Atari 2600, and a chance to chat with Philip Murphy about his North-East Retro Gaming events where over a hundred arcade cabinets, classic consoles and pinball tables are set to free play for the weekend.

For the Pi fan, the tutorial this month demonstrates how a relatively simple hardware hack – a switch connected to the GPIO port – can be used to bring some intelligence to every-day objects. Although I work from home, I often miss deliveries because I’m listening to music and can’t hear the doorbell. While I could have purchased a wireless door-chime with two receivers, I had Pis and switches a-plenty and decided to go for a homebrew solution with Twitter integration – with great success.

Finally for this month, the review of the Wolfson Audio Board. Kindly provided by CPC, the board connects to the GPIO header on the Model A and Model B Revision 2 – but not Revision 1 – Raspberry Pi boards and provides a considerable upgrade to its audio capabilities. To get a full idea of what it can do, you’ll have to buy the magazine – but its highlights include SPDIF digital audio inputs and outputs, high-definition playback, on-board amplification and even a pair of MEMS microphones for stereo recording.

All this, plus a bunch of fascinating stuff that I didn’t write, can be yours at your local newsagent, supermarket, or digitally via services like Zinio.

Raspberry Pi for Kids

Raspberry Pi for KidsThose of you who follow my every move may remember a few projects I created for Dennis Publishing’s Computeractive publication, centring around the Raspberry Pi and Arduino single-board systems – in particular the three-part series walking newcomers through creating software and hardware accessories for the Pi, which proved extremely popular with readers. So popular, in fact, that Dennis has extracted the tutorial on building a switch-based game controller and republished it in the MagBook Raspberry Pi for Kids.

If you missed it the first time around, the tutorial was designed as the follow-up to an earlier guide on writing a simple snake game in Python. Using microswitches, resistors, a segment of stripboard and a soldering iron, readers are shown how to add a dedicated game controller – connected through the Pi’s general-purpose input-output (GPIO) header – to the system and modify the game’s source code accordingly. Reader feedback was good, and the relatively simple circuit makes it a logical choice for the MagBook’s target audience – although younger kids should, naturally, be supervised when using a soldering iron.

The MagBook also makes heavy use of my photography, both in my tutorial and throughout the rest of the publication where various images of my Pis can be found gracing its pages. Sadly, in an editorial oversight, my name appears to have been missed off the list of contributors – but I’m sure that will be quickly corrected in a future edition.

The Raspberry Pi for Kids MagBook is available in newsagents and supermarkets now, or via Amazon.

Raspberry Pi User Guide, Second Edition

Raspberry Pi User Guide Second EditionSince I wrote the Raspberry Pi User Guide over a year ago, the project has changed dramatically. The Raspberry Pi Foundation has grown in size and stature, a new hardware revision has been released, the Model A finally hit the streets and users have been treated to dramatic improvements in the quantity, accessibility and quality of the software available.

As a result, I’m pleased to announce the release of the Raspberry Pi User Guide Second Edition. Significantly longer than the original release, the book has been thoroughly updated to cover the Model A, Model B Revision 2, and the Camera Module. Additional new features include step-by-step instructions for using the Raspberry Pi Software Configuration Tool, the New Out-Of-Box Software (NOOBS) installer, and various other tweaks to bring it bang up-to-date.

For those who haven’t taken the plunge into the world of Raspberry Pi yet, congratulations: you can now pick up a considerably better book to help you get started. For those who have already bought a copy of the First Edition, a consolation prize: I have negotiated with the publisher, Wiley & Sons, to produce an updated ‘Second Printing’ of the First Edition in eBook form. If you’ve purchased the First Edition in electronic format, delete and re-download the title to receive various free updates including Model A and Model B Revision 2 details. You’ll know if your particular store has updated the title, as there’ll be a sash at the top-right explaining the updated content.

The Raspberry Pi User Guide Second Edition is available from all good – and plenty of not-so-good – book sellers throughout the world and is also an official stock item of the Raspberry Pi Swag Store, profits from which go to help the Foundation complete its work in pushing the envelope of computing education both at home and abroad. High levels of interest in the title – the First Edition has at this point sold around 100,000 copies world-wide across its various translations – do mean that you may have a short wait for stock, though – so if you’re hoping to buy it as a Christmas present and see it available from somewhere, I’d advise against delaying your purchase.

Electronic copies of the Second Edition are at the time of writing hard to come by but, as with the First Edition, expect to see it in Kindle, Google Play Books, iBooks, PDF, ePub and various other proprietary and non-proprietary formats – as well as DRM-free via O’Reilly in the US – in the very near future.

Custom PC, Issue 121

Custom PC Issue 121Another month, another Hobby Tech column for Dennis Publishing’s Custom PC magazine. This month, I’ve been mostly playing with some toys that the rather lovely people at Ciseco have sent me: the Pi-Lite and the Raspberry Pi Wireless Inventors Kit.

But first, the traditional vintage computing section – and it’s a corker this month. Spanning a bumper two pages, this month I spoke to my rather talented friend Charlotte Gore about a project she’s been working on: the SIDI, a MIDI-to-SID-chip adapter designed with musicians firmly in mind.

The SID chip, for those who don’t know, was developed by Bob Yannes and found fame as the component of the Commodore 64 that really made the system stand out from the crowd. Famously described by Yannes’ colleague Charles Winterble as “10 times better than anything out there, and 20 times better than it needs to be,” the SID chip is still in use today to provide crunchy sounds for everyone from chiptune artists to mainstream musicians.

Trouble is, it’s a pain in the proverbial to use if you’re not a techie. That’s where the SIDI project comes in: a brave attempt to create a control surface that allows a musician, with absolutely no knowledge of programming, the Commodore 64, or the SID chip itself, to twiddle a few knobs, press keys on a MIDI keyboard and coax forth those iconic sounds. Even at this early stage of development – and when Gore started the project, her electronics experience was around the level of changing batteries in remote controls – it’s a stunning creation, and if you have any interest in electronic music, the C64, SID chips or how vintage electronics can be reborn I’d heartily recommend giving the feature a read.

Next, on to Ciseco. The company was kind enough to send over a couple of their latest toys: the white edition of the Pi-Lite, and the Raspberry Pi Wireless Inventors Kit. The first is an add-on board for the Pi that provides an LED matrix, programmable via the UART connection on the GPIO pins. To make full use of the gift, I create a small tutorial – highlighted on the cover splash – for displaying a scrolling graph of CPU activity. As usual, the code is up on GitHub if you’re curious.

The RasWIK, to use its contracted name, is a bit more involved: not due to launch until next month, the kit provides a radio-equipped Arduino clone, a matching radio board for the Raspberry Pi’s GPIO header, and a selection of components for experimentation. I had an absolute blast playing with this, even though at the time of writing the software was still at a very early stage. It provides possibly the simplest platform for experimenting with wireless sensor networks I’ve ever seen – and there’ll be a second review of the kit, written when the software was a bit more polished, appearing in a future Linux User & Developer magazine.

All this, plus the usual maker-themed news snippets, can be yours if you just pop over to your local newsagent, supermarket, or even just stay in and download a copy of the magazine from Zinio or another digital distribution platform.

Custom PC, Issue 118

Custom PC Issue 118I hinted last month that there were changes afoot at Custom PC, and this latest issue is the result: my regular two-page interview column has been replaced with Hobby Tech, a new four-page extravaganza celebrating the best of the hacker, maker and retrocomputing communities.

In other words: it’s a column where I get to waffle on about the sort of things I do for fun these days. While getting paid. What’s not to like?

It’s likely to be a couple of issues before the column gets into its full swing – the idea is that it will evolve into a 21st century update of Jerry Pournelle’s old column from BYTE magazine, which has long been one of my favourite pieces of content. I’m no Pournelle, but hopefully I can rustle up something that will keep the readers entertained each month.

So, onto the column itself. This month, the focus – as evidenced by the issue’s cover splash – is on the work I’ve done turning a Raspberry Pi into a low-cost NAS. Taking the form of a tutorial, this part looks at how I used Btrfs, SSH and a pair of external hard drives to create a low-cost, low-power destination for my backups and miscellaneous files. If you’re struggling with “page allocation failure” messages in your Pi’s kernel log, it also includes advice about that.

That’s only two pages, however, and Hobby Tech is bigger than that. So, there was room for a quick review of the excellent ExpEYES Junior developed by the Inter-University Accelerator Centre in New Delhi as an educational aid. Connecting to a USB port and driven by an open-source Python toolkit, the device acts as a programmable power supply, four-channel storage oscilloscope, microphone, analogue-to-digital converter, signal generator and more – and comes with the components required to perform 50 experiments.

Finally, for the retrocomputing enthusiasts, an explanation of how I turned a second-hand Amiga A1200 – purchased, incidentally, from Custom PC’s sister website bit-tech.net – into more than the sum of its parts. Those who follow me on Twitter will be aware of my work in that regard: fitting heatsinks to prolong the life, replacing the plastics and keyboard, upgrading the Kickstart ROMs, installing a CompactFlash hard drive and connecting the system to my home network.

If that sounds like something of a hodgepodge of topics, then that’s probably because it is; the link between them all is that they’re all subjects about which I am extremely passionate, and I hope that comes across in the column.

I’m very keen to get feedback on Hobby Tech, as is editor Ben Hardwidge: it’s a new direction for the magazine, and something of an experiment. Please, if you’ve read this month’s Custom PC, leave a comment with your thoughts either here or on the magazine discussion forum. Likewise, if you’ve got any ideas for topics or devices you’d like to see covered in future Hobby Tech columns, let me know!

Custom PC Issue 118 is available pretty much everywhere, but if it isn’t then grab a digital copy from Zinio or an equivalent service instead.