pHAT Stack review

pHAT Stack review

Pimoroni’s pHAT Stack (£14/$16) enables you to use multiple add-on boards simultaneously with your Raspberry Pi. Also available as a solder-yourself kit (or just a PCB board), the Stack is equipped with five sets of 2×20 pin headers, plus one to connect to the Pi via a GPIO ribbon cable (supplied). This means there’s room to connect five smaller pHAT boards, three full-size HATs, or a mixture of both. While this might seem like overkill, it provides a convenient way to switch in and out different HATs and pHATs and create your own custom combinations. So it’s ideal for experimenting with hardware project ideas. One nice touch is that the three of the GPIO headers have their pins fully labelled, which should prove handy for connecting up your own circuits and sensors. Brass standoffs and screws are also supplied for secure mounting of HATs and pHATs. Pimoroni pHAT Stack review While it’s very easy to mount the add-on boards on the pHAT Stack, one caveat is that not all of them will play nicely with each other: you need to look out for those that use the same GPIO pins. Pimoroni’s ‘pHAT Stack configurator’ online tool comes in handy here: hosted at the ever useful pinout.xyz, it lets you simulate adding various HATs and pHATs to the Stack and will warn you of any pin conflicts. Multiple boards may still use the same I2C pins (BCM 2 and 3) without issues, so long as they use different addresses. In our test setup, we combined a Speaker pHAT, Drum HAT, and Piano HAT to create a mini music box, following Pimoroni’s online guide. This worked well, even though the pHAT Stack configurator flagged up a possible pin conflict on BCM 21. Other suggested setups include an alarm clock (Four Letter pHAT, Touch pHAT, and Speaker pHAT) and a weather station with built-in dashboard (Enviro pHAT, Four Letter pHAT, and Scroll pHAT). You could even solder a female header to a Pi Zero and mount that on the Stack’s bottom header, rather than using the ribbon cable. Multiple hats connected to a Raspberry Pi using the pHAT Stack pHAT Stack review: The last word Whether you use it for a specific project or just for experimenting with combining various pHATs and HATs, the pHAT Stack is a well-designed breakout board that should prove useful. You just need to watch out for those GPIO conflicts…
Source: pHAT Stack review

Code games in C++ on Raspberry Pi part 1

Code games in C++ on Raspberry Pi part 1

Despite its awesome success as a hobby system, the Raspberry Pi is seldom looked on as a machine that lets you write or play your own graphical games. There are emulators, of course, and those are a great introduction to the style of retro games most old-school coders cut their teeth on as spotty youths. However, you don’t see many original games written for the Pi, on the Pi, by Pi coders. Let’s try to change that. Game coding, on Raspberry Pi, in a professional language like C/C++ isn’t apparently very popular, but why? The Pi is more than capable of doing cool graphics, has (nearly) all the tools needed on board, and just enough horsepower to easily create and run high-octane 2D games. It can even push a decent amount of polys around to create some quite exciting 3D experiences. There’s simply no reason not to write cool games on the Pi, so it’s time we addressed this and introduce some new Pi coders to C++ and game coding, as well as a little dabble with the Broadcom GPU. Let’s start with the first thing all new coders need to know, which is: DON’T PANIC! C/C++ isn’t as hard as people tend to think it is, especially if we stick to core principles and concepts. It can get very complex very fast, but you can take your time and make progress at your own rate and still create cool things. But before we can use the language, we really need to have a development system known as an integrated development environment, or IDE for short; this contains all our code and lets us edit, build, and debug our code in one program. Of course, you can use multiple files and command-line systems, but IDEs are designed to make things easier, so let’s just use them. For this set of tutorials we’re going to use Code::Blocks, which you can find using sudo apt‑get install codeblocks in your Terminal window. Code::Blocks gives us access to a much more C++ friendly editor, compiler and debugger, and lets us run our code directly from the edit screen. Once installed, it appears in Programming tools (see pic below). The Code::Blocks IDE lets you create a startup console C++ Hello World program First steps Coders always start learning with the Hello World example, so we should do the same just to get used to our system.…
Source: Code games in C++ on Raspberry Pi part 1

UnIversity student data collection powered by Pi

UnIversity student data collection powered by Pi

Overhauling internal computer systems can be hard, especially in places where the systems are vital. In the case of Michigan Tech ELC, replacing a proprietary data collection system – used by students – with Raspberry Pi is looking to be not only cost-effective, but also an upgrade over an existing system, as Aneet Narendranath explains to us. Can you tell us about your Pi data collection system? At Michigan Tech as part of my responsibilities, I manage and direct the operations of the Engineering Learning Center (ELC). The ELC is an in-house tutoring resource that helps engineering students with concepts and concept applications for engineering problems that they encounter in homework assignments. The tutors in the ELC, who have the title ‘coach’, are students themselves. At the ELC, we use peer-to-peer instruction as a method of teaching and learning. The purpose of the ELC is to allow engineering problem resolution through concept discussion amongst peers. At the ELC, I work with a certain yearly budget. The budget and the staffing of the ELC with coaches are coupled strongly. To ensure that we optimise our monetary resources through effective staffing, whilst ensuring that students receive help when they need it, is a (multidimensional mathematical) challenge. To perform this optimisation, we need (or needed) to collect ELC usage data to visualise what courses, hours of the day, and days of the week the ELC is used the most by students. By collecting data over several semesters, we found patterns in ELC usage and that allowed us to make staffing decisions, thereby helping us balance our budget while assisting students. We have a proprietary ‘Learning Center Management System’ that we use currently. We are planning on replacing it with a Raspberry Pi-based (prototype) data collection alternative. In this Raspberry Pi system, data can be collected through an interface written in Bash and then analysed through Python and Octave scripts. This Raspberry Pi alternative is in its alpha version. The beta version will be deployed shortly. How did the idea come about? Our previous method of data collection, which was proprietary although effective, was not flexible and could not be automated for ELC-specific usage. This and its cost had us review other options. I have personally used the Raspberry Pi to keep track of my house when I am away on vacation (like an IoT device). Given that I had already used it extensively…
Source: UnIversity student data collection powered by Pi

Button SHIM review

Button SHIM review

The Button SHIM from Pimoroni (£6/$7) adds five buttons and an LED to your Raspberry Pi. So far, so simple. What’s neat about it is that it gives you full use of all of your Pi’s pins. The GPIO pins poke through the SHIM so you can get to them. Most obviously, that means you can use the Button SHIM to add some input controls to an electronics project. If you’re running out of GPIO pins, getting five buttons for free is a real plus. This review was written by Phil King and first appeared in The MagPi #66. You can download a free copy of The MagPi and sign up for our newsletter to know when each new issue is available. Pimoroni Button Shim review The Button SHIM also plays nicely with many HATs, so you can use it to add input controls to an output HAT. The Unicorn HAT, for example, provides a grid of colourful LEDs that can be used for visual displays or scrolling messages. By adding buttons, you can create more flexible applications that can run without a keyboard. The buttons stick out above the top edge of your Raspberry Pi. As a result, your Button SHIM project is unlikely to fit in an existing Pi case. Positioned at a right angle, the buttons press in towards the Raspberry Pi, and are labelled from A to E. To set up the SHIM, you’ll need to be competent with a soldering iron. The SHIM has a set of holes, so you slide it over your GPIO pins. You then need to solder several of the Raspberry Pi’s pins to the board. It’s a good idea to solder an additional couple of pins at the other end of the board to help hold the SHIM in place. As with anything that involves soldering the GPIO pins, it’s an unavoidably fiddly job because the pins are only a few millimetres apart. If there is any excess solder on a pin, it might stop a HAT from sitting on the GPIO pins properly afterwards. There is also a female header included which you can solder to the Button SHIM if you want to use it by itself. The RGB LED in the corner of the board is a great bonus, and ideal for adding status signals to a project. The rainbow example program shows how the buttons can be…
Source: Button SHIM review

Control LEGO Mindstorms through GPIO

Control LEGO Mindstorms through GPIO

LEGO Mindstorms is a great tool to gain experience in understanding robotics, but what if you wanted to make your own input sensor? In this guide, we will show how simple it is to construct a circuit to control a Mindstorms robot through GPIO in Raspberry Pi. We will show every step from connecting the robot to writing the code. The result will be a program in Ch, a superset interpreter of C/C++, to control the direction of the robot with a push-button. You’ll need LEGO Mindstorms robot (NXT or EV3) Breadboard Wires for breadboard 1 × LED 1 × Push-button 1 × 220 Ω resistor (Red-Red-Brown) 1 × 10 kΩ resistor (Brown-Black-Orange) Code for this project Software To make use of C-STEM’s programming tools, you should install the C-STEMbian operating system, which contains C-STEM Studio. This free, open-source operating system contains all the necessary tools for robotics and physical computing. Additionally, it is a superset of Raspbian, so all the familiar features will still be there. If you already have Raspbian installed, the C-STEM modules can be installed separately on top. All of this is available from the C-STEMbian section of the C-STEM website. Step-by-step guides will assist you in setting up and accessing the Raspberry Pi if needed. Connecting to the Mindstorms robot Connecting to your Mindstorms robot is quite simple with the C-STEM software. First, you will need to open C-STEM Studio and launch Ch Mindstorms Controller. Find the big ‘C’ at the top of the screen after logging in to your Raspberry Pi. Click the ‘C’, then navigate to ‘Ch Mindstorms Controller’ on the left side of the menu in C-STEM Studio. Click on Launch to open it. Ch Mindstorms Controller can connect with both EV3 and NXT robots. Simply press the Scan Robot button and add the robots that are found to the list on your robot manager. Follow the instructions on screen to pair the robots with your Raspberry Pi. Due to the limitations of Bluetooth, the Ch Mindstorms Controller can connect to a maximum of seven robots at a time. (Do make sure that the robots are turned on and have Bluetooth enabled!) Once the robots have been scanned and added to the list, select the ones you would like to connect to and press Connect. Robots that you are connected to will have a green dot next to their names. Building the simple circuit…
Source: Control LEGO Mindstorms through GPIO

Steampunk Pi Jukebox

Steampunk Pi Jukebox

Matt Van Gastel’s retro-futuristic Steampunk Pi Jukebox music steaming device looks as good as it sounds As technology has progressed, so too has the way that we listen to music. We have enjoyed our tunes on vinyl, cassette, CD, and even MiniDisc, among a plethora of formats. We’ve also used MP3 players and iPods and grown accustomed to music streaming. Yet one method of listening to our favourite songs has remained strong throughout this time: the humble radio, a device that for many conjures images of cosy nights in twiddling AM and FM dials to discover new tunes. This project first appeared in The MagPi #66. Download a free digital edition of The MagPi #66 here. Steampunk Pi Jukebox So when we heard that Matt Van Gastel had turned the main assembly of a 1930s Westinghouse radio receiver into a Pi-powered modern player, it was music to our nostalgic ears. “I’d been carrying this old radio from house to house for years, fully intending to restore it,” he says of the set which his great-grandparents had bought close to a century ago. “But after doing some research and determining that there was no real value in restoring it, I came up with the idea of using a Raspberry Pi to create a music server.” Matt, who has a background in radio and television, began the project by tearing out the innards from the old tube amplifier. “This wasn’t difficult, but it was very messy and time-consuming,” he says. It mostly involved cutting away the various parts including the main electronics assembly. Once he had the assembly, he could turn his attention to his Raspberry Pi 3. “The Pi 3 seemed like a natural choice because I already had a few of them waiting for a project,” he explains. During his research, he came across the JustBoom Amp HAT which costs £60 and outputs at 55 W. Needing no soldering or external sound cards, and providing high-quality audio along with digital-to-analogue conversion, Matt felt it was perfect. Serving music on Raspberry Pi “I had looked at making an actual tube amplifier, but the cost was too high for the quality,” Matt tells us. “But I found the JustBoom site and found this HAT fitted the bill because of its power output capabilities and extremely low noise floor and supply requirements.” With this in place, Matt then looked for flexible music server software and…
Source: Steampunk Pi Jukebox

NanoSound DAC Pro review

NanoSound DAC Pro review

There are a number of DACs available for the Raspberry Pi – digital-to-analogue converter add-ons that let you play high-quality audio from the Pi. We’ve reviewed many of them in past issues of The MagPi, so it’s always interesting to see a DAC do something different. The NanoSound DAC Pro from Nanomesher is one of these devices that sets itself apart. Like a lot of DACs, it comes as a HAT add-on for the Raspberry Pi, sitting snugly on top of the GPIO pins. This one covers the entire board, going over the top of the USB and Ethernet ports of a full-sized Raspberry Pi (think B+, 2, 3, etc.). However, it does this to offer more options – namely a little LCD screen and some physical buttons. These buttons and screen are one of the most interesting parts of this solution, allowing you to use the Pi and the DAC together as an all-in-one music player which you can then hook up to your favourite speakers. There’s even a 3D-printed case you can get, with the files downloadable for free. It all works together with Volumio, an open-source music player that works on the Pi and is optimised for playing your music in the highest quality possible. With a few tweaks you can get it to accept the button inputs of the DAC and display song information on the screen, which is very smart. The kit even comes with a remote control you can control the system with as well. It’s a really neat little package, and it still outputs the great-quality sound it’s primarily meant to do. As well as the fully featured Pro version we reviewed, there is a cheaper Basic version for $48 / £35 that doesn’t come with a screen if you don’t need it (although you can get a kit to solder one on). At the very least it does come with the buttons and the remote, which are arguably more important than the screen anyway. It’s a great bit of kit, and maybe something to consider as an alternative to our music box tutorial on page 20 of our media player projects feature… Last word 5/5 A lovely all-in-one music box solution for your Raspberry Pi that adds everything you’d need bar speakers. It sounds good as well. The post NanoSound DAC Pro review appeared first on The MagPi Magazine.
Source: NanoSound DAC Pro review

Mozilla Project Things: IoT on Raspberry Pi

Mozilla Project Things: IoT on Raspberry Pi

Firefox maker Mozilla has launched a new, open standard for IoT and smart homes called Project Things. Mozilla announced that Project Things “makes it easy for anyone with a Raspberry Pi to build their own Things Gateway [to control any kind of smart device] directly from the web.” Mozilla Project Things We asked Ben Francis, Mozilla software engineer, for more detail. “The Things Gateway is designed to bridge existing smart home protocols and devices to the ‘Web of Things’ using ‘adapters’,” he says, to add extra wireless protocols to the Raspberry Pi. Ben confirms, “The latest version has built-in adapters for the Zigbee and Z-Wave protocols [as well as] adaptor add-ons for devices from brands like Philips and TP-Link… we’re calling on the community to help us build a whole directory of add-ons.” Many smart home devices use Zigbee or Z-Wave to minimise power draw. However, as few smartphones have Zigbee or Z-Wave hardware, smart home apps have to relay information via a physical hub unit. These hubs tend to be proprietary, closed ‘black boxes’ – even worse, you might need one for your lights, another for your heating system, and yet another for your multi-room speakers. Ben says that Project Things aims to “standardise web technologies as a common layer”, thus consolidating the need for hubs into one open-source, customisable and upgradable, Pi-powered unit. Project Things: IoT Beyond the black box Any smart device should be compatible with a Things Gateway, as Ben clarifies: “Our goal is not to create a proprietary Mozilla IoT platform, but rather help to build a World Wide Web of things, much like the World Wide Web of pages you can browse with Firefox.” Ben expounds that by “using the Web Thing Description format and Web Thing API  we’re contributing towards standardising through the World Wide Web Consortium (W3C).” Interestingly, given Mozilla’s web-based background, Ben confirms that “the rules engine built into the Things Gateway runs locally on the home network”. Further, “Mozilla provides a secure tunnelling service to make it safe and easy to access the gateway over the internet.” Ben adds that “working towards royalty free IoT standards, with multiple competing implementations, should help to drive down the certification and licensing costs, [both for hardware devices and] the software needed to connect them together.” The Project Things GitHub page is live on GitHub and you can start making your Things Gateway at…
Source: Mozilla Project Things: IoT on Raspberry Pi

Rosie the Red Robot

Rosie the Red Robot

The clock is ticking as the contestants concentrate hard on finding the longest word possible from nine randomly selected letters. Yes, it’s Countdown, the classic TV game show loved by students, senior citizens… and robots. Playing along at home is Rosie, her Camera Module eye focused on the screen. Within seconds she blurts out, “I have a six-letter answer: murder.” Rosie first came to life when Alan Peaty was challenged by his daughter to build a robot. Despite his engineering experience, Alan didn’t find it easy. “It didn’t take long before I was completely out of my comfort zone,” he tells us. “Possibly the most challenging aspect of trying to build a robot is that there are so many different areas of technology involved, from hardware to software, mechanics to electronics. For example, just to get Rosie’s neck to move, we had to write some code in Python, learn about Serial Peripheral Interface bus (SPI), and get familiar with servo motors and the physics of torque, even before thinking about connecting the whole thing together. Be prepared to Google absolutely everything and anything.” As documented in detail on the rosietheredrobot.com blog, Alan has spent several months building Rosie and gradually adding extra hardware and abilities, while learning a lot along the way. At first Rosie was a simple wheeled robot, but she is now equipped with a headlight, LED matrix expressive ‘eyes’, motion sensor, GPS receiver, ultrasonic distance sensors, and a Camera Module. Please don’t sit as close as Rosie does to your TV Playing the game It’s this last addition that enables Rosie to see the Countdown letters on the TV screen. Optical character recognition is then carried out using Google Cloud Vision API, to read the letters. “She performs relatively well at different distances on one condition – only the individual letters from the letters round is showing on-screen when the photo is captured,” reveals Alan. “When the contestants’ names, or even the channel name, appear in the same picture, it starts to muddle Rosie’s brain.” A Python application runs the identified letters through an algorithm that matches possible results from a dictionary containing 10 000 words – a dataset from magpi.cc/2mgxuv4 that Alan has arranged alphabetically. Python’s gTTS text-to-speech module is then used to get Rosie to say the longest word she’s found, along with the numbers of letters in it, via an on-board speaker. Naturally, replacing the…
Source: Rosie the Red Robot

Fractal music: explore musical patterns

Fractal music: explore musical patterns

Create fractal music and change them into intriguing music patterns with a Raspberry Pi. Fractals seem to have gone out of favour when it comes to computers, which is a pity because there are plenty of exciting things to explore with them, especially in the field of music. Most people think of a fractal as a complex curve and there a few pleasant-looking standard examples. The basic property of a fractal is that it is self-similar; that is, you see the same sort of pattern if looking at a very small magnified portion of the curve as you do when you look at a zoomed out portion. They are both similar, but not of course identical. Music has a similar structure, with patterns of notes repeating but developing throughout the composition. This is a rich, and largely untapped, source of tunes and inspiration. Fractal music generation There are many ways to generate fractals, but here we will be looking at one method, the Lindenmayer system, or L-system for short. This is a recursive algorithm inspired by biological system; it works by successive applications of substitution rules to a string of symbols to generate another, normally longer, string of symbols. This output string is fed into the input again and a new string is generated. This process is repeated any number of times and produces a fractal, or self-similar, sequence. The rules and the initial string, called the axiom, determine the outcome. Let’s see how this works in practice by looking at a very simple example shown in Figure 1. This has just three symbols – A, B, and C – and each symbol has a rule for substitution. So when we encounter an A in the input stream, we replace it with the symbols BA in the output stream. When B is encountered, we replace it with a C. When C is found, we replace it with an AB. These rules are shown on the left of the diagram. Figure 1How symbolic substitution works If we start with the simple axiom of C after the first application of the rules, we get the string AB. Then run it through the rules again and the first symbol A is replaced by BA and the second symbol B is replaced by C. This applying of rules to an input string to produce an output string is known as a level of recursion; after…
Source: Fractal music: explore musical patterns