Abstract
Have you ever wished you could have an alarm to prevent your little brother or sister from sneaking into your room? How about an alarm to prevent someone from stealing your favorite toy or from taking cookies out of the cookie jar? In this project you will learn how to program your own customized, wireless alarm systems to send you alerts about whatever you want!
Summary
None
See Materials section for details
No issues
Objective
Design and test your own wireless alarm system.
Introduction
Have you ever been in a home or building with an alarm system of any kind? Alarms usually monitor for something dangerous, like the presence of smoke, and then automatically warn people of the danger somehow. For example, smoke alarms may make a very loud beeping sound, flash a bright light, or play a recorded message like "Danger! Fire!" Modern alarm systems may also send an electronic alert, like an email or text message.
There are many different types of alarms. They use a variety of electronic sensors to measure different things. For example, a smoke detector uses a sensor that can detect particles of smoke in the air. A home security system might use a motion sensor that can detect body heat to "see" when someone is moving through a room, or a sound sensor (a microphone) to listen for loud noises, like someone breaking a window.
Some alarm systems use magnets to detect when a door or window has been opened. The strength of the magnetic field around a magnet decreases as you get farther away from the magnet. This means that you can place a magnet sensor on the frame around a door or window, and place a magnet on the door/window (or vice versa). When the door or window opens, the magnet and sensor move farther away from each other, and the strength of the magnetic field measured by the sensor changes. A computer connected to the sensor can react to this change to sound an alarm.
In this project, you will design your own wireless alarm system using a tiny programmable computer board called a micro:bit. The micro:bit has a variety of built-in sensors, including a magnet sensor. This means that a single micro:bit can function as a door or window alarm (Figures 1 and 2). However, the micro:bit also has built-in radio communication abilities. This means that it can wirelessly send a message to another micro:bit. You can design your own alarm system, with one or more sensor micro:bits to detect if a door or window opens, and they can all transmit messages to a base micro:bit (that you can carry around with you) to alert you when something has been opened.


The micro:bit also has a variety of other sensors, including an accelerometer which can detect motion, a light sensor which can measure light levels, and a microphone that can measure sound. All of these sensors could be included in a custom alarm system. The procedure of this project will focus on using magnets and the magnet sensor, but see the micro:bit tutorial series in the Bibliography to learn how to use the other sensors, and check out the Variations section for some ideas on how you can use them in an alarm system.
Terms and Concepts
- Alarm
- Sensor
- Magnetic field
- Micro:bit
- Radio communication
- Accelerometer
- Light sensor
Questions
- What is the purpose of an alarm?
- What are some different electronic sensors used by alarms? What can they detect?
Bibliography
- Finio, B. (n.d.). How to Use a micro:bit. Science Buddies. Retrieved January 14, 2026
- Science Buddies Staff (n.d.). Engineering Design Process. Science Buddies. Retrieved January 14, 2026
Materials and Equipment
- micro:bit Go Bundle (at least 2; more if you would like to have multiple alarms), available from our partner Home Science Tools®. Each kit contains:
- micro:bit board
- USB cable
- Battery holder
- AAA batteries (2)
- Computer with USB port.
- Note: the micro:bit kit comes with a USB-A to micro-USB cable. If your computer only has USB-C ports, you will need a USB-C (male) to USB-A (female) adapter.
- Small magnet (at least one; more for multiple alarms)
- Double-sided foam tape
- Door(s) and/or window(s) that can be opened and closed
Experimental Procedure

- If you have never used a micro:bit before, watch our micro:bit setup video before you continue.
- This is an engineering design project. There is no single "right answer" or correct way to do the project. Think about the criteria and constraints for your project before you continue.
- What do you want your alarm system to monitor? See the introduction for some ideas.
- What sensor(s) will the micro:bit boards need to use?
- How many micro:bit boards do you have available?
- What should the effective range of your transmitter and receiver be?
- How do you want the alarm to be activated? You could use more than one method, for example:
- Play a sound on the transmitter micro:bit to scare away an intruder
- Play a sound on the receiver micro:bit to notify you when an alarm has been activated
- Display a message on the screen of the receiver micro:bit to notify you which alarm has been activated (useful for multiple alarms)
- How should the system react if multiple alarms are triggered at the same time?
- To use the magnet sensor to detect when a door is opened or closed, you will first need to calibrate your sensor. This means you need to know the magnetic field strength values when the magnet is close to the micro:bit and when it is farther away. We recommend watching our micro:bit magnet sensor video before you continue.
- Write a simple program to print a single-axis magnetic force value to the serial monitor (Figure 3).

- Download the program to your micro:bit. Leave the micro:bit plugged into the USB cable, and click
Show data Device. - Watch the serial monitor. Experiment with moving a magnet near your micro:bit. Try changing the magnet's orientation, and moving it closer to/farther away from the micro:bit from different directions. How does the magnetic force value change? Write down the values when the magnet is very close to the micro:bit and when it is at least a few centimeters away.
- Note: the magnetic force value may be positive or negative. Whether the force is positive or negative depends on the direction of the magnetic field (north or south) relative to the magnet sensor's axis.
- Change the magnetic force block to the y-axis and re-download your program. Repeat step 6 and write down the values. Repeat the process again for the z-axis.
- Based on the results of your testing, think about how you will physically mount the micro:bit and magnet to a door or window and the surrounding frame. Think about the constraints and criteria you have to work with:
- There will always be some fluctuations, or noise, in the sensor reading, even when the micro:bit and magnet are holding still. Your goal is for there to be an easily detectable, large change in the magnetic force reading when the door or window opens or closes. What orientation(s) and axis resulted in the biggest change in the magnetic force reading when the micro:bit and magnet moved apart?
- Does this orientation work when it comes to physically mounting the micro:bit and magnet? For example, it is much easier to tape a flat side of a micro:bit to a door than one of the edges.
- Once you have decided on the relative orientations of the micro:bit and magnet and what magnetic force axis you will use, check the magnetic force values you wrote down. What is the value when the micro:bit and magnet are close? What is the value when they are farther away? Choose a threshold value approximately halfway between these two values.
- Write a program for your transmitter micro:bit like the one in Figure 4.
- Figure 4 is just an example - make sure to choose the correct axis and enter the threshold value you chose from your testing.
- Remember that you can choose different actions, like showing different icons or messages on screen, or playing a sound.
- We will add radio communication later - first you will test to make sure this program works.

forever if magnetic force (uT) y > -100 then show icon frown else show icon smile
- Download the new program to your micro:bit.
- Test the program by moving the magnet toward and away from the micro:bit.
- Note: if your micro:bit's behavior seems reversed (it shows the frowning face when the magnet is close, and the smiley face when the magnet is far away), change the greater than (>) sign to a less than (<) sign and re-dowload the program.
- Once you are sure the program works, disconnect your micro:bit from the USB cable and plug it in to the battery pack.
- Use double-sided foam tape to mount your micro:bit and magnet on the door/window and frame.
- Test opening and closing the door/window a few times to make sure the alarm works properly.
- You should now have a working alarm with a single micro:bit. However, what if you are in a different room in your home, and you cannot see or hear the alarm micro:bit? It would be nice if you could automatically receive an alert about the alarm. That is where radio communication comes in. Add a radio send number block to your program as shown in Figure 5.

forever if magnetic force (uT) y > -100 then show icon frown radio send number 1 else show icon smile
- Write a separate program for your receiver micro:bit. Figure 6 shows an example, but remember that you could choose different actions. Download this program to a second micro:bit.

- Test your transmitter/receiver combination.
- Keep the receiver with you. Open the door or window yourself while you are in the same room. Does the alarm sound on the receiver?
- Try having someone else open the door or window while you are in a different room. Does it still work?
- Note that, using the code in Figure 5, the transmitter micro:bit will continue to send radio messages as long as the window is open, and the receiver micro:bit will store these messages in a queue. See the Variations section for more information.
- Once you have a basic working alarm system with a single transmitter and single receiver, it is time to iterate and improve your alarm based on your criteria and constraints. Here are some suggestions. See the Variations section for even more ideas.
- Test the reliability of your system. Do you ever get a false negative where the alarm fails to trigger?
- Can you add a second transmitter micro:bit? Have the second transmitter send a different number in its radio message. Use an
if/else ifstatement in your receiver micro:bit's program to determine which transmitter sent the alarm, and display different messages accordingly. - Test the range of your alarm system. How far away can you go before you stop receiving the alerts?
- Can you improve the range using the
radio set transmit powerblock? - What about the
radio set frequency bandblock? This may be useful if there is interference from other wireless devices in the area, like WiFi routers, cordless phones, or baby monitors. If you change the frequency band, make sure you do it on all the micro:bits you are using.
- Can you improve the range using the
Ask an Expert
Global Goals
The United Nations Sustainable Development Goals (UNSDGs) are a blueprint to achieve a better and more sustainable future for all.
Variations
- Can you make your alarm system use additional sensors?
- The light sensor can detect when someone opens a door or turns on a light in a dark room, or when someone opens the lid of a container.
- The sound sensor can detect loud sounds above a certain threshold.
- The accelerometer can detect different types of motion.
- You could use this as an additional method to detect whether a door or window has been opened, or mount the micro:bit on a portable object to detect when it has been picked up.
- Is the accelerometer sensitive enough to detect vibrations from footsteps?
- Can you add two-way radio communication to your alarm system? For example, make a micro:bit mounted on a door play an alarm sound when the door is opened, and press a button on another micro:bit to silence the alarm.
- What happens to your system when a windor or door is left open for a long time, or multiple alarms are triggered at once? The micro:bit can only respond to one radio message at a time, and it will store additional messages in a queue if it has not finished responding to the first one yet. However, this queue can only hold a certain number of messages, and additional messages will be dropped if the queue is full. This can be a problem if your alarm uses actions that take a long time, like scrolling a message across the micro:bit's screen. Can you write a program that does a better job handling message queueing and multiple alarms?
Careers
If you like this project, you might enjoy exploring these related careers:








