Skip to content


Animal tracker

Beginner | MakeCode, Python | Accelerometer, Radio | 13 Climate, 15 Life on land, Communication, Input/output, Radio waves

Step 1: Make it

What is it?

Use the micro:bit's accelerometer and radio features to make a prototype of a device to help scientists track polar bears or other animals and discover how they are being affected by climate change.

This project is part of a series created to offer problem-solving and prototyping activities designed to explore technology as a solution to the challenges of the Global Goals for Sustainable Development.


Coding guide

What you'll learn

  • How to make a prototype for a larger project
  • How radio communication between electronic devices can be used for scientific study

How it works

  • This program uses the micro:bit's radio feature to make a prototype for tracking the movements of an animal. You can use it in the MakeCode simulator or flash the code on to 2 or more micro:bits. One would be attached to the animal, the other would be used by the scientist as a receiver.
  • First, it sets the radio group to 7. Groups are like channels, so make sure both your micro:bits are using the same group.
  • If several of you are making this project in pairs, make sure each pair uses a unique radio group number. You can pick any group number you like from 0-255.
  • It takes readings from the built-in accelerometer and transmits them by radio.
  • The receiver shows the accelerometer readings on the LED display. Larger numbers mean quicker movements. You can use these numbers to make inferences about an animal's behaviour, for example if it's looking for food, a new habitat or staying in one place to make a home.

What you need

  • 2 micro:bits (or MakeCode simulator)
  • MakeCode or Python editor
  • battery pack (optional)

Step 2: Code it

1from microbit import *
2import radio
6while True:
7    radio.send(str(accelerometer.get_y()))
8    message = radio.receive()
9    if message:
10        display.scroll(message)
11    sleep(2000)

Step 3: Improve it

  • This program measures movement in the Y-axis. The micro:bit's accelerometer can measure forces in other directions, and also give an overall reading of strength. Experiment using different axis measurements to see which works best.
  • Depending on the axis you measure and how you attach the sensor micro:bit, you may notice readings even when the animal is still. This is because of the Earth's gravity, which the micro:bit can also measure! How would you make sure this doesn't affect your readings?
  • What other sensors on the micro:bit could you use to transmit data about an animal?
diagram showing 3 axes in relation to micro:bit board