Wednesday, 21 December 2016

Bitty Software and Preparing Youngsters for the Age of the IoT

Bitty Software is the name I use for my micro:bit smartphone/tablet applications project. At the time of writing, there are 5 Bitty Software applications for each of iOS and Android in their respective app stores. In each case, micro:bit coding tutorials are available, the idea being that to use the smartphone applications, you have to program your micro:bit. For those who don't want to, or who are simply too impatient to get started, pre-built hex files are also available.

The idea behind Bitty Software was to create resources for education and fun which shine a light on communications technology and the micro:bit rather than just on coding. Bluetooth is of course my communications technology of choice.

Why emphasise communications? Well, given one of the primary goals of the micro:bit project is to educate youngsters in coding and making things and to prepare them for potentially becoming the next generation of technology entrepreneurs and leaders (or simply to make a living from their technical skills), communication between devices is an essential thing to know about, and here's why.

Goldman Sachs released a report in 2014 which discussed the Internet of Things (IoT). In that report, they characterised the internet as evolving through three major phases.

1. The 1990s. 1 billion devices are connected to the internet. These are largely desktop computers and servers. People use modems that make a quaint bleeping sound.

2. The 2000s. 2 billion devices are connected to the internet. This is the age of the smartphone.

3. The year 2020. It's forecast that by 2020 there will be <drum roll> 28 billion devices connected to the internet. This is a phenomenal figure. And those devices? Computers, smartphone and tablets. Obviously. But also light bulbs, manufacturing equipment, sensors of every conceivable type and much more besides.

The IoT is why youngsters need to be educated in communications as well as coding. At the "edge tier" of any IoT architecture, you'll generally find smaller devices, often equipped with microcontroller units (MCUs). The BBC micro:bit is an MCU. And they will very typically communicate wirelessly with each other and with the internet via entities known as "gateways".

There are various wireless technologies. Some of them are categorised as "low power wireless technologies" meaning that they use relatively small amounts of power to communicate data. Bluetooth low energy is one example and this is the Bluetooth technology on the micro:bit. Low power use is critical in many IoT scenarios. Consider a smart building. It can only be "smart" in any meaningful sense of the word if we have lots of data about its various aspects and from every nook and cranny of the building, let alone every room; temperature, light levels, water levels, security status of windows and doors, occupancy of rooms and so on. Data can be accrued, aggregated and analysed. It can form the basis of intelligent automation and reveal hitherto unknown things about the building (is this building energy efficient compared to other, similar buildings?) but this can only be achieved with the right type and quantity of data, acquired at the right time.

To obtain this magical data requires sensors. Lots of sensors. Everywhere. Placing sensors in wall spaces, attics and under the ground becomes untenable if they need their batteries changing every few weeks. Devices have to run for many years on a single battery or better still, require so little power that energy harvesting techniques which generate power from ambient light, temperature changes, mechanical vibration or naturally occurring radio in the environment, can be used instead of batteries.

Its ubiquity (over 3 billion Bluetooth devices shipped in 2015 alone), wide platform support, developer friendliness and very low power requirements have made Bluetooth the low power communications technology of choice for the IoT.

So those youngsters we have such high hopes for, they need to be immersed in communications as well as coding and learn about creating systems of devices, not just creating the code for one device.

Bitty Software and Bluetooth. Doing their bit. OK, I nearly finished on a pun there!


Wednesday, 16 November 2016

micro:bit support

The 'micro:bit foundation' has arrived and is charged with looking after the future of the micro:bit. It's also a great place to go for technical support. We've lacked a central place to find answers to questions or to get assistance until now, so this is a big step forwards.

Here are some handy support resources for you:

1. If you need help with a Bitty Software application or tutorial

Send a message to @bittysoftware on Twitter. If you can, post more extensive details on a blog or similar and include a link to these details in your tweet.

2. Anything else micro:bit related

Email help@microbit.org or go to http://support.microbit.org and open a support ticket.

That's it!

Tuesday, 15 November 2016

micro:bit Blue - open source at last!

Most of the micro:bit demos involving a smartphone shown on my micro:bit page involve an Android application I wrote and which I eventually decided to call "micro:bit Blue". It was initially put together to help me to test the Bluetooth profile I'd designed for the micro:bit. Then, as I started to have ideas, it transformed into a series of demos.

But I always had the aim that it be released as open source, so I also did my best to provide educational documentation in the helps screens so that people who are new to Bluetooth could get the hang of the primary concepts.

A few months ago I loaded the application into Google Play so that other people could find and install it easily.

 It's right here:

https://play.google.com/store/apps/details?id=com.bluetooth.mwoolley.microbitbledemo&hl=en_GB

Meanwhile, releasing the source code was delayed by a variety of rather uninteresting issues. And then some more. To cut a long story short and at the same time apologise for having taken so long over this, today I'm delighted to say that the source code is now available!

The new microbit foundation have kindly offered a home for the code and their home being more palatial than my own github home, I gratefully accepted their offer.

I hope those people who have been waiting for this are pleased and that everyone and anyone with an interest in writing smartphone apps for the micro:bit finds this useful.

Here it is:

https://github.com/microbit-foundation/microbit-blue

 Enjoy :-)

Thursday, 10 November 2016

Bitty Data Logger V1.2.0

Yesterday, Bitty Software released a new version of the Bitty Data Logger application. If you're unfamiliar with the app, check it out at the Bitty Software web site.

The new release makes the following improvements:

  1. A new "Results" screen lists up to 30 data files.
  2. Data can now be uploaded at any time.
  3. New "Extra Data" screen provides the opportunity to add a time and distance value after a test run has completed. A speed value is automatically calculated.
  4. The Activate / Deactivate button is now named Start / Stop and is coloured green and red.
  5. The Settings screen now allows a Project Name and a Team Name to be entered.
Bitty Data Logger is currently being evaluated for use in the Bloodhound model rocket car competition for schools, Race for the Line. This is of course, *very* exciting!
Bitty Data Logger is free and available for both iOS and Android. The code needed for the micro:bit is available as a hex file from the Bitty Software web site or you can create it yourself, with guidance available in the form of a couple of coding tutorials, one for C/C++ and one for the PXT tool.

The application is great for school or personal projects:
Spice up your science lessons with the @bittysoftware #microbit data logging app for Android & iOS: #edchathttps://t.co/zBFzku9G95 pic.twitter.com/w7Kgg5VHTE

Here are some screenshots of the new release. 

Ready to start data logging!

And we're off....

After capturing data we can record extra, optional data

Up to 30 data files are kept. NEW files have not yet been uploaded
After uploading, you can download to your computer from the URL provided

Data file details include the URL which was allocated when uploading

Tuesday, 1 November 2016

micro:bit proximity beacons

One the big growth areas for Bluetooth is in "beacons". Bluetooth beacons broadcast data which can be used by another device to deduce roughly where it is. This can be in terms of a particular location or perhaps in terms of proximity to an object of interest.

ABI predict that by 2020, there will be 400 million Bluetooth beacons shipping each year.

Beacons work by using Bluetooth "advertising" to broadcast a small amount of data, which can be received and acted upon by anyone in range with a suitable device and software, typically a smartphone and application.

There are various beacon message formats, which define the way Bluetooth advertising packets are used as containers for beacon data. iBeacon is Apple's beacon message format. Eddystone comes from Google.

Google have a very interesting project called the Physical Web and it in large part, is all about how Bluetooth beacon technology, coupled with software on smartphones and tablets, coupled with the web, can enable people to more easily discover and interact with physical things in the environment.

Believe me. This is going to be BIG.

I just helped add Eddystone beacon capabilities to the BBC micro:bit. Kudos to Thomas Beverly for having kicked things off by implementing support for Eddystone URL messages in the micro:bit's "runtime". I tagged along for the ride and added support for UID messages over the weekend and it's now pretty easy to use a micro:bit for a wide range of beacon scenarios.

I have a couple of videos on my Bitty Software web site. The first shows the UID Eddystone message type in use and the second uses the URL message type. Take a look at them now to get the idea, especially if you're not already familiar with beacons.

Don't forget, you don't need to make a Bluetooth connection to a beacon to use it... you just have to be near enough to it to receive its broadcast data and as I've noted elsewhere in this blog, micro:bits can have a range of hundreds of metres when using Bluetooth at full power. 

So you could place micro:bit beacons all over (say) your school, and with a suitable application on phones and tablets, provide information pertinent to each location or some other response, automatically on someone simply coming into range of the micro:bit's beacon broadcasts.

Right now, turning your micro:bit into a beacon requires you to do some C/C++ programming. I'm hoping though that Microsoft's awesome PXT tool will end up with a "Bluetooth Beacon Block" in the future so that making micro:bit beacons is as easy as can be.

The microbit-samples repo will soon have Eddystone beacon code examples in it and I've also submitted updates to the Lancaster University micro:bit documentation on the subject.

Meanwhile, to whet your appetite, here's some code:

#include "MicroBit.h"

MicroBit uBit;

char URL[] = "https://goo.gl/TlUTF7";
const int8_t CALIBRATED_POWERS[] = {-49, -37, -33, -28, -25, -20, -15, -10};

uint8_t advertising = 0;
uint8_t tx_power_level = 6;

void startAdvertising() {
    uBit.bleManager.advertiseEddystoneUrl(URL, CALIBRATED_POWERS[tx_power_level-1], false);
    uBit.bleManager.setTransmitPower(tx_power_level);
    uBit.display.scroll("ADV");
    advertising = 1;
}


Saturday, 29 October 2016

Bitty Software

Bitty Software is a relatively new endeavour which concentrates on smartphone apps for use with the BBC micro:bit and offers free coding tutorials where you can learn to write the micro:bit code which is needed to make a micro:bit work with one of the Bitty Software apps. Tutorials are available for both C/C++ developers and those who prefer a visual programming language. In the latter case, Microsoft's excellent PXT is used.

The ethos behind Bitty Software is that in this emerging age of IoT, learning to code is just one dimension of the technology journey which youngsters need to take; learning about connectivity and communications is essential too. Hence the focus on systems which involve one or more micro:bits, a smartphone or tablet and in the middle, enabling the whole thing to work, Bluetooth.

Despite being such a relatively new concern, the Bitty Software web site www.bittysoftware.com is rapidly accruing a really useful collection of micro:bit programming resources, including some great videos.

Take a look.... the bitty data logger application demo and the micro:bit Eddystone beacon demos are particular favourites.

Bitty Software already have 4 applications for micro:bit, all of which are available for both iOS and Android. There are more in the pipeline. Watch this space!

Bitty Data Logger and a Speeding Vehicle

I thought it would be interesting to see how well the new Bitty Software application Bitty Data Logger would handle capturing accelerometer data from a micro:bit attached to a moving vehicle. So.... that's what I set out to discover.

The first challenge was how to attach a micro:bit to my car! I'm no structural engineer. As you'll see. But with some good sticky tape, some glue, some rolled up cardboard and of course a piece of Lego, anything's possible :-)


There were some practical issues associated with planning this project. One person would need to drive and another hold the smartphone and operate the app whilst standing at the side of the road. I'd need a suitable stretch of road where I could drive fairly fast without breaking the law or having a horrible accident. And of course "smartphone operator" and driver would need to be able to communicate so that the driver would know when the app was connected to the micro:bit and data capture activated in the the bitty data logger app.

My long suffering wife got the job of smartphone operator, with me behind the wheel of my car. We'd devised a system of hand signals she could use to indicate she was ready and I could start driving (none of which were rude!) and I dropped her at a suitable point on a local A road, drove to the end of the road and came back around the roundabout ready to drive past her. I awaited her signal as she scanned for and connected to the micro:bit mounted on my car's wing mirror and activated data logging.

When the signal came, I immediately put my foot down and accelerated up the road in her direction. For about 2 seconds. I immediately got stuck behind another car. Yes, there was a lot of traffic about, and I did wonder what effect all those large metallic objects might have on Bluetooth radio communications.

I pulled out past the slower vehicle and put my foot down again. About 2 seconds later I was at 60mph and held that speed until the next set of traffic lights forced me to decelerate.

Don't worry - this was taken by my passenger before we started data logging!

Had the experiment worked? Had we captured any data?

Happily the answer was a big yes! The plan had been for my wife to start capturing data when I was at the roundabout about 50 metres away and driving towards her and then deactivate when I was an estimated 100 metres past her. It looks like everything worked a treat. Here's the resultant data in chart form with a manually drawn trend line which shows broadly how things panned out.

Y axis - forward acceleration


Note that this data is completely raw. The micro:bit accelerometer generates data that is somewhat "rough" and it's best used by applying a low pass filter to it to smooth out its roughness. Maybe a later release of Bitty Data Logger will give you the option to have it do this for you.

I was predominantly interested in the Y axis which represents forward motion, given how I'd mounted the micro:bit on my car, but just for good measure, here's the X (sideways) and Z (up and down) data:

X axis - sideways acceleration
My guess is, the sudden deceleration and then acceleration shown near the start of the chart correspond to me having to pull out and overtake the car that was blocking my way. After that, the general trend shows constant x axis acceleration, averaging around 0.

Z axis - up and down acceleration
The Z axis just shows vibration and general bumpiness I think!

I think I can declare today's little experiment a success!