Data logging with the BBC micro:bit

Turn your micro:bit into a data logger with the XinaBox IM01 bridge.

Being able to easily record large data files onto a microSD card unlocks activities and experiments that are not possible with the micro:bit's limited built-in memory or using a tethered solution.

Expand the data gathering capabilities of your micro:bit significantly: collect big data anywhere for classroom, hobby or professional use.

It is very quick and easy to build a data logger: the hardware can be assembled in seconds and the code is simple to write. We've even provided some pre-compiled code you can use if you prefer. Get your data logger up and running in three quick, simple steps:

  1. Setting up the hardware
  2. Code
  3. Using the data logger

1: Setting up the Hardware:

You need the following hardware:

  • 1x BBC micro:bit
  • 1x micro:bit USB cable
  • 1x IM01 micro:bit bridge
  • 1x microSD card

 

To assemble the hardware:

  • Format the microSD card and insert it into the slot on the IM01.

It is not always necessary to format the SD card first, but it is recommended. If you are unsure how to format an SD card the process is explained on this wikihow page. When formatting your microSD card: choose "FAT32" (or "FAT" if FAT32 is not available)

When connected together your micro:bit and IM01 should look like this:

The video below shows the components being assembled:

2: Code

You can write your own data logging program for your micro:bit and IM01 using MakeCode. Find out more about the IM01 bridge here.

Alternately you can use pre-compiled code:

  • Download the hex file DataLogger v1.06.hex from this folder.
  • Flash it onto your BBC micro:bit (i.e. connect your micro:bit to your computer then drag and drop the file onto your micro:bit).

If you like writing code it is very easy in MakeCode. The example below shows a program that records GPS data from an XinaBox SN01 GPS sensor and records it onto a microSD card. The same code will work with any XinaBox sensor, and you can use several at the same time:

3: Using the data logger

For power you can use your micro:bit AAA battery holder or connect a USB cable to either the micro:bit or the IM01. There are also a load of battery pack xChip options that will work (check out the full range here).

If you are using the pre-compiled code: with your micro:bit data logger powered up and running do the following:

  • press A to start logging data from the micro:bit internal sensors (accelerometer and magnetometer) to a csv file.
  • Press A again to stop logging.
  • Press A again to continue logging data to the same file.
  • While recording data the LEDs on the micro:bit will pulse on and off and a green light will show on the IM01.
  • While recording click the B-button to tag a record in the data
  • Data is recorded to csv and file sizes of >1gig are possible
  • When you are finished take out the SD card and put it into your laptop to access the data on the csv file.

Extending the data logger:

Do you have an XK04 STEM kit? Specifically, do you have an SW01 weather station or SL01 light sensor?

You can add these xChips to the IM01 and the data logger pre-compiled application will auto-detect them. Weather and / or light data will be recorded and added to the csv file.

The image below shows temperature and humidity data recorded over a 12 hour period and includes more than 20,000 data records:

Data logging need not be limited to recording data onto an SD card. If you have access to the Excel Data Streamer and are interested in LoRa peer-to-peer (P2P) communications you might find the video below interesting. By adding LoRa P2P to the data logger it is possible to communicate data over quite large distances:

If you are interested in finding out more about the LoRa add-on for micro:bit please email us on support@xinabox.zohodesk.com

Troubleshooting (If you are using the pre-compiled code):

When you power up the circuit you should see the following:

  1. The blue power indicator on the right hand side of the IM01 turns on.
  2. The LED on the IM01 may flash blue for a short period.
  3. The LED on the IM01 will turn a solid blue when it is ready to record.

If you do not see a solid blue light, the first thing you should try is removing the power, then powering it up again (yep, the classic turn-it-on-and-off).

The most common issue that we encounter is with microSD cards that are not formatted in FAT. If you have problems please ensure your microSD card is correctly formatted - there are details further up this page that will help.

The circuit may misbehave if you have a CW01 plugged into it. Remove your CW01 if you are having difficulties.

If you continue to have issues please get in touch and we will try to help: support@xinabox.zohodesk.com:


Find out more about XinaBox and micro:bit on our getting started page.