Ever wonder what an 8-year-old child would build if you taught them balena? Building their very own Scratch server is at the top of the list. All it took was some encouragement, a Raspberry Pi, and some simple steps.
For parents and educators who want to start quickly, our tried-and-true guide steps are available here. Or read on to enjoy the tale of an eight year old boy and his quest to build his own Raspberry Pi-driven Scratch server. Using Scratch and balenaCloud lets you not only set up the server quickly, but also add additional devices easily.
Note: Scratch requires quite a bit of resources from the Raspberry Pi 4. It works at a minimum with a 2GB (RAM) model. We recommend using a 4 or 8GB Pi for the best performance.
- Some background
- Build it yourself
- What’s next?
I have two sons, Harry who is eight years of age, and Oscar, who is four. Since I joined balena in early 2020, Harry has been incredibly interested in my work. Previously, software architecture diagrams littered my desk and my screens showed design documents and occasionally a Visual Studio window. Since working at balena, my desk gained more and more pieces of technology: Raspberry Pis, a Jetson Nano, a balena Fin, sensors, cameras, HATs, a set of kitchen scales with wires hanging out the side, and more and more flashing LEDs of many colours.
Sometimes I caught Harry staring wide-eyed at all of that technology. Since Harry is home-schooled, I took the chance to weave some computing into his learning and got him started with some coding of his own. A micro:bit seemed fun and allowed him to teach himself block-based coding, but really he wanted a Raspberry Pi. He wanted HATS and sensors. He wanted flashing LEDs!
During our recent team Summit, Harry was able to get more involved with balena. He helped me to run an online game show called “streetview bingo” aimed purely at bringing balenaistas together for some fun: finding random stuff on Google Streetview.
Through this he got to know a few of the people I work with, including Hardware Hacker Chris. So when he walked into the room one day, and found me watching a presentation by Chris on some future balena ideas, he recognised the familiar furry face and deep voice, and sat on my lap to listen. The presentation itself was so inspiring, and energising that, like all of us, Harry was immediately motivated to contribute. And that was the seed of his Scratch project.
Scratch is a programming language and an online community focused on teaching young children how to solve problems with code. Children program and share interactive media such as stories, games, and animation with people from all over the world. It’s a great tool to help children learn to think creatively, work collaboratively, and reason systematically.
Acting on inspiration
The next day, we were out walking in the remains of the summer sun and chatting about the game he was coding in scratch on his chromebook. “You know, not everyone knows how to get started with coding.” I said nonchalantly, “Not everybody has a software developer for a dad who can help them get going”.
“Really?” Harry replied shocked. “Do they have a laptop?” he asked. “Maybe not,” I answered. “We only got one for you because you homeschool and have a real need for one. They’re very expensive.”
“So, other children can’t even run Scratch?” he asked. “Well, they could run it on a Raspberry Pi. And then they could add HATs and make them do cool stu..”. I was cut off: “I could make a balena project with a balena button and when the child clicks it their raspberry pi runs scratch and…”.
For the rest of the walk I wandered along smiling to myself and drinking in the sun, whilst Harry literally bounced next to me pouring out his idea as fast as his mouth could move.
Harry’s Scratch build… from scratch!
Here’s the build method that my son created. If you’re looking for a quicker way that uses Deploy with balena, click here.
I bought Harry a Raspberry Pi Desktop Kit and long-term loaned him my senseHat. The first thing he did, after dancing round the room to calm down enough, was to fit the HAT to the Pi. Next thing was to teach him the basics of balenaCloud and provisioning a device. We created an application called
Once we created the application, we added a device. With the provided image, Harry used balenaEtcher to flash it to his SD card. Then came the moment of magic, inserting the SD into his raspberry pi, turning it on and seeing it appear in his balenaCloud app (see build steps for more details on this).
Containers: explain it to me like I’m eight
The next job was to explain containers to an 8 year old. “You see,” I ventured, “that file we used Etcher to put onto the SD card, that tells the Raspberry Pi that it’s a computer, and connects it to your balenaCloud application, but nothing about scratch.”
“Oh” Harry qualified, “we need to tell it about Scratch, right?”
“Yep, but if we just tell your Raspberry Pi about scratch, that’s only going to help you. What we need to do is find a way to make anyone’s Pi connect to balenaCloud and be told how to install and run scratch for itself.”
“And that’s a container?” Harry asked. “Yeah. It’s a way of getting a sort of pretend computer to run on a real one. The container is built from a special file called a dockerfile, which really is just a set of recipe ingredients and instructions.” “Oh, so it’s like making a cake?” Harry asked. “It’s like writing a cake recipe, which the oven reads and just makes the cake for you” I offered. “COOL!”
Our recipe needed scratch, obviously, and a few bits of xserver so that the Pi knew how to put scratch onto the TV. Other than that, we just plugged in the mouse and keyboard, and did a
balena push scratch.
Then another moment of balena magic: the scratch service downloaded to Harry’s Pi, the connected TV burst into life showing the balena logo and then:
...scratch loaded, and the adventures could begin!
Build it yourself
- Pi4 (preferably 4 or 8Gb model but a 2Gb will work)
- SD card
- A display or television
- A keyboard and mouse
- senseHat (optional but fun)
Harry did the work, so that you don’t have to. All you have to do is click the button, log in or set up your free balenaCloud account (first ten devices are fully-featured and free of charge with no credit card required to begin), add a device, and flash:
If you want to see the repo and contribute via GitHub, see the repo.
Deploy and add device
Give the app some time to build and preload into your account. While it’s building, click into click “Add device” and fill out the modal to download a balenaOS image to load onto your device. Be sure to accurately input your wifi credentials so that the device can access the internet to download the Scratch service once it’s online.
Use an image flashing tool like balenaEtcher to flash the image onto your SD card. Insert the SD card into the device and power it on. When it’s online, you should see it on your device list within your Scratch app.
Start up Scratch
Once balenaOS loads on the device, it’ll directly load Scratch. You’ll be greeted with a modal asking if you want to submit feedback to the creators. Select an option and you’ll be brought directly to your first project.
So, did Harry’s project actually work? Was it as good an experience as coding Scratch on his laptop?
It was better.
There‘s something about writing code that runs directly on the device in front of you. Add a HAT to it, make the LEDs flash, use the buttons on it as input, and it’s even more real.
I’ve seen Harry learn to code other things, like Arcade, but I’ve never seen him into something so much as Scratch on a Raspberry pi with HATS connected. After some experimentation, he decided to make a halloween project. Apparently it’s being embedded into a pumpkin.
Simplifying access to learning tools for educators
What Harry hoped to do with this project was enable other people, specifically children, to have access to Scratch running on a Raspberry Pi so that they too could learn to write code and create inventions. This means enabling parents and educators to be able to set up Scratch, or other similar tools, as simply as possible. It also means removing any friction of maintaining those devices to keep the fun learning times rolling.
Educators are integrating Scratch across many different subject areas and age groups. Schools, coding clubs, or homeschooling groups can also use this guide if they want to add a fleet of devices to their Scratch application, and spread the joy of coding to a group of people.
Whomever you are, try it out, have fun and if you need any help come and find us lovely balena folk in the forums. Share your successes or questions with us on Twitter and Instagram as well.
A special thank you to Harry Philip Wilson for his work in bringing Scratch to balena and to hopefully many children all over the world.