Sunday, 12 March 2017

micro:bit and Bluetooth

We have 8 BBC micro:bit micro controller boards (are they computers?? Not sure - is a washing machine?! (time travel!)), and although the club has had a bit of a fiddle with them, writing random messages, playing music, listening to bananas and other fruit, we could do with something a bit more challenging.

Martin Woolley (Bitty Software) has developed some smartphone applications that can connect to uBits using Bluetooth and retrieve data etc. Maybe we need to look into these...

First, I've downloaded the Bitty Data Logger app for my aging iPhone 4S from the Apple App Store. Yeah, I should be using Android, but it still works and owes me nothing, ok?

Let's check the tutorials website - I like PXT because it means I don't have to mess around with C/C++, been there, done that, got paid for it.

The tutorial is pretty simple, although the current PXT facilities, assisting nRF bluetooth application and procedure is different.

Writing Bluetooth code in uBit

Start a new project in PXT. Add the Bluetooth package, accepting to discard the Radio package.

The tutorial gives you the general idea, but I had to use the following:


Obviously, more could be done! Download the hex file and load into the uBit.

Pairing with the iPhone

Note:
I used the app that requires pairing - there is also another version which does not require pairing, which we used in conjunction with an iPad. It worked perfectly fine.

This doesn't work without a helper app - I tried! The video here shows the basic approach:

  1. Put the uBit into pairing mode (Reset + A + B - display shows PAIRING)
  2. Use the uRF Connect application from Nordic (NOT the suggested one in the video!)
    1. Scan shows the uBit available
    2. Click on Connect 
  3. Job done!
The screen now shows all the uBit service IDs which are loaded into the uBit hex file, and the uBit is visible on the Services Bluetooth 

Iphone Bluetooth screen
nRF Connect screen




















Use Bitty Data Logger!

This bit was easy - start the app, Scan, see the uBit listed, click on its entry, then Start.

I then dropkicked the uBit around a tad, and had some results! Marvellous.


Screen shot of actual captured data!

Update:

The Data Logger application has a settings page - you can add Magnetometer and Temperature data to the logging. Marvellous.

Child Testing Notes:

The uBit/app combination generated some interest. I took some bubble wrap and tape so we could protect a uBit whilst doing dynamic things with it. After getting it working with the school's iPad, using the non-pairing version of the application, various experiments were tried:

  • How far will the uBit go before it loses contact with the iPad?
    • About 30 ft, which involved a partition wall and various interspersed children
  • What happens if you drop it?
    • The batteries wiggle in the box and it cuts out, enough to sever the Bluetooth connection. We tried taping them in, but this requires more thought. 
  • Can you strap it to your shoe and get any interesting data?
    • You can!! But it would require lots of attempts and study of the data, using some kind of "normalised" or standard setup, to get enough reliable data to make statements about gait and so on. Lots of interest in that though.
All in all, a worthwhile session!


Code Club - the start

I went to Reading Geek Night - 2nd Tuesday of the month, upstairs at a large central pub. There I met Peter Higginson and got talking, ending up suggesting that I might be interested in assisting in running coding classes and an associated Code Club at a local primary school. Inevitably, his current assistant backed out, and I was called in.

Four weeks of Scratch lessons to two Year 6 classes (10 year olds), then Dec - April lunchtime Code Clubs, one hour once a week. It's fun. The kids are amazingly interested!

We started Code Club with some additional Scratch work, then moved onto the 8 micro:bits that the club has. They were quite fun, with kids getting involved in making music and various other things than can easily be done. It's quite hard to

  1. Help all the people with questions, as they're all working at different speeds and levels, with only two people
  2. Address/fix the problems they encounter when one has little or no experience of the tools yet, especially as some of the difficulties are because they deleted something!
Subsequently, we've moved onto Javascript, modifying a "shoot down the airliner" game. I'd forgotten lots about JS...

Ideally, I'd like to have some slightly longer term projects running, that involve multiple people doing various sub-tasks, that would carry us from week to week. But they are coming back, and enthusiastic, amazingly, so should I be asking for more at all?