Hi everyone! We’re here with another circuit design as part of our home automation circuit ideas. This time we’re going to make a home security system that can save you a lot of money. Traditional home security systems often cost hundreds or thousands of dollars and require maintenance or a monthly fee. Therefore, many homeowners and renters decide not to install these systems. But with today’s IoT solutions, you can build your own home security system, that is customized to your needs and your budget.

Generally, there are two types of electronic home security systems:

  • Surveillance – which lets you see what’s going on in the house and around it
  • Sensors – detecting movement or any other thing in the environment of your home (gas, water etc).

The circuit we’re going to show you today is a sensory system. However, that isn’t to say that you can’t also build a surveillance system on top of it, but it may require some heavier coding and possibly more expensive equipment.

Project Description

We’re going to put together a circuit that will detect movement using an ultrasonic sensor and detect doors opening using a magnetic door switch. When that happens, a thin speaker and relay switch will be triggered to sound an alarm and turn on the lights, and simultaneously, a notification will be send to your mobile phone through Wifi. The system will be activated and deactivated using a keypad or fingerprint sensor (depending on your choice).

The circuit

Primary components

Click this link or the image below to see the circuit components.


  • Magnetic door switch set– based on a small reed switch. It’s designed to alert you when doors, drawers, or any other aperture opens. When the two parts of the switch are separated from each other the circuit is broken and the value is changed from 1 to 0.
  • Ultrasonic sensor (HC-SR04) – A low-cost ultrasonic sensor, for your common range measuring needs.
  • Keypad – a simple 4-by-3 keypad matrix. You can set the keys as you wish.
  • Arduino Uno – Arduino/Genuino Uno is a microcontroller board based on the ATmega328P. It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header and a reset button.
  • ESP8266 – a low-cost Wi-Fi board, that you can easily wire to a microcontroller, and connect any project you build to the internet (of things).The microcontroller communicates with the module using AT commands, either via Software Serial or Hardware Serial.
  • Thin speaker – this 0.25W, 8Ohm speaker is going to be used as the alarm. It’s dimensions are 40mm in diameter and about 4mm thick.
  • Relay module – used to isolate components and create a sub-circuit in your circuit, with a different voltage. We are going to set it to turn on the lights when the system detects movement or when the door switch is open.

Secondary components

‘Secondary components’ is a general name for all the components that you need to add to your circuit in order to make it work. We divide these components into:home_security_system_buy_components
General secondary components – non-electronic components you can find in almost every circuit. Such as breadboards, jumper wires, etc.
Specific secondary components – components added to the circuit according to the specific components we want to use. For example resistors, voltage regulators, capacitors, etc. which are present in order to adjust current flow and voltage levels.

You can find information about the secondary components you need for each core component in datasheets and example circuits, and you can also calculate some of their values on your own. When using circuito.io circuit generator, the values of the secondary components are calculated for you automatically.

General secondary components

Breadboard – best for prototyping. Allows you to electrically connect different components using jumper wires.
Jumper Wires M/F and  M/M – used for connecting components to the breadboard.
USB Cable – connects the microcontroller to the computer, for uploading code.

Male headers – soldered to different components, in this case the keypad.

Specific secondary components

Logic level converter – used to coordinate voltage levels between 5V controllers and 3.3V components and vice versa. In this circuit it’s required for the E

SP8266 Wifi module

10k Ohm resistor – a passive two-terminal electrical component that implements electrical resistance as a circuit element.In electronic circuits, resistors are used to reduce current flow, adjust signal levels, to divide voltages, bias active elements, terminate transmission lines and much more.In this circuit it’s required for the magnetic door switch set.

Buying the components

All the components for your circuit can be purchased through the circuito.io website, by clicking on Review and Buy on the right bottom corner.

*some of the components may be temporarily out of stock

You can, of course, buy the components from any other distributor, online store or local electronics store. We have a list of some great maker oriented online stores in this link.


Click this link or the image below for the circuit wiring diagram.


After you’ve put together the circuit, you can download the test code from the project guide and upload it to your Arduino to check your connectivity.

You can also access the code by clicking the image below and clicking on code.

That’s all for this time. Now that you have the circuit set-up, you can start programming it to your needs, adding or removing components according to your personal preferences.

We hope you found this guide helpful. Let us know if you have any comments or questions.