Category Archives: Physical Computing

How to Build a Wildlife Camera with the BBC micro:bit and Samsung’s micro:bit App

After much fiddling about I’ve finally managed to work out how to get Samsung’s micro:bit app working properly with my micro:bit. Before I tell you how you can use it to turn your phone into a wildlife camera there are two very important points to bear in mind:

1. You need to make sure you have the latest version (1.5.3 – 11 October 2016) of the app installed. I couldn’t get my micro:bit to control my phone’s camera with previous versions. So install/reinstall the latest version of the app now.

2. Every time you flash new code to your micro:bit you need to un-pair your micro:bit from your phone (go to ‘Settings’ then ‘Bluetooth’ on your phone) then re-pair it via the micro:bit app. Very, very important point this. It took me ages to work this out.

OK, now we’ve got that out of the way, here’s how to build a wildlife camera.

You will need:

  • Wildlife camera kit 1 x BBC micro:bit, its USB lead, and its 3V battery pack.
  • 1 x PIR motion sensor (I used this one from Squirrel Labs. Strictly speaking it’s a 5V motion sensor, but seems to work OK with 3V of power from the micro:bit.
  • 3 x crocodile clips.
  • 1 x male to female jumper lead. Not essential, but makes connecting the crocodile clips to the motion sensor a lot easier.
  • A Samsung smartphone (I used an J5) with the Samsung micro:bit app (1.5.3 or later) installed.

First, adjust Sensor setupthe sensitivity and time delay on the motion sensor. Turn both orange dials anti clockwise as far as they’ll go.

This sets the motion sensitivity to it’s least sensitive setting (left dial in the photo above) and the time delay between sensing to the shortest possible interval (right dial in the photo above). Five seconds for this motion sensor.

Next, connect your jumper lead to the middle pin (labelled OUT) on your PIR motion sensor. This just makes it a bit easier to connect the motion sensor to the micro:bit with crocodile clips.

Now connect your motion sensor to yMotion sensor to micro:bit wiringour micro:bit with crocodile clips:

  •  The ‘GND’ pin needs to be connected to the GND ring on the micro:bit.
  • The ‘OUT’ pin (jumper lead) needs to be connected to ring P0 on the micro:bit.
  • The ‘VCC’ pin needs to be connected to 3V ring on the micro:bit.

Now you’re ready to code. I created the following code in the Block Editor on my computer. Use your computer, not your smartphone to write code. It’s very, very annoying trying to code on your phone. The screen is just too small.

Wildlife camera code

All the time nothing is sensed, a simple line pulses across the display – – – But when something is sensed the motion sensor sends an electric signal out on its ‘OUT’ pin, which is detected by the micro:bit as a change from 0 to 1 on ring P0 (the ring the ‘OUT’ pin is connected to by the crocodile clips).

All the time a 1 is detected on ring P0, the micro:bit will change its display to ! ! ! and send three commands (via bluetooth) to your smartphone. The first launches your smartphone’s camera app. The second command initiate a countdown of 5 seconds, then the third command actually takes a photo and saves it to the ‘Images’ folder on your phone. You need the time delay between the ‘launch’ and ‘take photo’ commands because the camera doesn’t kick into life the instant the app is launched. But you may be able to get away with a delay of less than 5 seconds. I guess it depends on what model of phone you are using.

Once you’ve written the code (on your computer) connect your micro:bit to your computer via the USB cable, then compile the .hex file and drag it onto your MICROBIT icon.

Now un-pair your micro:bit from your phone (go to ‘Settings’ then ‘Bluetooth’ on your phone) then re-pair it via the micro:bit app.

Don’t forget to press the micro:bit’s reset button after pairing!Paired micro:bit

Now your ready to test. It takes a good minute for the sensor to start up properly. After that you should be able to trigger your phone’s camera into life by waving your hand in front of the sensor.

If it doesn’t work, double check your crocodile clip connections and/or try increasing the sensitivity of the motion sensor by gradually turning the orange dial (the one on the right if the dome it pointing upwards) clockwise. Try a tiny increment. These motion sensors are very sensitive.

If all is working well, your phone will say ‘Selfie time!’ every time the camera is triggered into action. This is extremely annoying. To turn off this alert go to ‘Settings’ then ‘Accessibility’ then ‘Hearing’ on your phone and switch on ‘Turn off all sounds’. Remember to turn this off again when you want to use your phone as a phone again, or you won’t be able to hear anyone!!!

So far I’ve only managed to capture my cat rolling about on a rug in our lounge. To make a true wildlife camera I need to design some sort of water proof case for the whole ensemble, and leave it outside somewhere (the bird table maybe) for a while. But for now, I’m very pleased with what I’ve got and I’m finally able to say I quite like the Samsung micro:bit app.

20161017_132532 Cookie the Cat

FacebookTwitterGoogle+Share

How to fix ‘Unfortunately micro:bit has stopped’ error.

Screenshot_2016-09-20-18-15-42Screenshot_2016-09-20-18-16-00J5 microbit error

A few weeks ago, keen to use my micro:bit to control my Google Nexus 5’s camera I tried to install the Samsung micro:bit app. I was a little surprised when I was told (by the app) that it wasn’t compatible with my hardware. A bit annoying I thought, but it’s Samsung’s app so I thought maybe they’ve coded it so it only works on Samsung devices.

So last week when my new Samsung Galaxy S5 arrived I was keen to try the app again. Surely it will work with Samsung’s most popular smartphone. This time there was no polite incompatibility message, the app installed in an instant. I then used the app to pair my micro:bit and S5, and after a couple of failed attempts (where I didn’t follow the instructions properly it must be said) it appeared to have paired successfully. Brilliant I thought. Now lets have some fun.

Well, unfortunately that’s where the fun ended, because every time I tried to connect to my micro:bit with the app I instantly got the message ‘Unfortunately micro:bit has stopped’. I tried un-pairing and re-pairing my devices, updating my S5, and I even updated the firmware on my micro:bit. But still the same error message.

Then I did what I should have done in the first place: I googled the error message. I didn’t get a direct hit, but I did notice a lot of people were getting remarkably similar error messages with other apps installed on the S5 (and other smartphones). This was their solution and I can confirm it fixed my micro:bit app error a treat.

  1. From the home screen, tap ‘Apps’, then ‘Settings’.
  2. Scroll down to ‘Applications’ then tap ‘Application manager’.
  3. Scroll down to, and tap micro:bit.
  4. Tap the ‘CLEAR DATA’ button, then ‘Clear’ to confirm. This should clear the cache as well.

Unfortunately, now that the micro:bit app is working on my S5, I’m sorry to report that it isn’t actually very good. Writing code is extremely fiddly and it takes forever to compile. It could be that I’m not using it properly, so I’ll persevere for now. Watch this space for a full review of the app.

How to Build a PIR Motion Sensor Intruder Alarm with the BBC micro:bit

Here’s a fun (and fairly easy) micro:bit project to get you started.

You will need:

  •  1 x BBC micro:bit, its USB lead, and its 3V battery pack.
  • 1 x PIR motion sensor (I used this one from Squirrel Labs. Strictly speaking it’s a 5V motion sensor, but seems to work OK with 3V of power from the micro:bit.
  • 1 x buzzer.
  • 5 x crocodile clips.
  • 1 x male to female jumper lead. Not essential, but makes connecting the crocodile clips to the motion sensor a lot easier.
  • A clear plastic food container. Quite a big one; there’s lots of wires to fit in it.
  • 1 x kitronic micro:bit case. Not essential, but makes it a lot easier to position the micro:bit in the food container.
  • A drill and some different size drill bits.

you will need

First, adjust the sensitivity and time delay on the motion sensor. Turn both orange dials anti clockwise as far as they’ll go.

sensor etup

This sets the motion sensitivity to it’s least sensitive setting and the time delay between sensing to the shortest possible interval. Five seconds for this motion sensor.

Next, connect your jumper lead to the middle pin (labelled OUT) on your PIR motion sensor. This just makes it a bit easier to connect the motion sensor to the micro:bit with crocodile clips.

Now connect your motion sensor to your micro:bit with crocodile clips:

  •  The ‘GND’ pin needs to be connected to the GND ring on the micro:bit.
  • The ‘OUT’ pin (jumper lead) needs to be connected to ring P0 on the micro:bit.
  • The ‘VCC’ pin needs to be connected to 3V ring on the micro:bit.

Next, connect your buzzer to your micro:bit with crocodile clips:

  •  The short pin needs to be connected to the GND ring on the micro:bit.
  • The long pin needs to be connected to ring P1 on the micro:bit.

Your wiring should now look like this:

wiring

Now you’re ready to code. I created the following code in the Block Editor:

intruder alarm code

All the time nothing is sensed, a simple line pulses across the display – – – But when something is sensed the motion sensor sends an electric signal out on its ‘OUT’ pin, which is detected by the micro:bit as a change from 0 to 1 on ring P0 (the ring the ‘OUT’ pin is connected to by the crocodile clips).

All the time a 1 is detected on ring P0, the micro:bit will change its display to ! ! ! and send an electric signal out on ring 1 (digital write 1 to pin P1). The buzzer is connected to this ring by crocodile clips, so it causes the buzzer to buzz for 1 second (1000 ms).

Now connect your micro:bit to your computer via the USB cable, write the code in Block Editor, then compile the .hex file and drag it onto your MICROBIT icon.

It takes a good minute for the sensor to start up properly. After that, you can test things are working properly by covering the motion sensor with an opaque box (or put in in a drawer) for a while. Nothing should be sensed: the display should read – – – and no buzzer noise should be heard. Once you take the box away the display should change to ! ! ! and the buzzer should start going off, as it detects your movement. If it doesn’t work, double check your crocodile clip connections and/or try increasing the sensitivity of the motion sensor by gradually turning the orange dial (the one on the right if the dome it pointing upwards) clockwise.

To turn your intruder alarm into some sort of product, try to fit it all into a clear plastic food container and power it from the micro:bit battery pack. I used my kitronic micro:bit case to attach the micro:bit to the front of the food container.

microbit in case

As you can hopefully see, I had to punch four small holes into the front of the food container to thread the case’s screws through.

I then drilled a big hole in the bottom of the food container so the motion sensor could poke out of the bottom. The ‘finished’, rather crude ‘product’ looks like this.

final product

It’s not the world’s best intruder alarm. It sometimes takes quite a while to sense an intruder, and the buzzer isn’t very loud, but for a first micro:bit project I’m quite pleased with the result.

Watch this space for more micro:bit projects.