CCITE Creating fruitful and sustainable links between innovative organisations committed to the improvement of technological education for young people. The Centre for Innovation in Technological Education in Cambridge http://ccite.org Founder: Emeritus Professor Adrian Oldknow MA, MTech, CEng, CITP, CMath, CSci, FBCS, FBIS, FIMA, FRSA The BBC micro:bit for Telemetry – modelling acceleration data from a bouncing elephant Adrian Oldknow [email protected] 20th November 2016 Ever since I learned that the BBC micro:bit had both sensors and Bluetooth I have been yearning to put them into action for telemetry. I wanted the micro:bit to send data wirelessly in real-time to a device with a decent display and memory to plot graphs and store a decent amount of data. Over the past couple of days I have been finding my way around the solution invented by Martin Woolley which I read about in a regular email update from Kitronik. I have bought several great accessories for the micro:bit from them, and have signed up for their newsletter – which you can do on their home page. There are several sources of very useful information which are worth regular visits. Graham’s has his own blog called That IoT Thing. This contains a welter of information about the Bluetooth capabilities of the micro:bit including his new Bitty Data Logger App. For the techies, the Micro:Bit Foundation has its own Bluetooth blog. Graham’s Bitty Software site has the links for the Apple IoS and Android Apps for the Data Logger. I am using the software with my Apple iMac Pro and Samsung S6 Android phone. Ellie is a heavy wooden elephant mobile suspended in a doorway on a long spring. She is carrying a BBC micro:bit attached by an elastic band. As she bounces up and down her accelerometer data is being recorded by the sensors on the micro:bit. The data is being sent by Bluetooth in real-time to my iPad running the Bitty Data capture App. First you need to set up your micro:bit to use the Bluetooth to communicate with your device. I used the editor found here on my Windows laptop in Chrome: https://pxt.microbit.org/. When it opens a fresh screen you will see that there is a Radio block, but not a Bluetooth one. Use the Add Package choice from the toolkit menu (the icon with three bars). Now you can swap in the Bluetooth package in place of the Radio one. The code is short and simple. It is really only just one line! The last line is “Bluetooth accelerometer service” which tries to establish the communication with a paired device. The five lines at the start are just to give visual feedback that the micro:bit is ready to communicate with your device. Enter the program above. Now you can flash this to the micro:bit through the USB cable with the green Download button. Disconnect the USB cable and connect the battery pack. (For convenience I have posted the microbit-Acc-test.hex file here.) Now you can use the Apple micro:bit App from Lawrence Rogers to pair your micro:bit with an Apple device , such as my iPad Pro, or the Android App from Samsung to pair with an Android device like my Galaxy S6. It is probably a good idea to go the Bluetooth settings and remove any already paired micro:bits first. My micro:bit is called ZAZIG. When you start the Bitty Data Logger App you need to Scan for a paired micro:bit. When it has been detected its name appears, and you click on it to establish the connection. If this is successful then the App shows “Connected” and the micro:bit displays the letter “C”. If you check the Bluetooth devices in settings it should appear as “BBC micro:bit Connected”. As a first test it is a good idea to record some data while the system is at rest. The image on the left shows that the y-accelerometer, in blue, is reading a steady value of about 1g. The x- and y-accelerometers are also showing a steady value with x (red) about 0 and z (yellow) a little below zero. This means that the micro:bit is not completely vertical and needs its position adjusting slightly. After the correction we can start Ellie bouncing gently and see that we get a repeated pattern in the blue y-graph, and that the red and yellow graphs are constant at zero. When you have collected your data you can save it on your device as CSV file, and also upload it to the cloud. It gives you a link such as: https://file.io/OhdldZ . If you open the link in a browser on a laptop or PC it automatically copies it to the Downloads folder in Windows. Double-clicking on it opens it in Excel. As the motion is in one direction only, we just need to study the y-accelerations. We can tidy up the sheet by removing the top few rows and the unwanted columns for x- and z-accelerations. We can also insert a first column for the corresponding times. The Bitty App has a default sampling rate of 20ms, which can be adjusted in the Settings option. In cell E1 I have entered the formula “=20/1000” which produces the sample rate as 0.02s. Right-click on cell E1 and select the option to name it. I’ve named as “dt”. Now enter a zero in cell A2 and create the formula “A3=A2+dt” in cell A3. Dragging this formula down you can create the table of time and y-accelerations, and use them to create the scattergraph, which should look like a sine wave. Well you can see that this isn’t quite what we’ve got displayed. At the moment I am not sure why we have the apparent gaps in the data collection, but at least we can see that we are picking up sections of the sine wave! Excel has the facility to fit a “trendline” to a graphed set of data. These include quite an impressive array of functions, but not a sinusoid. So we could certainly mount a micro:bit on a model car and release it to roll down a slope and record the relationship between the angle of the slope and the various accelerations – an experiment which Galileo performed. I am a devotee of the powerful, free GeoGebra software which has extensive tools for data analysis. You can install GeoGebra from here or run it through a browser. You can copy the data from columns A and B. Then you can paste the data into the Spreadsheet View in GeoGebra. The captions “t” and “y” will appear in cells A1 and B1. Right-click on the first row and select “delete”. Click on “A” and shift-click on “B” to highlight both columns of data. From the icon bar select the second one, and pull it down to select “Two Variable Regression Analysis”. If you right-click on the red sine-graph you have the option to “Copy to Graphics View”. The final result has three views. The one on the left is the Algebra View, which show the equation for the red sine graph which GeoGebra has computed. We would expect this to have the correct frequency and phase shift, but it looks as we need to fiddle with amplitude and mean value. So I have used the Input bar to enter a similar function with the mean value as the expected 1 for 1g and a smaller amplitude. This looks a pretty good fit. GeoGebra will perform symbolic manipulation including calculus. So we could integrate the function h(x) once to obtain predicted velocities, and then again for predicted displacements. By taking a video clip of the motion at the same time as data-logging accelerations we could use the free Tracker software to extract the position data for Ellie and compare it with our predictions based on acceleration data. You will find an online guide to using Tracker and GeoGebra here.
© Copyright 2026 Paperzz