Thursday, 5 May 2016

Using the BBC Micro:bit as a data logger

I ordered a set of BBC Micro:bits for our year 7 students as part of BBC's offer to provide them across the UK. If you need to know more about this, please check their website here:
This guide is written assuming you know what a BBC Micro:bit is and you've got a basic understanding of uploading codes to it.

Like many schools data logging is part of our curriculum in science lessons. Data loggers can be very expensive, especially for a class set. 

When the micro:bit arrived and I saw that it was capable of measuring temperature and displaying it on the LED matrix. I wondered if it was possible to output this data somehow so it could be recorded - turning the micro:bit into a data logger.
It's proven to be not very straight forward, but I got it working to a degree (pun intended!) - so I thought I'd share it here and maybe someone with more programming knowledge can take the idea further and do something more with it.

Firstly, you'll need to download a programme that lets you view data transferred from the micro:bit over a USB link. I used teraterm:


Also, you'll need to download a device driver from here:


Once both the driver and the terminal emulator are installed, plug in the micro:bit and wait until the device is fully setup. Then, open TeraTerm.
  • Hit File > New Connection
  • Check "Serial"; in the dropdown menu, pick the COM port that says "mbed Serial Port". Hit Ok.
  • In the menus, hit Setup > Serial Port and set the baud rate to 115200.
You should be good. Feel free to hit Setup > Save Setup in the menus to erase the default configuration file with a new one so that you don't have to type in the settings again.
Keep the Teraterm window open.

Once this is done, write this short code using the BBC micro:bit Touch Develop code creator. https://www.microbit.co.uk/fthkjv

If the serial button is not available, you will need first to add the micro:bit serial library to your script:
  • tap on add new
  • tap on library
  • select micro:bit serial

Once the script has been loaded onto your micro:bit you should see numbers scrolling down the terminal window in Teraterm, separated by a comma. This particular script measures the temperature every 1000 milliseconds (1 second) and can be adjusted accordingly.
Now you have the raw data, copy and paste it into excel or spreadsheet of your choice and you can now analyse the data. 

What next? Well, this is just a very basic prototype, the script can be modified to write other outputs and it's got limitations in the classroom as a data logger (it's not waterproof) but this is just the beginning. I'm going to try and hack a few bits of electronics apart like pH meters and temperature probes to see if I can make this more classroom friendly and useable. If you've got any ideas on how to take this further, leave a comment or tweet me @kieronmiddleton 

More detail about the above can be found here: 


The information regarding Teraterm and using serial write was taken from these websites.