Using Motion Sensor with Raspberry Pi

About This Project

A PIR Motion Sensor is very helpful for projects in the area of homeautomation or security systems. With such a sensor, its possible to track and react to activitys and movements. So you can control other devices, for example lights, when the motion sensor tracks a person, or give on activity.

In the last time a motion sensor is often used in connection with a smart mirror to wake him up. I the near future i want also to create a smart mirror, running a smart mirror software and cayenne to work with sensors etc. Up on this i tried to implement a motion sensor with cayenne and using alerts and triggers.

What’s Connected

I use a raspberry pi 2, normal power supply over micro usb. The pi is connected via LAN to the local area network and to the internet. I work via ssh on the rpi.

An standard motion sensor is connected to the gpio pins. The sensor got a power supply of 5 Volt (pin 2), a cable to ground (pin 6) and the trigger of the sensor is connected to gpio 17 (other gpios possible). A resistor for limit the current is not mandatory - i used no resistor.

For general: if the motion sensor tracks an activity, the output pin of the sensor went to high (3,3 volt) and falls back to 0 volt after a short time. This time (and the sensitivity of the sensor) you can mostly setup over potentiometer.

To setup the motion sensor in cayenne you can search in the supported hardware. In the setup dialog it is important to setup the right channel. The channel is the used gpio number - so in my case channel 17. You can also give a name, setup the state as graph in the dashboard and if your project need it, invert the logic of the sensor.

Triggers & Alerts

In my case i setup an trigger, when the motion sensor went to high. This event i later need to activate my smart mirror.

Photos of the Project

2 Likes

@tooony

Thanks much for this writeup!

I’m going to move this to the FAQs category since it’s such good general information on using a motion sensor with Cayenne and Raspberry Pi, and not too specific to an individual project.

Yes, sure :slight_smile: