Tag Archives: The MagPi

Gamified boxing with Pi Fighter

via Raspberry Pi

Gamifying boxing with a special punchbag that allows you to fight Luke Skywalker? Rob Zwetsloot starts a training montage to check it out.

Not Rob

Street Fighter

Did you know that the original version of Street Fighter had a variant where you could punch the buttons to get Ryu to attack? The harder you smacked the kick button, the more damage it would do. These apparently wore out very quickly, which is why watching Street Fighter tournaments these days is akin to watching someone playing the piano. Albeit with six buttons and a joystick.

What if you could bring this back? And combine it with other arcade classics and staples? Meet Richard Kirby’s Pi Fighter.

A new challenger!

“Pi Fighter is essentially a real-world old-school fighting video game,” Richard tells us. “The player chooses an opponent and challenges them to a sparring match. Each player has a certain number of health points that decrement each time the other player lands an attack. Instead of clicking a joystick or mouse button, the player hits a heavy bag. The strength of the hit is measured by an accelerometer. [A Raspberry] Pi translates the acceleration of the heavy bag (measured in G) into the number of health points to decrement from the opponent. [Raspberry] Pi runs your opponent, which attacks you — you don’t actually get hit, but your health points decrement each time they attack.”

Use a heavy bag to get a good workout and a good idea of your punch strength, Rocky IV style

It’s a remarkably simple idea, and it started off as just an app that used a smartphone’s accelerometer. Translating that to a Raspberry Pi is just a case of adding an accelerometer of its own.

3… 2… 1… Fight!

“I realised it could be used to measure the overall strength of a punch, but it was hard to know how that would translate into an actual punch, hence the idea to use a heavy bag,” Richard explains. “This appealed to me as I studied karate and always enjoyed hitting a heavy bag. It is always difficult to gauge your own strength, so I thought it would be useful to actually measure the force. The project ended up consuming a good amount of time, as you would expect when you are learning.”

Finish them?

While Pi Fighter is already used at events, Richard says “[i]t needs a bit of tuning and coding to get everything right […]. It could be a never-ending project for me. You can always fix things and make the software more robust, the user interface more usable, etc. It isn’t mass-rollout ready, but I have never had it fail at a key moment such as presenting at a Raspberry Jam or Raspberry Pint. It (mostly) gets better every time I put some effort into it.”

If you find yourself at Raspberry Pint in London, make sure to do a bit of a warm-up first — you might find yourself head-to-head in a boxing match with a Jedi. Here’s hoping they don’t know Teräs Käsi.

The post Gamified boxing with Pi Fighter appeared first on Raspberry Pi.

Raspberry Pi 4: a full desktop replacement?

via Raspberry Pi

The MagPi magazine puts Raspberry Pi 4 to the ultimate test as writer and all-round tech tinkerer PJ Evans uses it for a week as his desktop computer.

When Raspberry Pi 4 was launched earlier in 2019, the significant improvements in processor speed, data throughput, and graphics handling lead to an interesting change of direction for this once humble small computer. Although it’s impressive that you can run a full Linux operating system on a $35 device, a lot of people were just using their Raspberry Pi to get Scratch or Python IDLE up and running. Many people were skipping the graphical side altogether and using smaller models, such as Raspberry Pi Zero, for projects previously covered by Arduino and other microcontrollers.

Raspberry Pi desktop experience

Raspberry Pi 4 was different. Tellingly, the Raspberry Pi Foundation released a new all-in-one kit and named it the Desktop Kit. For the first time truly in Raspberry Pi history, the new model was considered powerful enough to be used as a daily computer without any significant compromise. Challenge accepted. We asked PJ Evans to spend a week using a Raspberry Pi 4 as his only machine. Here’s what happened.

Day 1 | Monday

Decisions, decisions

Our new favourite single-board computer comes in a selection of RAM sizes: 1GB, 2GB, or 4GB. Given a price difference of £20 between the 1GB and 4GB versions, it made sense to go right for the top specification. That’s the version included in the official Desktop Kit that I went out and bought for £105 (inc. VAT) at the official Raspberry Pi store; it normally retails for $120 plus local taxes. My last laptop was £1900. I’m not suggesting that the two can be reasonably compared in terms of performance, but £1795 minus the cost of a monitor is a difference worth remarking upon.

Back at the office, I inspected the contents. For your money you get: a 4GB version of Raspberry Pi 4, thoughtfully already installed in the new official case; the official keyboard and mouse; the new USB-C power supply; a 16GB microSD card preloaded with the Raspbian Buster operating system; and a copy of The Official Raspberry Pi Beginner’s Guide 252-page book. It’s very well packaged and presented, with little plastic waste. The book is the icing on the cake if you are looking at this set for a young person’s first computer, short-circuiting the ‘now what do I do?’ stage. What pleased me, in particular, was the inclusion of two micro-HDMI cables in the kit, allowing me to set up a dual-screen system without delay.

First tests

I set up my new workstation next to my existing laptop, with two 1080p monitors that only had DVI connectors, so I had to get a couple of £2 adapters and an additional cable to get sound out of the audio jack of my Raspberry Pi. Time for an initial test-drive. Booting up into Raspbian Buster was quick, about ten seconds, and connection to WiFi easy. There’s no doubting the feel of the speed improvements. Yes, I’ve read all the benchmark tests, but I wanted to know how that translates to user experience. This new kit does not disappoint.

Raspbian has matured impressively as an OS. For my daily desktop scenario, the jewel in the crown is Chromium: having such a capable web browser is what makes this whole experiment feasible. Others have upped their game, too: Firefox has come a long way, and many other browsers are now available, such as Vivaldi. A check of some of my most visited sites showed Chromium to be just as capable as Chrome on my regular machine. Unsurprisingly, it wasn’t as snappy and I hit a few bumps, but we’ll get to that.

A day of impressions

I’m no expert when it comes to GPUs, but I was impressed with the dual-monitor support. The setup worked first time and didn’t seem to have any detrimental effect on the machine’s performance. I was expecting slow window drawing or things getting ‘stuck’, but this wasn’t the case.

By the end of the first day, I was getting used to the keyboard and mouse too. They are a nice mixture of being both functional and aesthetically pleasing. The keyboard comes with a three-port hub, so you can connect the mouse if you wish. It does not have the build quality and precision of my daily wireless keyboard and trackpad, but for a fraction of the price, I was surprised how much I got for my money. By the end of the week, I’d grown quite fond of it.

Day 2 | Tuesday

Back to basics…


If you’d like to see what PJ got up to for the rest of his week spent using Raspberry Pi as a desktop replacement, head over to The MagPi magazine’s website, where you can either buy the magazine with international home delivery or download the PDF for FREE!

The MagPi magazine is also available from most high street newsagents in the UK, or from the Raspberry Pi store in Cambridge.

What we’re trying to say, dear reader, is that there is absolutely no reason for you not to read the rest of this article. And when you have, let us know what you thought of it in the comments below.

And while we have your attention, here’s the latest video from The MagPi — a teaser of their review for the rather nifty RockyBorg, available now from PiBorg.

RockyBorg: the £99 Raspberry Pi robot!

Power. Performance. Pint-sized. The new RockyBorg has it all. Read our review in The MagPi 85: https://magpi.cc/get85 Would you like a FREE #RaspberryPi? Subscribe today to twelve months print subscription! You can see all our subscription offers on The MagPi magazine website: https://magpi.cc/subscribe

The post Raspberry Pi 4: a full desktop replacement? appeared first on Raspberry Pi.

IoT community sprinkler system using Raspberry Pi | The MagPi issue 83

via Raspberry Pi

Saving water, several thousand lawns at a time: The MagPi magazine takes a look at the award-winning IoT sprinkler system of Coolest Projects USA participant Adarsh Ambati.

At any Coolest Projects event, you’re bound to see incredible things built by young makers. At Coolest Projects USA, we had the chance to talk to Adarsh Ambati about his community sprinkler and we were, frankly, amazed.

“The extreme, record-breaking drought in California inspired me to think of innovative ways to save water,” Adarsh tells us. “While going to school in the rain one day, I saw one of my neighbours with their sprinklers on, creating run-offs. Through research, I found that 25% of the water used in an average American household is wasted each day due to overwatering and inefficient watering methods. Thus, I developed a sprinkler system that is compliant with water regulations, to cost-effectively save water for entire neighbourhoods using a Raspberry Pi, moisture sensors, PyOWM (weather database), and by utilising free social media networks like Twitter.”

Efficient watering

In California, it’s very hot year round, so if you want a lush, green lawn you need to keep the grass watered. The record-breaking drought Adarsh was referring to resulted in extreme limitations on how much you could water your grass. The problem is, unless you have a very expensive sprinkler system, it’s easy to water the grass when it doesn’t need to be.

“The goal of my project is to save water wasted during general-purpose landscape irrigation of an entire neighbourhood by building a moisture sensor-based smart sprinkler system that integrates real-time weather forecast data to provide only optimum levels of water required,” Adarsh explains. “It will also have Twitter capabilities that will be able to publish information about when and how long to turn on the sprinklers, through the social networks. The residents in the community will subscribe to this information by following an account on Twitter, and utilise it to prevent water wasted during general-purpose landscaping and stay compliant with water regulations imposed in each area.”

Using the Raspberry Pi, Adarsh was able to build a prototype for about $50 — a lot cheaper than smart sprinklers you can currently buy on the market.

“I piloted it with ten homes, so the cost per home is around $5,” he reveals. “But since it has the potential to serve an entire community, the cost per home can be a few cents. For example, there are about 37000 residents in Almaden Valley, San Jose (where I live). If there is an average of two to four residents per home, there should be 9250 to 18500 homes. If I strategically place ten such prototypes, the cost per house would be five cents or less.”

Massive saving

Adarsh continues, “Based on two months of data, 83% of the water used for outdoor landscape watering can be saved. The average household in northern California uses 100 gallons of water for outdoor landscaping on a daily basis. The ten homes in my pilot had the potential to save roughly 50000 gallons over a two-month period, or 2500 gallons per month per home. At $0.007 per gallon, the savings equate to $209 per year, per home. For Almaden Valley alone, we have the potential to save around $2m to $4m per year!”

The results from Adarsh’s test were presented to the San Jose City Council, and they were so impressed they’re now considering putting similar systems in their public grass areas. Oh, and he also won the Hardware project category at Coolest Projects USA.

The MagPi magazine #83

This article is from today’s brand-new issue of The MagPi, the official Raspberry Pi magazine. Buy it from all good newsagents, subscribe to pay less per issue and support our work, or download the free PDF to give it a try first.

The post IoT community sprinkler system using Raspberry Pi | The MagPi issue 83 appeared first on Raspberry Pi.

Make a retro console with RetroPie and a Raspberry Pi — part 2

via Raspberry Pi

Here’s part two of Lucy Hattersley’s wonderful retro games console tutorial. Part 1 of the tutorial lives here, for those of you who missed it.

Choose the network locale

RetroPie boots into EmulationStation, which is your starter interface. It’s currently displaying just the one option, RetroPie, which is used to set up the emulation options. As you add games to RetroPie, other systems will appear in EmulationStation.

With RetroPie selected, press the A button on the gamepad to open the configuration window. Use the D-pad to move down the options and select WiFi. You will see a warning message: ‘You don’t currently have your WiFi country set…’. Press the D-pad left to choose Yes, and press A. The interface will open raspi-config. At this point, it’s handy to switch to the keyboard and use that instead.

Choose 4 Localisation Options, and press the right arrow key on the keyboard to highlight Select, then press Enter.

Now choose 4 Change Wi-fi Country and pick your country from the list. We used GB Britain (UK). Highlight OK and press Enter to select it.

Now move right twice to choose Finish and press Enter. This will reboot the system.

Connect to wireless LAN

If you have a Raspberry Pi with an Ethernet connection, you can use an Ethernet cable to connect directly to your router/modem or network.

More likely, you’ll connect the Raspberry Pi to a wireless LAN network so you can access it when it’s beneath your television.

Head back into RetroPie from EmulationStation and down to the WiFi setting; choose Connect to WiFi network.

The window will display a list of nearby wireless LAN networks. Choose your network and use the keyboard to enter the wireless LAN password. Press Enter when you’re done. Choose the Exit option to return to the RetroPie interface.

Configuration tools

Now choose RetroPie Setup and then Configuration Tools. Here, in the Choose an option window, you’ll find a range of useful tools. As we’re using a USB gamepad, we don’t need the Bluetooth settings, but it’s worth noting they’re here.

We want to turn on Samba so we can share files from our computer directly to RetroPie. Choose Samba and Install RetroPie Samba shares, then select OK.

Now choose Cancel to back up to the Choose an option window, and then Back to return to the RetroPie-Setup script.

Run the setup script

Choose Update RetroPie-Setup script and press Enter. After the script has updated, press Enter again and you’ll be back at the Notice: window. Press Enter and choose Basic install; press Enter, choose Yes, and press Enter again to begin the setup and run the configuration script.

When the script has finished, choose Perform a reboot and Yes.

Turn on Samba in Windows

We’re going to use Samba to copy a ROM file (a video game image) from our computer to RetroPie.

Samba used to be installed by default in Windows, but it has recently become an optional installation. In Windows 10, click on the Search bar and type ‘Control Panel’. Click on Control Panel in the search results.

Now click Programs and Turn Windows features on or off. Scroll down to find SMB 1.0/CIFS File Sharing Support and click the + expand icon to reveal its options. Place a check in the box marked SMB 1.0/CIFS Client. Click OK. This will enable Samba client support on your Windows 10 PC so it can access the Raspberry Pi.

We’ve got more information on how Samba works on The MagPi’s website.

Get the game

On your Windows PC or Mac, open a web browser, and visit the Blade Buster website. This is a homebrew video game designed by High Level Challenge for old NES systems. The developer’s website is in Japanese — just click BLADE BUSTER Download to save the ROM file to your Downloads folder.

Open a File Explorer (or Finder) window and locate the BB_20120301.zip file in your Downloads folder. Don’t unzip the file.

Click on Network and you’ll see a RETROPIE share. Open it and locate the roms folder. Double-click roms and you’ll see folders for many classic systems. Drag and drop the BB_20120301.zip file and place it inside the nes folder.

Play the game

Press the Start button on your gamepad to bring up the Main Menu. Choose Quit and Restart EmulationStation. You’ll now see a Nintendo Entertainment System option with 1 Games Available below it. Click it and you’ll see BB_20120301 — this is Blade Buster. Press A to start the game. Have fun shooting aliens. Press Start and Analog (or whatever you’ve set as your hotkey) together when you’re finished; this will take you back to the game selection in EmulationStation.

If you’ve been setting up RetroPie on your monitor, now is the time to move it across to your main television. The RetroPie console will boot automatically and connect to the network, and then you can move ROM files over to it from your PC or Mac. At this point, you may notice black borders around the screen; if so, see the Fix the borders tip.

Enjoy your gaming system!

More top tips from Lucy

Change the resolution

Some games were designed for a much lower resolution, and scaling them up can look blocky on modern televisions. If you’d prefer to alter the resolution, choose ‘RetroPie setup’. Open raspi-config, Advanced Options, and Resolution. Here you’ll find a range of other resolution options to choose from.

Fix the borders

These are caused by overscan. Choose RetroPie from EmulationStation and raspi-config. Now select Advanced Options > Overscan and select No on the ‘Would you like to enable compensation for displays with overscan?’ window. Choose OK and then Finish. Choose Yes on the Reboot Now window. When the system has rebooted, you will see the borders are gone.

The MagPi magazine issue 81

This article is from the latest issue of The MagPi magazine, which is out today and can be purchased online, at the Raspberry Pi Store, or from many newsagents and bookshops, such as WHSmith and Barnes & Noble.

The MagPi magazine issue 81

You can also download issue 81 for free from The MagPi website, where you’ll also find information on subscription options, and the complete MagPi catalogue, including Essentials guides and books, all available to download for free.

the MagPi subscription

The post Make a retro console with RetroPie and a Raspberry Pi — part 2 appeared first on Raspberry Pi.

Make a retro console with RetroPie and a Raspberry Pi — part 1

via Raspberry Pi

Discover classic gaming on the Raspberry Pi and play homebrew ROMs, with this two-part tutorial from The MagPi Editor Lucy Hattersley.

Raspberry Pi retro games console

Turning a Raspberry Pi device into a retro games console is a fun project, and it’s one of the first things many a new Pi owner turns their hand to.

The appeal is obvious. Retro games are fun, and from a programming perspective, they’re a lot easier to understand than modern 3D powerhouses. The Raspberry Pi board’s small form factor, low power usage, HDMI connection, and wireless networking make it a perfect micro-console that can sit under your television.

RetroPie

There are a bunch of different emulators around for Raspberry Pi. In this tutorial, we’re going to look at RetroPie.

RetroPie combines Raspbian, EmulationStation, and RetroArch into one handy image. With RetroPie you can emulate arcade games, as well as titles originally released on a host of 8-bit, 16-bit, and even 32- and 64-bit systems. You can hook up a joypad; we’re going to use the Wireless USB Game Controller, but most other USB game controllers will work.

You can also use Bluetooth to connect a controller from most video games consoles. RetroPie has an interface that will be very familiar to anyone who has used a modern games console, and because it is open-source, it is constantly being improved.

You can look online for classic games, but we prefer homebrew and modern releases coded for classic systems. In this tutorial, we will walk you through the process of setting up RetroPie, configuring a gamepad, and running a homebrew game called Blade Buster.

Get your microSD card ready

RetroPie is built on top of Raspbian (the operating system for Raspberry Pi). While it is possible to install RetroPie from the desktop interface, it’s far easier to format a microSD card† and copy a new RetroPie image to the blank card. This ensures all the settings are correct and makes setup much easier. Our favourite method of wiping microSD cards on a PC or Apple Mac is to use SD Memory Card Formatter.

Attach the microSD card to your Windows or Mac computer and open SD Card Formatter. Ensure the card is highlighted in the Select card section, then click Format.

Download RetroPie

Download the RetroPie image. It’ll be downloaded as a gzip file; the best way to expand this on Windows is using 7-Zip (7-zip.org).

With 7-Zip installed, right-click the retropie-4.4-rpi2_rpi3.img.gz file and choose 7-Zip > Extract here. Extract GZ files on a Mac or Linux PC using gunzip -k <filename.gz> (the -k option keeps the original GZ file).

gunzip -k retropie-4.4-rpi2_rpi3.img.gz

Flash the image

We’re going to use Etcher to copy the retropie-4.4-rpi2_rpi3.img file to our freshly formatted microSD card. Download Etcher. Open Etcher and click Select Image, then choose the retropie-4.4-rpi2_rpi3.img image file and click Open.

Etcher should have already located the microSD card; remove and replace it if you see a Select Drive button. Click Flash! to copy the RetroPie image to the microSD card.

See our guide for more information on how to use Etcher to flash SD cards.

Set up the Raspberry Pi

Insert the flashed microSD card to your Raspberry Pi. Now attach the Raspberry Pi to a TV or monitor using the HDMI cable. Connect the USB dongle from the Wireless USB Game Controller to the Raspberry Pi. Also attach a keyboard (you’ll need this for the setup process).

Insert the batteries in the Wireless USB Game Controller and set the power switch (on the back of the device) to On. Once everything is connected, attach a power supply to the Raspberry Pi.

See our quickstart guide for more detailed information on setting up a Raspberry Pi.

Configure the gamepad

When RetroPie starts, you should see Welcome screen displaying the message ‘1 gamepad detected’. Press and hold one of the buttons on the pad, and you will see the Configuring screen with a list of gamepad buttons and directions.

Tap the D-pad (the four-way directional control pad on the far left) up on the controller and ‘HAT 0 UP’ will appear. Now tap the D-pad down.
Map the A, B, X, Y buttons to:

A: red circle
B: blue cross
X: green triangle
Y: purple square

The Left and Right Shoulder buttons refer to the topmost buttons on the rear of the controller, while the Triggers are the larger lower buttons.

Push the left and right analogue sticks in for the Left and Right Thumbs. Click OK when you’re done.

Top tips from Lucy

Install Raspbian desktop

RetroPie is built on top of the Raspbian operating system. You might be tempted to install RetroPie on top of the Raspbian with Desktop interface, but it’s actually much easier to do it the other way around. Open RetroPie from EmulationStation and choose RetroPie setup. Select Configuration tools and Raspbian tools. Then choose Install Pixel desktop environment and Yes.

When it’s finished, choose Quit and Restart EmulationStation. When restarted, EmulationStation will display a Ports option. Select it and choose Desktop to boot into the Raspbian desktop interface.

Username and password

If RetroPie asks you for the username and password during boot, the defaults are pi and raspberry.

The MagPi magazine issue 81

The rest of this article can be found in the latest issue of The MagPi magazine, which is out now and can be purchased online, at the Raspberry Pi Store, or from many independent bookshops, such as WHSmith and Barnes & Noble. We’ll also post the second half on the blog tomorrow!

The MagPi magazine issue 81

You can also download issue 81 for free from The MagPi website, where you’ll find information on subscription options, and the complete MagPi catalogue, including Essentials guides and books, all available to download for free.

the MagPi subscription

The post Make a retro console with RetroPie and a Raspberry Pi — part 1 appeared first on Raspberry Pi.

Raspberry Pi underwater camera drone | The MagPi 80

via Raspberry Pi

Never let it be said that some makers won’t jump in at the deep end for their ambitious experiments with the Raspberry Pi. When Ievgenii Tkachenko fancied a challenge, he sought to go where few had gone before by creating an underwater drone, successfully producing a working prototype that he’s now hard at work refining.

Inspired by watching inventors on the Discovery Channel, Ievgenii has learned much from his endeavour. “For me it was a significant engineering challenge,” he says, and while he has ended up submerging himself within a process of trial-and-error, the results so far have been impressive.

Pi dive

The project began with a loose plan in Ievgenii’s head. “I knew what I should have in the project as a minimum: motions, lights, camera, and a gyroscope inside the device and smartphone control outside,” he explains. “Pretty simple, but I didn’t have a clue what equipment I would be able to use for the drone, and I was limited by finances.”

Bearing that in mind, one of his first moves was to choose a Raspberry Pi 3B, which he says was perfect for controlling the motors, diodes, and gyroscope while sending video streams from a camera and receiving commands from a control device.

The Raspberry Pi 3 sits in the housing and connects to a LiPo battery that also powers the LEDs and motors

“I was really surprised that this small board has a fully functional UNIX-based OS and that software like the Node.js server can be easily installed,” he tells us. “It has control input and output pins and there are a lot of libraries. With an Ethernet port and wireless LAN and a camera, it just felt plug-and-play. I couldn’t find a better solution.”

The LEDs are attached to radiators to prevent overheating, and a pulse driver is used for flashlight control

Working with a friend, Ievgenii sought to create suitable housing for the components, which included a twin twisted-pair wire suitable for transferring data underwater, an electric motor, an electronic speed control, an LED together with a pulse driver, and a battery. Four motors were attached to the outside of the housing, and efforts were made to ensure it was waterproof. Tests in a bath and out on a lake were conducted.

Streaming video

With a WiFi router on the shore connected to the Raspberry Pi via RJ45 connectors and an Ethernet cable, Ievgenii developed an Android application to connect to the Raspberry Pi by address and port (“as an Android developer, I’m used to working with the platform”). This also allowed movement to be controlled via the touchscreen, although he says a gamepad for Android can also be used. When it’s up and running, the Pi streams a video from the camera to the app — “live video streaming is not simple, and I spent a lot of time on the solution” — but the wired connection means the drone can only currently travel as far as the cable length allows.

The camera was placed in this transparent waterproof case attached to the front of the waterproof housing

In that sense, it’s not perfect. “It’s also hard to handle the drone, and it needs to be enhanced with an additional controls board and a few more electromotors for smooth movement,” Ievgenii admits. But as well as wanting to base the project on fast and reliable C++ code and make use of a USB 4K camera, he can see the future potential and he feels it will swim rather than sink.

“Similar drones are used for boat inspections, and they can also be used by rescue squads or for scientific purposes,” he points out. “They can be used to discover a vast marine world without training and risks too. In fact, now that I understand the Raspberry Pi, I know I can create almost anything, from a radio electronic toy car to a smart home.”

The MagPi magazine

This article was lovingly borrowed from the latest issue of The MagPi magazine. Pick up your copy of issue 80 from your local stockist, online, or by downloading the free PDF.

Subscribers to The MagPi also get a rather delightful subscription gift!

The post Raspberry Pi underwater camera drone | The MagPi 80 appeared first on Raspberry Pi.