Using our website means you agree to using cookies which help us improve microbit.org.Learn more
Skip to content

Activity

MakeCode data logger

Advanced | MakeCode | Accelerometer, Radio, USB interface | Data handling, Energy, Forces, Radio waves, Sensors, Weather & climate

Step 1: Make it

What is it?

Use micro:bit as a wireless data logger recording readings from its sensors.

micro:bit showing graph and X, Y and Z axes going across front, up down and front to back resepctively

How it works

  • Flash the transmitter program onto a micro:bit with battery pack and either attach it to something that moves (like the inside of a salad spinner) or get ready to play catch with it.
  • The transmitter takes constant accelerometer readings of the forces in 3 dimensions (x, y and z axes) and transmits them by radio.
  • Connect the receiver micro:bit to a computer and flash the logger program in to it using the Chrome browser or standalone MakeCode app. This receives the accelerometer data and send as serial data to your computer.
  • You should now see a ‘show console device’ button appear below the micro:bit simulator, click on it and you should see graphs of the live data readings appear on the screen.
  • Hold the sensor micro:bit on each of its sides and see how the readings in each axis change. Throw it in the air, spin it in a salad spinner: what do you see?
  • Press ‘pause’ and you can download the numerical data as a CSV (comma separated values) file which you can open in a spreadsheet program to analyse. If you delete the second and third time columns, leaving only the first, you can plot the data on a scatter graph in your spreadsheet showing how the forces change over time.
spreadsheet showing line chart made from accelerometer readings

What you need

  • 2 micro:bits and one battery pack
  • laptop or desktop computer to record data on
  • MakeCode editor (standalone app or web version in Chrome v65 or later)
  • up-to-date firmware (0250 or higher) on the receiving micro:bit
  • optional salad spinner

Step 2: Code it

Sensor / transmitter

Receiver

Step 3: Improve it

  • Record other micro:bit sensor readings remotely this way, such as temperature, light or magnetic compass readings.
  • Conduct a physics experiment into the forces acting on a micro:bit as it spins in a salad spinner (centrifuge). Do you see what you expect? (Bear in mind that the accelerometer on the micro:bit can only read forces up to 2g, twice the force of the Earth’s gravity – if you spin it fast it may experience forces that are too large for it to register.)