Raspberry Pi Blog

This is the official Raspberry Pi blog for news and updates from the Raspberry Pi Foundation, education initiatives, community projects and more!

Connect your Raspberry Pi 4 to an iPad Pro

Have you ever considered attaching your Raspberry Pi 4 to an Apple iPad Pro? How would you do it, and why would you want to? Here’s YouTuber Tech Craft to explain why Raspberry Pi 4 is their favourite iPad Pro accessory, and why you may want to consider using yours in the same way.

We’ve set the video to start at Tech Craft’s explanation.

My Favourite iPad Pro Accessory: The Raspberry Pi 4

The Raspberry Pi 4 is my favourite accessory to use with the iPad Pro. In this video, learn more about what the Pi can do, what gear you need to get running with one, how to connect it to your iPad and what you’ll find it useful for.

 

Having installed Raspbian on Raspberry Pi and configured the computer to use USB-C as an Ethernet connection (read Ben Hardill’s guide to find out how to do this), Tech Craft could select it as an Ethernet device in the iPad’s Settings menu.

So why would you want to connect your Raspberry Pi 4 to your iPad? For starters, using your iPad instead of a conventional HDMI monitor will free up desk space, and also allow you to edit your code on the move. And when you’ve connected the two devices like this, you don’t need a separate power lead for Raspberry Pi, because the iPad powers the computer. So this setup is perfect for train or plane journeys, or for that moment when your robot stops working at a Raspberry Jam, or for maker conventions.

You can also use Raspberry Pi as a bridge between your iPad and portable hard drive, for disk management.

Tech Craft uses the SSH client Blink to easily connect to their Raspberry Pi via its fixed IP address, and with Juno Connect, they connect to a running Jupyter instance on their Raspberry Pi to do data science work.

For more information on using Raspberry Pi with an iPad, make sure you watch the whole video. And, because you’re a lovely person, be sure to subscribe to Tech Craft for more videos, such as this one on how to connect wirelessly to your Raspberry Pi from any computer or tablet:

Mobile Raspberry Pi with ANY iPad. No USB-C needed.

Following on my from earlier video about pairing the Raspberry Pi 4 with the iPad Pro over USB-C, this video show how to pair any iPad (or iPhone, or Android tablet) with a Pi4 or a Pi3 over WiFi.

11 Comments

Fake cases — make sure yours is the real deal

We’ve had some reports of people finding cases that pretend to be official Raspberry Pi products online — these are fakes, they’re violating our trademark, they’re not made very well, and they’re costing you and us money that would otherwise go to fund the Raspberry Pi Foundation’s charitable work. (Reminder, for those who are new to this stuff: we’re a not-for-profit, which means that every penny we makes goes to support our work in education, and that none of us gets to own a yacht.)

Making sure your accessories are legit

If you want to be certain that the Raspberry Pi accessories you buy are the real thing, make sure you’re purchasing from one of our Authorised Resellers: if you buy via our website, you’ll automatically be directed to the Authorised Resellers in your region. Lots of other vendors also sell the official case, so if you’re wondering whether yours is the real thing, we’ve found there are some easy ways to tell the difference.

A wellwisher sent us one of the fake cases (elegantly photographed by Fiacre above), which we passed around the office with a great deal of wincing, imagining what you guys might say if you got your hands on one and thought we’d made it. They’re really not very nice; the moulding’s awful, the fit’s bad, the colour’s off, and we’d be embarrassed if we had made something like this ourselves.

Asking the experts

We thought we’d ask the good people at T-Zero, who did all the work on the tooling and injection moulding for the real case (which is a considerably harder job than we’d imagined at first — you can read about the very bumpy road we had before finding T-Zero, who are amazing partners, in this post from days of yore), why the fake cases look so hideous. Simon Oliver, Grand Poobah of Plastics, wrote back:

Basically, what you are witnessing is very cheaply and quickly made tooling. The flash is just poor toolmaking. The rounded edges are due to the toolmaking method of milling everything, which is quick and cheap, but you can’t get definition of sharp corners because you have to have a radius in places. I have tried to explain it below, and you have to think in reverse for the tool.

Milling artifacts

Can you imagine how many electrodes are needed for the logo? The leaves around the top have to be laser-cut into an electrode to get the definition. See screen grabs of the tool and moulding — look how many sharp corners there are!

CAD representations of logo and tool

To properly make a tool for something this complicated, you need more electrodes than someone quickly copying a case like this would find economical. The official Raspberry Pi case needed 140 electrodes to produce the tool.

Electrodes

A few of the electrodes that went to make the injection moulding tool for the official case

 

Reverse-engineering by digitising existing components in a CAD will also loose definition, particularly in sharp corners, as the moulding process will form a small radius even if the tool is a sharp corner.

Plastic shrinks away from a 90 degree corner, leaving a smallish radius in any case. So your data from digitising will have a radius, and then [the producers] compound it by milling the lot.

Finally, the colour is off! It took ages to get your Raspberry Pi red correct. A lot of suppliers can’t repeat it; the current supplier had five attempts!

Thanks, Simon; and to everybody reading this, we hope it arms you with the confidence to make sure you’re buying a genuine product!

FYI

Before panic ensues, please note: we love third-party cases designed for Raspberry Pi. So much so that we sell a few of them in our store here in Cambridge.

The internet is full of innovative cases you can purchase, as well as wonderful 3D-printable alternatives you can make yourself, and as long as they aren’t breaking any trademark rules — using our logo, copying the work of others, pretending to be official when they’re not — that’s great!

If you’ve designed a case for any of the Raspberry Pi models, share it with us in the comments below, as we’d love to see your work. And if you see a case, or any other Raspberry Pi accessory, for sale that you think is breaking trademark rules or attempting to imitate our official products, please let us know.

37 Comments

Code a Boulder Dash mining game | Wireframe #30

Learn how to code a simple Boulder Dash homage in Python and Pygame. Mark Vanstone shows you how. 

The original Boulder Dash was marked out by some devious level design, which threatened to squash the player at every turn.

Boulder Dash

Boulder Dash first appeared in 1984 for the Commodore 64, Apple II, and the Atari 400/800. It featured an energetic gem collector called Rockford who, thanks to some rather low-resolution graphics, looked a bit like an alien. His mission was to tunnel his way through a series of caves to find gems while avoiding falling rocks dislodged by his digging. Deadly creatures also inhabited the caves which, if destroyed by dropping rocks on them, turned into gems for Rockford to collect.

The ingenious level designs were what made Boulder Dash so addictive. Gems had to be collected within a time limit to unlock the exit, but some were positioned in places that would need planning to get to, often using the physics of falling boulders to block or clear areas. Of course, the puzzles got increasingly tough as the levels progressed.

Written by Peter Liepa and Chris Gray, Boulder Dash was published by First Star Software, which still puts out new versions of the game to this day. Due to its original success, Boulder Dash was ported to all kinds of platforms, and the years since have seen no fewer than 20 new iterations of Boulder Dash, and a fair few clones, too.

Our homage to Boulder Dash running in Pygame Zero. Dig through the caves to find gems – while avoiding death from above.

Making Boulder Dash in Python

We’re going to have a look at the boulder physics aspect of the game, and make a simple level where Rockford can dig out some gems and hopefully not get flattened under an avalanche of rocks. Writing our code in Pygame Zero, we’ll automatically create an 800 by 600-size window to work with. We can make our game screen by defining a two-dimensional list, which, in this case, we will fill with soil squares and randomly position the rocks and gems.

Each location in the list matrix will have a name: either wall for the outside boundary, soil for the diggable stuff, rock for a round, moveable boulder, gem for a collectable item, and finally, rockford to symbolise our hero. We can also define an Actor for Rockford, as this will make things like switching images and tracking other properties easier.

Here’s Mark’s code, which gets an homage to Boulder Dash running in Python. To get it working on your system, you’ll first need to install Pygame Zero. And to download the full code, go here.

Our draw() function is just a nested loop to iterate through the list matrix and blit to the screen whatever is indicated in each square. The Rockford Actor is then drawn over the top. We can also keep a count of how many gems have been collected and provide a congratulatory message if all of them are found. In the update() function, there are only two things we really need to worry about: the first being to check for keypresses from the player and move Rockford accordingly, and the second to check rocks to see if they need to move.

Rockford is quite easy to test for movement, as he can only move onto an empty square – a soil square or a gem square. It’s also possible for him to push a boulder if there’s an empty space on the other side. For the boulders, we need to first test if there’s an empty space below it, and if so, the boulder must move downwards. We also test to see if a boulder is on top of another boulder – if it is, the top boulder can roll off and down onto a space either to the left or the right of the one beneath.
There’s not much to add to this snippet of code to turn it into a playable game of Boulder Dash. See if you can add a timer, some monsters, and, of course, some puzzles for players to solve on each level.

Testing for movement

An important thing to notice about the process of scanning through the list matrix to test for boulder movement is that we need to read the list from the bottom upwards; otherwise, because the boulders move downwards, we may end up testing a boulder multiple times if we test from the beginning to the end of the list. Similarly, if we read the list matrix from the top down, we may end up moving a boulder down and then when reading the next row, coming across the same one again, and moving it a second time.

Get your copy of Wireframe issue 30

You can read more features like this one in Wireframe issue 30, available now at Tesco, WHSmith, all good independent UK newsagents, and the Raspberry Pi Store, Cambridge.

Or you can buy Wireframe directly from Raspberry Pi Press — delivery is available worldwide. And if you’d like a handy digital version of the magazine, you can also download issue 30 for free in PDF format.

Make sure to follow Wireframe on Twitter and Facebook for updates and exclusive offers and giveaways. Subscribe on the Wireframe website to save up to 49% compared to newsstand pricing!

2 Comments

Protect your veggies from hail with a Raspberry Pi Zero W

Tired of losing vegetable crops to frequent summertime hail storms, Nick Rogness decided to build something to protect them. And the result is brilliant!

Digital Garden with hail protection

Tired of getting your garden destroyed by hail storms? I was, so I did something about it…maker style!

“I live in a part of the country where hail and severe weather are commonplace during the summer months,” Nick explains in his Hackster tutorial. “I was getting frustrated every year when my wife’s garden was get demolished by the nightly hail storms losing our entire haul of vegetable goodies!”

Nick drew up plans for a solution to his hail problem, incorporating liner actuators bolted to a 12ft × 12ft frame that surrounds the vegetable patch. When a storm is on the horizon, the actuators pull a heavy-duty tarp over the garden.

Nick connected two motor controllers to a Raspberry Pi Zero W. The Raspberry Pi then controls the actuators to pull the tarp, either when a manual rocker switch is flipped or when it’s told to do so via weather-controlled software.

“Software control of the garden was accomplished by using a Raspberry Pi and MQTT to communicate via Adafruit IO to reach the mobile app on my phone,” Nick explains. The whole build is powered by a 12V Marine deep-cycle battery that’s charged using a solar panel.

You can view the full tutorial on Hackster, including the code for the project.

3 Comments

Can algorithms be unethical?

At Raspberry Pi, we’re interested in all things to do with technology, from building new tools and helping people teach computing, to researching how young people learn to create with technology and thinking about the role tech plays in our lives and society. One of the aspects of technology I myself have been thinking about recently is algorithms.

An illustration of a desktop computer above which 5 icons are shown for privacy, culture, law, environment, and ethics

Technology impacts our lives at the level of privacy, culture, law, environment, and ethics.

All kinds of algorithms — set series of repeatable steps that computers follow to perform a task — are running in the background of our lives. Some we recognise and interact with every day, such as online search engines or navigation systems; others operate unseen and are rarely directly experienced. We let algorithms make decisions that impact our lives in both large and small ways. As such, I think we need to consider the ethics behind them.

We need to talk about ethics

Ethics are rules of conduct that are recognised as acceptable or good by society. It’s easier to discuss the ethics of a specific algorithm than to talk about ethics of algorithms as a whole. Nevertheless, it is important that we have these conversations, especially because people often see computers as ‘magic boxes’: you push a button and something magically comes out of the box, without any possibility of human influence over what that output is. This view puts power solely in the hands of the creators of the computing technology you’re using, and it isn’t guaranteed that these people have your best interests at heart or are motivated to behave ethically when designing the technology.

An icon with the word 'stakeholders' below it

Who creates the algorithms you use, and what are their motivations?

You should be critical of the output algorithms deliver to you, and if you have questions about possible flaws in an algorithm, you should not discount these as mere worries. Such questions could include:

  • Algorithms that make decisions have to use data to inform their choices. Are the data sets they use to make these decisions ethical and reliable?
  • Running an algorithm time and time again means applying the same approach time and time again. When dealing with societal problems, is there a single approach that will work successfully every time?

Below, I give two concrete examples to show where ethics come into the creation and use of algorithms. If you know other examples (or counter-examples, feel free to disagree with me), please share them in the comments.

Algorithms can be biased

Part of the ‘magic box’ mental model is the idea that computers are cold instructions followers that cannot think for themselves — so how can they be biased?

Humans aren’t born biased: we learn biases alongside everything else, as we watch the way our family and other people close to us interact with the world. Algorithms acquire biases in the same way: the developers who create them might inadvertently add their own biases.

An illustration of four people using smartphones

Humans can be biased, and therefore the algorithms they create can be biased too.

An example of this is a gang violence data analysis tool that the Met Police in London launched in 2012. Called the gang matrix, the tool held the personal information of over 300 individuals. 72% of the individuals on the matrix were non-white, and some had never committed a violent crime. In response to this, Amnesty International filed a complaint stating that the makeup of the gang matrix was influenced by police officers disproportionately labelling crimes committed by non-white individuals as gang-related.

Who curates the content we consume?

We live in a content-rich society: there is much, much more online content than one person could possibly take in. Almost every piece of content we consume is selected by algorithms; the music you listen to, the videos you watch, the articles you read, and even the products you buy.

An illustration of a phone screen showing an invented tweet asking where people get their news from

Some of you may have experienced a week in January of 2012 in which you saw a lot of either cute kittens or sad images on Facebook; if so, you may have been involved in a global social experiment that Facebook engineers performed on 600,000 of its users without their consent. Some of these users were shown overwhelmingly positive content, and others overwhelmingly negative content. The Facebook engineers monitored the users’ actions to gage how they responded. Was this experiment ethical?

In order to select content that is attractive to you, content algorithms observe the choices you make and the content you consume. The most effective algorithms give you more of the same content, with slight variation. How does this impact our beliefs and views? How do we broaden our horizons?

Why trust algorithms at all then?

People generally don’t like making decisions; almost everyone knows the discomfort of indecision. In addition, emotions have a huge effect on the decisions humans make moment to moment. Algorithms on the other hand aren’t impacted by emotions, and they can’t be indecisive.

While algorithms are not immune to bias, in general they are way less susceptible to it than humans. And if a bias is identified in an algorithm, an engineer can remove the bias by editing the algorithm or changing the dataset the algorithm uses. The same cannot be said for human biases, which are often deeply ingrained and widespread in society.

An icon showing a phone screen with an internet browser symbol

As is true for all technology, algorithms can create new problems as well as solve existing problems.

That’s why there are more and less appropriate areas for algorithms to operate in. For example, using algorithms in policing is almost always a bad idea, as the data involved is recorded by humans and is very subjective. In objective, data-driven fields, on the other hand, algorithms have been employed very successfully, such as diagnostic algorithms in medicine.

Algorithms in your life

I would love to hear what you think: this conversation requires as many views as possible to be productive. Share your thoughts on the topic in the comments! Here are some more questions to get you thinking:

  • What algorithms do you interact with every day?
  • How large are the decisions you allow algorithms to make?
  • Are there algorithms you absolutely do not trust?
  • What do you think would happen if we let algorithms decide everything?

Feel free to respond to other people’s comments and discuss the points they raise.

The ethics of algorithms is one of the topics for which we offer you a discussion forum on our free online course Impact of Technology. The course also covers how to facilitate classroom discussions about technology — if you’re an educator teaching computing or computer science, it is a great resource for you!

The Impact of Technology online course is one of many courses developed by us with support from Google.

19 Comments

How to control multiple servo motors with Raspberry Pi

In the latest Explaining Computers video, Christopher Barnatt explains how to use servo motors with Raspberry Pi. Using servos is a great introduction to the digital making side of computing; servos allow you to control the movement of all manner of project components with your Raspberry Pi and a motor controller attached to its GPIO pins.

Raspberry Pi Servo Motor Control

Control of SG90 servos in Python on a Raspberry Pi, including an explanation of PWM and how a servo differs from a motor. You can download the code from the video at: https://www.explainingcomputers.com/pi_servos_video.html The five-pack of SG90 servos used in this video was purchased on Amazon.co.uk here: https://www.amazon.co.uk/dp/B07H9VC698/ref=nosim?tag=explainin-21 with a similar product on Amazon.com here: https://amzn.to/2QHshx3 (affiliate links).

Servos and your Raspberry Pi

Christopher picked up his SG90 servo motors online, where you’ll find a variety of servo options. What type of servo you need depends on the project you want to create, so be sure to consider the weight and size of what you plan to move, and the speed at which you need to move it.

As the motor controller connects via GPIO, you can even use the tiny £5 Raspberry Pi Zero to control your servo, which makes adding movement to your projects an option even when you’re under tight space constraints.

Find out more

For other detailed computing videos, be sure to subscribe to the Explaining Computers YouTube channel.

And for more Raspberry Pi projects, check out the Raspberry Pi projects page.

Raspberry Pi projects PSA

We’re always looking for people to join our incredible community of translators to help us translate our free resources, including the free projects found on our projects page.

If you speak English and another language and would like to give a portion of your time to making our resources available to more people across the globe, sign up as a translator today.

No Comments

Playing The Doors with a door (and a Raspberry Pi)

Floyd Steinberg is back with more synthy Raspberry Pi musical magic, this time turning a door into a MIDI controller.

I played The Doors on a door – using a Raspberry PI DIY midi controller and a Yamaha EX5

You see that door? You secretly want that to be a MIDI controller? Here’s how to do it, and how to play a cover version of “Break On Through” by The Doors on a door ;-) Link to source code and the DIY kit below.

If you don’t live in a home with squeaky doors — living room door, I’m looking at you — you probably never think about the musical potential of mundane household objects.

Unless you’re these two, I guess:

When Mama Isn’t Home / When Mom Isn’t Home ORIGINAL (the Oven Kid) Timmy Trumpet – Freaks

We thought this was hilarious. Hope you enjoy! This video has over 60 million views worldwide! Social Media: @jessconte To use this video in a commercial player, advertising or in broadcasts, please email [email protected]

If the sound of a slammed oven door isn’t involved in your ditty of choice, you may instead want to add some electronics to that sweet, sweet harmony maker, just like Floyd.

Trusting in the melodic possibilities of incorporating a Raspberry Pi 3B+ and various sensory components into a humble door, Floyd created The Doors Door, a musical door that plays… well, I’m sure you can guess.

If you want to build your own, you can practice some sophisticated ‘copy and paste’ programming after downloading the code. And for links to all the kit you need, check out the description of the video over on YouTube. While you’re there, be sure to give the video a like, and subscribe to Floyd’s channel.

And now, to get you pumped for the weekend, here’s Jim:

The Doors – Break On Through HQ (1967)

recorded fall 1966 – lyrics: You know the day destroys the night Night divides the day Tried to run Tried to hide Break on through to the other side Break on through to the other side Break on through to the other side, yeah We chased our pleasures here Dug our treasures there But can you still recall The time we cried Break on through to the other side Break on through to the other side Yeah!

2 Comments

Come to our free educator sessions next to Bett 2020

Are you attending Bett Show this year? Then come to our free educator sessions on Friday 24 January right next to Bett to take a break from the hustle and bustle of the show floor and learn something new!

Our team will be in a private room below the [email protected] pub, next door to Bett, all day on Friday 24 January. We’ll be offering free physical computing sessions for primary and secondary educators during the day. Then from 17:30, you can drop in to chat to us about computing in your classroom, and to connect with like-minded educators.

A teacher attending a physical computing sessions laughs as she works through an activity

Our schedule for you on 24 January

11:00–12:30: Physical computing session for primary teachers (limited spaces, please register to attend)

12:45–13:30: Panel and Q&A for primary teachers: Code Club and the National Centre of Computing Education (drop in without registering)

14:30–16:00: Physical computing session for secondary teachers (limited spaces, please register to attend)

16:15–17:00: Panel and Q&A for secondary teachers: Code Club and the National Centre of Computing Education (drop in without registering)

17:30–21:00: Informal meet and greet with the Raspberry Pi team for everyone (drop in without registering)

  • Snacks and refreshments will be provided at all the sessions
  • Directions to the [email protected] pub, where you’ll find us, are below
  • You don’t need to have a pass to Bett Show to attend any of our sessions

What are these physical computing sessions?

In these free, registration-only, practical sessions (tailored to primary and secondary educators, respectively), we’ll highlight the value of delivering curriculum objectives through physical computing activities.

You’ll learn about:

  • Setting up a Raspberry Pi computer
  • Controlling LEDs using Scratch, Python, and Raspberry Pi
  • Pedagogical approaches such as pair programming and Parson’s Puzzles

Women using Raspberry Pi and Trinket

The sessions are perfect for you if you’d like an introduction to how to bring physical computing to your classroom, because no experience of physical computing is needed.

Both sessions are free and open to all teachers and educators working with learners in the relevant Key Stages.

Spaces are limited for both sessions, so make sure you register to reserve your space:

Find out how to bring more computing opportunities to your school

Following each of the physical computing sessions, you’ll have the chance to find out how else we can help you bring computing to your school! During a 45-minute panel and Q&A, our team will introduce you all things Code Club and how to set up an engaging coding club in your school, and to the comprehensive, free support we offer you through the National Centre of Computing Education. You’ll also be able to ask us any questions you have about the programmes and resources we offer to you.

There is no need to register for this ‘panel and Q&A’ part of the day — just drop in when it suits you.

Network with us and other educators

Your evening at [email protected], from 17:30 onwards, will be an informal meet and greet with the Raspberry Pi team. Snacks and refreshments will be provided, and you can drop in whenever you like.

This is your time to chat to us, discover more about the other educational activities we run, and network with other primary and secondary educators who want to encourage children and young adults to get hands-on with computing.

Code Club

We hope to see many of you there, and we’re looking forward to chatting with you!

If you have any questions about this event, or want to find out more, please contact [email protected] and we will get back to you!

How to find us

The [email protected] is a pub located in Warehouse K next to the ExCel Center, easily accessed from the footpath between the ExCel West Entrance and Custom House DLR Station.

Map of where the Fox@ExCel London is

You will find us in a private area below the main floor of the [email protected]. There should be a sign directing you to the location, and you can also ask the pub staff to point the way.

From Custom House DLR Station:

Follow the signs along the footbridge towards the ExCel main entrance, enter the door labelled ‘[email protected]’ on the first building to your right, and head down the stairs.

From the ExCel West Entrance:

Turn right out of the main entrance and follow the footbridge towards the ExCel. You will find the entrance to the [email protected] in the second pair of doorways on your left. Enter the building and go down the stairs.

No Comments

Design 3D prints with a Raspberry Pi and BlocksCAD

BlocksCAD is a 3D model editor that you use in a web browser, and it runs on Raspberry Pi. You drag and drop code blocks to design 3D models that can be exported for 3D printing.

In this project, you will use BlocksCAD to design a 3D pendant. The pendant uses a geometric pattern based on ‘the flower of life’, a design which is often found in historical art.

The finished pendant with a cord threaded through the small hanging hoop

If you have access to a 3D printer, then you can print your pendant. The pendant is small and only uses a little bit of filament. There’s a hoop on top of the pendant so that you can put it on a necklace or cord. The pendant has a diameter of 40 mm, plus the hoop for hanging. It is 2 mm thick, so it will 3D-print quite quickly.

After this project, you’ll also be able to code your own design and create a custom pendant.

Step 01: create a hoop

This project can be completed in a web browser using BlocksCAD. Open Chromium and enter the BlocksCAD editor URL: blockscad3d.com/editor.

The design uses six interlocking hoops in the centre, and a larger hoop around the outside. As mentioned, the pendant is 40 mm wide, plus the hoop for hanging, which is 2 mm thick.

Click 3D Shapes and drag a cylinder block to the project. Create a cylinder with a radius of 12, and a height of 2 (the unit here is millimetres). Cylinders are automatically centred along the X and Y axes. Select not centered so that the pendant sits on the surface. (This means that the Z-axis value is greater than 0.)

Click on the Render button after each change to your code to see the results.

Step 02: add more hoops

Now, drag a difference block from Set Ops to encase the cylinder. Add another cylinder block in the bottom space, and this time give it a radius of 11 mm. This will remove a smaller cylinder from the centre. This creates a hoop. Click Render again to see it.

If you like, you can click on the coloured square to change the colour used in the viewer. This does not affect the colour of your pendant, as that depends on the colour of the filament that you use.

The design uses six intersecting hoops, and each hoop is moved out from the centre and rotated a different number of degrees.

In the final design, there is no central hoop: the hoops are all moved out from the centre.

Drag a translate block (from Transforms) around your code, and set X and Y to 5. This moves the first hoop into position.

Step 03: centre the hoop

Now the hoop is a little off-centre. You need multiple copies of this hoop, rotated around the centre. First, create three equally spaced hoops.

Add a count Loops block to create three hoops. To space the hoops, add a rotate Transforms block between the count loop and the translate block.

In the count block, set the i variable from 1 to 3. You’ll need to insert an arithmetic block from Math and a variable (i) block from Variables into the Z field of the rotate block.

The rotation moves each hoop by 120 × i degrees, so that the three hoops are distributed equally around the 360 degrees of a circle (360 / 3 = 120). Look at the code and make sure you understand how it works. The finished design has six hoops rather than three. In the count block, set i from 1 to 6, and set the Z rotation to 60, so it creates six equally spaced hoops.

Step 04: add a border

Next, add a border around the edge of the design. Create a centred hoop that touches the edges of the design. You can either do the maths to work out what the radius of the circle needs to be, or you can just create a circle and change the radius until it works. Either approach is fine!

Encase your code with a union block from Set Ops, to join the border to the other hoops. Add a difference block to the plus section of union, and two cylinder blocks to make the hoop.

The six hoops each have a radius of 12 mm, so the border cylinder that you are making needs to be bigger than that. You could try setting the radius to 24 mm.

To make a hoop, the radius of the second cylinder in the difference block needs to be 1 mm smaller than the radius of the first cylinder.

Adjust the size of the cylinders until the border hoop just touches the outer edges of the six inner hoops.

The radius should be around 20 mm. (As mentioned in the introduction, the finished pendant will be 40 mm in diameter.)

Step 05: work it out

You could also use maths to work out the diameter. The diameter of each inner hoop is 24 mm. If the hoops met at the centre of the pendant, the border hoop would need to have a radius of 24 mm. But the inner hoops overlap, as they are translated 5 mm along the X and Y axes.

This removes a section from the radius. This section is on the arc, 5 mm from the origin, so we need to remove 5 mm from 24 mm. Thus the inner radius of the border hoop should be 19 mm.

Maths is really useful when you need to be accurate. But it’s fine to just change things until you get the result you need.

Step 06: add a hanging hoop

Now, add a small hanging hoop through which you can thread a cord to make a necklace.

Click the [+] on the union block to add another section to add the new hoop.

At the moment, the position of the hanging hoop isn’t very visually pleasing.

Add a rotate block to move the inner hoops so that the hanging hoop is centred over one of the gaps between them.

Step 07: experiment with shapes

Experiment and change some values in your pendant. For example, change the number of hoops, or the rotation.

You could also try to use cuboids (cubes) instead of cylinders to create a pattern.

Step 08: export to STL

BlocksCAD 3D can export an STL file for 3D printing. Render your model and then click on Generate STL. Remember where you save the STL file. Now 3D-print your pendant using a filament of the colour of your choice. Very carefully remove the 3D print from the print bed. The pendant is thin, so it’s quite delicate.

You might need to remove small strands of filament (especially from the hanging hoop) to tidy up the print.

Thread the pendant on to a chain or cord. If you want to use a thicker cord or necklace, then you can adjust the design to have a larger hanging hoop.

Check your code

You can download the full code and check it against your own. You can also check out our projects page, where you’ll find more images and step-by-step instructions for using BlocksCAD.

This project was created by Dr Tracy Gardner and the above article was featured in this month’s issue of The MagPi magazine. Get your copy of The MagPi magazine issue 89 today from your local newsagent, the Raspberry Pi Store, Cambridge, or online from Raspberry Pi Press.

5 Comments

How to set up OctoPrint on your Raspberry Pi

If you own a 3D printer, you’ll likely have at least heard of OctoPrint, created by Gina Häußge and maintained by her and Guy Sheffer! OctoPrint has the potential to transform your 3D printing workflow for the better, and it’s very easy to set up. This guide will take you through the setup process step by step, and give you some handy tips along the way.

Octoprint

Before we start finding out how to install OctoPrint, let’s look at why you might want to. OctoPrint is a piece of open-source software that allows us to add WiFi functionality to any 3D printer with a USB port (which is pretty much all of them). More specifically, you’ll be able to drop files from your computer onto your printer, start/stop prints, monitor your printer via a live video feed, control the motors, control the temperature, and more, all from your web browser. Of course, with great power comes great responsibility — 3D printers have parts that are hot enough to cause fires, so make sure you have a safe setup, which may include not letting it run unsupervised.

OctoPrint ingredients

• Raspberry Pi 3 (or newer)
MicroSD card
• Raspberry Pi power adapter
• USB cable (the connector type will depend on your printer)
• Webcam/Raspberry Pi Camera Module (optional)
• 3D-printed camera mount (optional)

Before we get started, it is not recommended that anything less than a Raspberry Pi 3 is used for this project. There have been reports of limited success using OctoPrint on a Raspberry Pi Zero W, but only if you have no intention of using a camera to monitor your prints. If you want to try this with a Pi Zero or an older Raspberry Pi, you may experience unexpected print failures.

Download OctoPi

Firstly, you will need to download the latest version of OctoPi from the OctoPrint website. OctoPi (created by Guy Sheffer) is a Raspbian distribution that comes with OctoPrint, video streaming software, and CuraEngine for slicing models on your Raspberry Pi. When this has finished downloading, unzip the file and put the resulting IMG file somewhere handy.

Next, we need to flash this image onto our microSD card. We recommend using Etcher to do this, due to its minimal UI and ease of use; plus it’s also available to use on both Windows and Mac. Get it here: balena.io/etcher. When Etcher is installed and running, you’ll see the UI displayed. Simply click the Select Image button and find the IMG file you unzipped earlier. Next, put your microSD card into your computer and select it in the middle column of the Etcher interface.

Finally, click on Flash!, and while the image is being burned onto the card, get your WiFi router details, as you’ll need them for the next step.

Now that you have your operating system, you’ll want to add your WiFi details so that the Raspberry Pi can automatically connect to your network after it’s booted. To do this, remove the microSD card from your computer (Etcher will have ‘ejected’ the card after it has finished burning the image onto it) and then plug it back in again. Navigate to the microSD card on your computer — it should now be called boot — and open the file called octopi-wpa-supplicant.txt. Editing this file using WordPad or TextEdit can cause formatting issues; we recommend using Notepad++ to update this file, but there are instructions within the file itself to mitigate formatting issues if you do choose to use another text editor. Find the section that begins ## WPA/WPA2 secured and remove the hash signs from the four lines below this one to uncomment them. Finally, replace the SSID value and the PSK value with the name and password for your WiFi network, respectively (keeping the quotation marks). See the example below for how this should look.

Further down in the file, there is a section for what country you are in. If you are using OctoPrint in the UK, leave this as is (by default, the UK is selected). However, if you wish to change this, simply comment the UK line again by adding a # before it, and uncomment whichever country you are setting up OctoPrint in. The example below shows how the file will look if you are setting this up for use in the US:

# Uncomment the country your Pi is in to activate Wifi in RaspberryPi 3 B+ and above
# For full list see: https://en.wikipedia.org/ wiki/ISO_3166-1_alpha-2
#country=GB # United Kingdom
#country=CA # Canada
#country=DE # Germany
#country=FR # France
country=US # United States

When the changes have been made, save the file and then eject/unmount and remove the microSD card from your computer and put it into your Raspberry Pi. Plug the power supply in, and go and make a cup of tea while it boots up for the first time (this may take around ten minutes). Make sure the Raspberry Pi is running as expected (i.e. check that the green status LED is flashing intermittently). If you’re using macOS, visit octopi.local in your browser of choice. If you’re using Windows, you can find OctoPrint by clicking on the Network tab in the sidebar. It should be called OctoPrint instance on octopi – double-clicking on this will open the OctoPrint dashboard in your browser.

If you see the screen shown above, then congratulations! You have set up OctoPrint.

Not seeing that OctoPrint splash screen? Fear not, you are not the first. While a full list of issues is beyond the scope of this article, common issues include: double-checking your WiFi details are entered correctly in the octopi-wpa-supplicant.txt file, ensuring your Raspberry Pi is working correctly (plug the Raspberry Pi into a monitor and watch what happens during boot), or your Raspberry Pi may be out of range of your WiFi router. There’s a detailed list of troubleshooting suggestions on the OctoPrint website.

Printing with OctoPrint

We now have the opportunity to set up OctoPrint for our printer using the handy wizard. Most of this is very straightforward — setting up a password, signing up to send anonymous usage stats, etc. — but there are a few sections which require a little more thought.

We recommend enabling the connectivity check and the plug-ins blacklist to help keep things nice and stable. If you plan on using OctoPrint as your slicer as well as a monitoring tool, then you can use this step to import a Cura profile. However, we recommend skipping this step as it’s much quicker (and you can use a slicer of your choice) to slice the model on your computer, and then send the finished G-code over.

Finally, we need to put in our printer details. Above, we’ve included some of the specs of the Creality Ender-3 as an example. If you can’t find the exact details of your printer, a quick web search should show what you need for this section.

The General tab can have anything in it, it’s just an identifier for your own use. Print bed & build volume should be easy to find out — if not, you can measure your print bed and find out the position of the origin by looking at your Cura printer profile. Leave Axes as default; for the Hotend and extruder section, defaults are almost certainly fine here (unless you’ve changed your nozzle; 0.4 is the default diameter for most consumer printers).

OctoPrint is better with a camera

Now that you’re set up with OctoPrint, you’re ready to start printing. Turn off your Raspberry Pi, then plug it into your 3D printer. After it has booted up, open OctoPrint again in your browser and take your newly WiFi-enabled printer for a spin by clicking the Connect button. After it has connected, you’ll be able to set the hot end and bed temperature, then watch as the real-time readings are updated.

In the Control tab, we can see the camera stream (if you’re using one) and the motor controls, as well as commands to home the axes. There’s a G-code file viewer to look through a cross-section of the currently loaded model, and a terminal to send custom G-code commands to your printer. The last tab is for making time-lapses; however, there is a plug-in available to help with this process.

Undoubtedly the easiest way to set up video monitoring of your prints is to use the official Raspberry Pi Camera Module. There are dozens of awesome mounts on Thingiverse for a Raspberry Pi Camera Module, to allow you to get the best angle of your models as they print. There are also some awesome OctoPrint-themed Raspberry Pi cases to house your new printer brains. While it isn’t officially supported by OctoPrint, you can use a USB webcam instead if you have one handy, or just want some very high-quality video streams. The OctoPrint wiki has a crowdsourced list of webcams known to work, as well as a link for the extra steps needed to get the webcam working correctly.

As mentioned earlier, our recommended way of printing a model using OctoPrint is to first use your slicer as you would if you were creating a file to save to a microSD card. Once you have the file, save it somewhere handy on your computer, and open the OctoPrint interface. In the bottom left of the screen, you will see the Upload File button — click this and upload the G-code you wish to print.

You’ll see the file/print details appear, including information on how long it’ll take for the object to print. Before you kick things off, check out the G-code Viewer tab on the right. You can not only scroll through the layers of the object, but, using the slider at the bottom, you can see the exact pattern the 3D printer will use to ‘draw’ each layer. Now click Print and watch your printer jump into action!

OctoPrint has scores of community-created plug-ins, but our favourite, Octolapse, makes beautiful hypnotic time-lapses. What makes them so special is that the plug-in alters the G-code of whatever object you are printing so that once each layer has finished, the extruder moves away from the print to let the camera take an unobstructed shot of the model. The result is an object that seems to grow out of the build plate as if by magic. You’ll not find a finer example of it than here.

Satisfying 3D Prints TimeLapse episode 7 (Prusa I3 Mk3 octopi)

3D Printing timelapses of models printed on the Prusa i3 MK3! Here’s another compilation of my recent timelapses. I got some shots that i think came out really great and i hope you enjoy them! as always if you want to see some of these timelapses before they come out or want to catch some behind the scenes action check out my instagram!

Thanks to Gina and Guy

OctoPrint was created and is maintained by Gina Häußge (@foosel) and Guy Sheffer (@GuySoft)! A big thank you to both of them for putting in many, many volunteer hours to provide the world with an amazing piece of free, open-source software.

Head over to the OctoPrint website to find out how you can support OctoPrint’s continued existence.

Thanks to Glenn and HackSpace magazine

This tutorial comes fresh from the pages of HackSpace magazine issue 26 and was written by Glenn Horan. Thanks, Glenn.

To get your copy of HackSpace magazine issue 26, visit your local newsagent, the Raspberry Pi Store, Cambridge, or the Raspberry Pi Press online store.

Fans of HackSpace magazine will also score themselves a rather delightful Adafruit Circuit Playground Express with a 12-month subscription. Sweet!

8 Comments