Door Alert PI


Any actions and or activities related to the material contained within this Website is solely your responsibility. The misuse of the information in this website can result in criminal charges brought against the persons in question. Cyber Security Associates Limited, will not be held responsible for any criminal charges brought against any individuals misusing the information in these projects to break the law.

Please ensure you are using the latest SD Card image which is available here.


Learning Outcomes

  • Configure the Raspberry Pi, pre-assembled breadboard, Raspberry Pi Camera and door sensor; 

  • Understand how the door sensor works;

  • Code a test script and a full script linking the sensor and the Pi Camera together.


Hardware Required


Raspberry Pi + Case

Raspbian SD Card


Door Alert Breadboard

Door Alert Magnetic Sensor

Male Male wires

Male Female Wires

Flat Head Screw Driver


Wireless Keyboard

Wireless Mouse

Power Supply

Component Number (Box Case)

Slot 1

Slot 11

Slot 11

Slot 8 & 9

Slot 8

Slot 11

Slot 11

Slot 11

Slot 11

Slot 11

Slot 12

Slot 13


Video Guide



In this project we have configured multiple hardware peripherals and programmed them to work synchronously in this project. It is important to understand why we have created 2 different scripts to make sure this project works. There is no point jumping to the final step in any project without making sure each step works along the way, this is especially important for hardware and software projects as there are so many areas there can be a misconfiguration. The test script makes sure that we have wired the hardware correctly and are able to prove that it works, then progressing to the final script that then integrates the camera and the sensors.  

It is possible to further this project by adding different items of software. For example, you could configure an email server on the Raspberry Pi to email the image and video to you when the sensor is tripped. Additionally, the project could be configured to trigger a physical alarm that is tripped when the sensor is separated. There are a range of additional configurations for this project and the applications can be very diverse. Do be aware of the security issues when configuring an email server, it requires your email address and email password which are sorted in the config files of the Raspberry Pi. If someone was able to gain access to the Raspberry Pi they would also be able to retrieve the user name and password that are stored as well.