Introduction: Create an Alarm System and Visitor Counter for Your Room

You want to get notified when someone enters your room?

You want to know how many visitors you had?

You want a device that says "Goodbye" everytime someone leaves?

In this instructable i will explain how to do this using a Raspberry Pi and a photoelectric barrier unsing laser sensors.

Step 1: Parts List

  • Raspberry Pi
  • 2 Laser photoelectric barriers (i'm using wenglor OY2P303A0135 but there are cheaper ones)
  • perfboard
  • 4 Resistors: 2x 33kOhm, 2x 10kOhm
  • 15V power supply (i used one from an old lenovo laptop)

Step 2: Building the Voltage Divider

The sensors will output 15V when the laser is interrupted.

To not fry our Raspberry we will need to build a voltage divider that converts the 15V from the sensor into 3.3v for the Raspberry to recognize it.

R1 will be the 33kOhm resistor, R2 will be 10kOhm.

The output from the laser is connected to the top port in the schematic, the bottom port to ground. When the sensor outputs 15V, the voltage between the middle pin and ground will be 3.3v.

I built the voltage divider circuits on a perfboard and also used the perfboard to distribute the 15V to the sensors.

Step 3: Connecting the Raspberry

You only need to connect three pins to the Raspberry:

Ground has to be connected to the power supply's ground.

The outputs from the voltage dividers have to be connected to GPIO pins (I used 23 and 24).

I used an old IDE Cable because it fits to the GPIO header.

Step 4: Programming the Raspberry

On your Raspberry with installed Raspbian execute the following commands:

sudo apt-get update

sudo apt-get install python-dev

sudo apt-get install python-rpi.gpio

sudo apt-get install espeak

sudo apt-get install espeak python-espeak

nano alarm.py

Then paste the code found here.

To launch the script type

sudo python alarm.py

Step 5: Finish!

Now your project is finished!

Place your sensors and calibrate, if necessary.

If you are using the same sensors like i do and you have access to a 3D printer, use the mount i made which is available here.

You can also use a case, available here.

Comments

author
seamster (author)2015-07-16

This is a clever little device. Thanks for sharing the details of how you made it!

About This Instructable

2,520views

36favorites

License:

More by ottojo:Toolbox Bodensee e.V.Make your Raspberry Pi speakCreate an alarm system and visitor counter for your room
Add instructable to: