How we built a virtual Sense HAT with the Raspberry Pi Foundation

We’ve been working most of the summer on an exiting new project with the Raspberry Pi Foundation, one of the world’s leading coding education charities. Together we built an in-browser emulator for the Sense HAT device, which adds sensors, gyroscopes, and color LEDs to their inexpensive Raspberry Pi computers. Here’s what the finished product looks like:

Here’s what the Sense HAT and Raspberry Pi look like in real life.  The Raspberry Foundation’s designers provided us with the cool image that we modified to use in the emulator- not bad, huh?

The Raspberry Pi Sense HAT
The Raspberry Pi Sense HAT

What’s The Sense HAT Do?

Like all Raspberry Pi devices, the Sense HAT is cool enough to have developed a huge base of hobbyists who love it but really shines for students learning to code in the classroom. The Sense HAT is one of the best devices for connecting code to the real world by allowing students to see their code read temperature and make LEDs light up with relatively little overhead or boilerplate. Raspberry Pi wanted to build an in-browser emulator to bring this neat tool to as many students as they could around the world. We were excited and honored when they reached out to us about submitting a proposal for the project this past Spring.

Why Raspberry Pi Picked Us

If you’re a reader of this blog you probably know that Trinket is all about quick, easy, in-browser coding. Luckily for us, the Raspberry Pi folks had heard about us too. They recently merged with another amazing UK-based charity, Code Club, who’s been using embedded trinkets in their free HTML and CSS projects for about two years now. The Code Club staff made sure that the Sense HAT project team knew about us and the rest, as they say, is history.

To Space – And Beyond!

Astronaut Tim Peake with the Sense HAT in orbit aboard the International Space Station
Astronaut Tim Peake with the Sense HAT that’s currently in orbit aboard the ISS

So what are the Foundation’s plans for the new emulator? If you haven’t hear about it, the Foundation has been running one of the coolest coding projects we’ve ever seen, called Astro Pi. They sent two Raspberry Pi computers up to the International Space Station with British ESA astronaut Tim Peake in 2015. This Spring, they held several contests for students to submit Sense HAT programs for a chance to have Tim run them in Space. Amazing! The new emulator will allow thousands more students to participate in upcoming contests as Raspberry Pi looks to expand it to other space programs around the world.

Doing More With The Sense HAT

But regardless of whether you’re a student with an astronaut on the ISS, the new emulator will let you experience the fun of a Sense HAT equipped Raspberry Pi for free. And while students in Science class will likely be writing programs using the environmental sensors, the Sense HAT can do a whole lot more. For instance, here’s a clone of the popular Flappy Bird game:

To play, make sure the Sense HAT window is active by clicking on it, then use the ‘up’ key to fly your bird with the virtual joystick. How many points can you get?

The new technology is available from all of our Python trinkets- just import sense_hat and you’re off! To see more example programs, check out our new demo page for the project.  And if you already own a Sense HAT, a special Download button in the left-hand menu will let you download everything you need to run these programs on your Pi.

We can’t wait to see what our awesome users come up with! If you write a cool program, tweet it to @trinketapp and @Raspberry_Pi for a chance to get featured!

A Little Help From Our Friends

A project like this is the work of many hands, so I’ll end a few words of thanks. Raspberry Pi Team Members Dave Honnes, Ben Nuttall, Helen Lynn, Philip Colligan, Rik Cross, and the others who worked behind the scenes on this project made it a success.  Thanks to all of the awesome beta testers who tested the emulator as we built it and provided helpful suggestions.  Dave Jones did amazing work with the sense_hat module’s new SenseStick API that we were able to implement in Skulpt.  Speaking of Skulpt, open source developers Michael Ebert and Albert Jan Nijburg were a key part of the Trinket team for the project.  Their expertise and diligence really shows clearly in the final product.  The rest of the great Skulpt development community continues to make improvements to Skulpt, which is a key part of our in-browser Python interpreter, and we’re extremely grateful for their efforts.  Finally, thank YOU, our users, for teaching and learning code using our tools every day.  Together we’re making the world a better, more hackable place!