Category Archives: Uncategorised

Raspberry Pi Zero – Programming over USB! (Part 1)

Part 2 to this post can be found here.

Update 19/05/2016 – The modules are now included in the most recent version of Raspbian and thanks to some digging around in kernel documentation, it is now possible to set the full thing up without a keyboard/mouse/screen! Just need a Windows/Mac/Linux computer!

Update 15/01/2016 – The modules have now been merged into the Raspberry Pi Foundation maintained kernels! So no more need for custom kernels, just need to grab the most recent alpha kernels. Doing this is now far simpler.

Full credit for the initial documentation for this goes to a number of Pi experts from the Raspberry Pi community, see here and here.

An acknowledgement also to Lady Ada of Adafruit who was working on documenting in parallel to myself on Christmas eve. She has taken a different approach which requires a UART serial cable. Her guide can be found here.

What is this?

The Raspberry Pi Zero is a very cool little computer. At £4, is pretty amazing for the price. But one thing many Pi users have wanted to be able to do for a long time is program their Raspberry Pi from another computer, using only a single USB cable!

The Raspberry Pi Zero is able to do this, hardware wise anyway, although a lack of software support was holding up it ever happening. Until now!

So what can it do?

Using the Linux USB Gadget modules, we can get the Pi Zero to emulate a whole host of USB devices including

  • Virtual Serial – So can get a serial connection into the Pi, similar to using the UART pins. You can use Putty (on Windows) or Screen (on Mac and Linux).
  • Virtual Ethernet – You can get your Pi Zero to appear as a USB Ethernet modem. With a little configuration, you can then get full SSH, VNC, FTP etc.
  • Mass storage device – You can get the Pi Zero to appear as a flash drive, allowing you to for example, copy files over and have the Pi run these files (useful for robotics for example)
  • Virtual MIDI – The Pi Zero could appear as a virtual MIDI instrument.
  • Virtual Audio – The Pi Zero could appear as a virtual headphone output or microphone input.
  • Virtual Human Interface Device (HID) – The Pi Zero could appear as a virtual HID, for example a keyboard or mouse. So when you plug it into your computer, it could start typing!

You can also combine a few of the above (up to 3 at a time) using the g_multi module, although Windows and Mac have difficulty handling it then.

Examples

Where is this useful? Lets take an example of some Raspberry Pi robots in a classroom. Although you could be using Wifi for each robot, remembering addresses, unreliability with wifi etc all make wifi a bit of a rubbish answer.
With this, the student simply plugs in the robot and perhaps drops their script onto the flash drive that appears. When they unplug it, the robot runs the script, dumping the results of the script back onto the mass storage device, ready to be read when it is plugged in next.

Another example, lets say you don’t have access to a screen to use with your Raspberry Pi Zero, in for example, a school. You could still let your students play with GPIO or Linux by simply using the serial module (with Putty or Screen), or the virtual ethernet module to allow them SSH access.

How to I set it up on my Raspberry Pi?

I have thrown together a guide over on Github Gists, including links to the downloadable precompiled kernels.

Destination space at W5

On Tuesday 15th December 2015, Tim Peake, the first British ESA astronaut, launched on a Soyuz rocket from Baikonur Cosmodrome.

To celebrate this, a number of Destination Space public events were being held across the UK with one at W5 in Belfast.
Myself and some of the Northern Ireland Raspberry Jam team went along and with us, brought 10 Raspberry Pis, some Sense HATs and a stack of Raspberry Pi DOTS Boards.

Rocket dots

Our most popular activity we were running on the day was as usual, the DOTS boards. For the launch, I hastily added a new Easter Egg to the RPi-dots-minecraft program, a rocket simulation!

To enable the secret mode, you simply don’t draw the wings on the plane, causing your drawing to look like a rocket!

Lots and lots of rockets filled in by schoolkids!
Lots and lots of rockets filled in by schoolkids!
Lots of schoolkids busy drawing their customised rockets!
Lots of schoolkids busy drawing their customised rockets!

The activity was extremely popular with over 200+ students giving it a go.

We even had a real ESA astronaut, Jean-Francois Clervoy try out the activity!
We even had a real ESA astronaut, Jean-Francois Clervoy try out the activity!

Sense HAT activity

We also brought along a set of Sense HATs and set them up with the excellent Raspberry Pi Foundation Sense HAT pixel art activity.

Although not as popular as the DOTS boards, Dean and Art were certainly kept busy helping stacks of kids create some awesome pixel art using Python!

Of course, there were a number of creepers created.
Of course, there were a number of creepers created.

Thanks

Big thanks to the wonderful team of Northern Ireland Raspberry Jam volunteers who were able to make it down for the day and for W5 for having us. We all had a great day!

NI Raspberry Jam team at Destination Space. From left to right. Vincent Lee, Andrew Mulholland (myself), Dean Welch, Artemiy Knipe, Sam Stuart.
NI Raspberry Jam team at Destination Space.
From left to right.
Vincent Lee, Andrew Mulholland (myself), Dean Welch, Artemiy Knipe, Sam Stuart.

 

#MyFestivalOfLight 2015 competition entry

As part of the Festival of Light this year at Mount Stuart, a photographic competition is being run alongside it. This blog post features my entries. For a bit more information on how the photographs are done and how you can build your own light painter, see the previous blog post.
Details on the competition can be found here.

Task 1 – Nature and Light

Note – All the images below are the original images as captured by the camera. The only exception to this is some may have had minor colour/contrast adjustments.

Taken at The Festival of Light at Mount Stuart
Taken at The Festival of Light at Mount Stuart
Taken at The Festival of Light at Mount Stuart
Taken at The Festival of Light at Mount Stuart
Taken at The Festival of Light at Mount Stuart
Taken at The Festival of Light at Mount Stuart
Taken at The Festival of Light at Mount Stuart
Taken at The Festival of Light at Mount Stuart
Taken at The Festival of Light at Mount Stuart
Taken at The Festival of Light at Mount Stuart
Taken at The Festival of Light at Mount Stuart
Taken at The Festival of Light at Mount Stuart
Taken at The Festival of Light at Mount Stuart
Taken at The Festival of Light at Mount Stuart
Taken at Downhill forest
Taken at Downhill forest
Taken at Downhill forest, drawing of the Mussenden lion
Taken at Downhill forest, drawing of the Mussenden lion

 Task 2 – People and Light

Taken at Downhill forest
Taken at Downhill forest, featuring Polly, Dan and Dean
Taken in Mermaid's Cave underneath Dunluce Castle
Taken in Mermaid’s Cave underneath Dunluce Castle, featuring Polly, Dan and Dean
Taken in Mermaid's Cave underneath Dunluce Castle
Taken in Mermaid’s Cave underneath Dunluce Castle, featuring Polly, Dan and Dean

Task 3 – Special places and Light

The International Space Station hurtling over Mussenden Temple. 30 second exposure.
The International Space Station hurtling over Mussenden Temple. 30 second exposure.

Task 4 – Time together and Light

Taken at The Festival of Light at Mount Stuart
Taken at The Festival of Light at Mount Stuart, featuring Dominik and Amy

 

Light painting at the Festival of Light 2015

For the past year, on and off I have been working on an automated light painter system. The project finally culminated in testing at this years National Trust Festival of Light at Mount Stuart house.

What is light painting?

Light painting is using a long exposure photograph (usually 5 seconds+) with the camera on a tripod where you use a bright light to “draw” in the image.

Drawing Pacman at Downhill Forest with Polina and Dean
Drawing Pacman at Downhill Forest with Polina, Daniel and Dean. 6 second exposure.

There are a number of ways you can do this, by far the simplest way is find a pitch black area and draw with a phone torch.
The above image was done in a pitch black forest around 11pm at night.

Signing names at Downhill Forest with Polina, Daniel and Dean. 20 second exposure.
Signing names at Downhill Forest with Polina, Daniel and Dean. 20 second exposure.

You can also get super accurate with hand held light painting using phones, in the photograph above, Polly, Dean and Daniel were even able to sign their own names. On top of this, Dean made use of a technique where if an object is lit up light enough, it will also appear. He simply pointed the light at himself.

The International Space Station hurtling over Mussenden Temple. 30 second exposure.
The International Space Station hurtling over Mussenden Temple. 30 second exposure.

The background does not need to be completely black. As long as the objects in the background, don’t move then should be fine.

Handheld light painting

It is actually super easy to get started with simply light painting.
Light painting is an awesome activity to try out with big groups of kids, as all they need is some form of light source.
While this could be a torch on a phone, for young kids or those without a phone with a torch, a simple answer would get them creating a “throwie”! A throwie requires a coin cell battery, an LED and some tape to tape it together. By mixing and matching LEDs, you can create some very cool images.

Getting kids involved at Techcamp to create the camp name with light using 50p throwies. 10 second exposure.
Getting kids involved at Techcamp to create the camp name with light using 50p throwies. 10 second exposure.
The activity can also scale to 50+ kids very easily. In this photograph, the kids drew what they wanted to draw and they were frozen in time jumping using a flashgun. 15 second exposure.
The activity can also scale to 50+ kids very easily. In this photograph, the kids drew what they wanted to draw and they were frozen in time jumping using a flashgun. 15 second exposure.

On top of your light source, you also need a camera and a tripod. It is important to check that your camera supports manually editing the shutter speed and aperture. It is recommended to manually set all the camera light settings (shutter speed, aperture, ISO) as the camera will most likely think the image will be too dark and compensate, causing issues.
You must use a tripod!

Digital light painting

As a maker/inventor, I decided to take light painting one step further by of course, adding a microcontroller!

My first prototype back in 2014 made use of x24 breadboardable Neopixel LEDs and an Arduino Uno.

Festival of light 2014 using the digital light painter on a breadboard and some other LEDs. 20 second exposure.
Festival of light 2014 using the digital light painter on a breadboard and some other LEDs. 20 second exposure.

And resulted in some pretty cool pictures. But, I needed to go bigger!

Introducing the Arduino light painter version 1

Light painter v1
Light painter v1

Using a 1m Adafruit Neopixel strip with 60 pixels, a piece of scrap wood and an Arduino Mega, the first proper light painter of mine was born.

There is full documentation on its Github repo on making your own that you can find here.

Using the light painter to draw a rainbow behind Claire. 30s exposure.
Using the light painter to draw a rainbow behind Claire. 30 second exposure.
Drawing Pacman and ghosts down at Farset Labs using the Arduino Light painter V1
Drawing Pacman and ghosts down at Farset Labs using the Arduino Light painter v1. 30 second exposure.

Arduino Micropainter version 1

The £5 custom designed Arduino Micropainter.
The £5 custom designed Arduino Micropainter.

Between version 1 and 2 of the main light painter, I also threw together a “Micropainter”. Featuring x5 full RGB Neopixel LEDs, it is driven by ATTiny85 chip and is powered by x2 AA batteries. It is soldered onto a custom designed and milled singled sided PCB.

Arduino light painter version 2!

Version 2 of the light painter, featuring 144 RGB LEDs!
Version 2 of the light painter, featuring 144 RGB LEDs!

This year, for the Festival of Light, I thought I would go even bigger! What could possibly go wrong, right?

Building upon version 1, I switched out the 1m strip of 60 LEDs, for a 1m strip of 144 LEDs! This dramatically increases the resolution available, but also dramatically increased the storage space required. With version 1, I had used the program space on the Arduino Mega to store the program, but unfortunately there is nowhere near enough space for the bigger images required, so I also added a MicroSD card slot. This allowed me to store multiple images so I also went ahead and built a menu system, allowing me to select the different images. The menu system simply used the LEDs on the stick as numbers, so image number 8 would be when LED 8 was on in the menu.

Another major adjustment I made over version 1, was adding 3 inputs. x2 buttons for the menu system (next item and select) plus a small potentiometer, allowing me to adjust the brightness of the pixels.
Bar these changes, most of the rest of the system stayed the same.

The light painter uses a Python script to convert the images to an easy to read format for the Arduino, then an Arduino program reads the image file line by line, outputting these onto the light painter. All you have to then do is move the light painter across the frame slowly and smoothly to display the image. In the case of some of the photographs below, the opposite was intentionally done to create the wave effect.

The results though were pretty amazing from this years Festival of Light at National Trust Mount Stuart.IMG_9350IMG_9371IMG_9388IMG_9392IMG_9382IMG_9463IMG_9438

The plan is to hopefully have a building guide up for the new light painter this side of the new year.

Which picture is your favourite?

Mozilla festival 2015 is coming!

What is Mozfest?

Mozfest is the annual Mozilla Festival, run at Ravensbourne College in London. This year the event is running on the weekend of 7th-8th November 2015.

Attended by over 1700+ people every year from over 50 countries, it is no small event. What makes it pretty cool though is it is a weekend run by the community for the community. It is all about the open web and technology and has sessions ranging from Journalism to Science to Learning! The sessions overview can be found here with the full list of over 300 individual sessions here.

Who doesn't want a high five from Foxy.
Who wouldn’t want a high five from Foxy?

But, this year there is one big difference… There is going to be a massive new YouthZone! Now when I say massive, I mean an entire floor of the college dedicated to stuff for young people (and people still young at heart) with over 30 different sessions.!

As part of this, the Raspberry Pi Community has come together with the Raspberry Pi Foundation to deliver a whole stack of awesome Raspberry Pi workshops, aimed at young people.

NIJam

In total, we will be running 17 workshops over the weekend, all aimed at complete beginners with titles including (to name a few)…

  • Astro Pi – Your Code in Space (by Carrie-Anne from the Raspberry Pi Foundation)
  • Musical fruit with the Explorer HAT (by Jim Darby)
  • Hacking Minecraft Pi with Python (by Yasmin Bey)
  • Scratch-ing the Surface with GPIO (by Cat Lamin)

All our workshops will be aimed at complete beginners, so even if you nothing about Raspberry Pi or programming, no matter!
On top of the above workshops in the main Raspberry Pi zone, we will also have 2 other satellite mini Raspberry Pi programming zones with one in the music zone with a key focus on making music with code (especially using Sonic Pi) and the other focusing on the Raspberry Pi Foundation Dots Boards.

Raspberry Pi Dots Board activity
Raspberry Pi Dots Board activity at a previous event

This all sounds awesome, I want to come!

Awesome! We would love to see you down at Mozfest. Tickets are only £3 for young people! For adults tickets are only £45… Tickets are full weekend passes and include lunch both days so is amazing value.

You can grab tickets here.

So all that is left to say is, see you at Mozfest!