Initial report by Luca Shapiro, 25 May 2012

Introduction

The ePIR is a motion detection sensor made by Zilog. The difference between the ePIR and a standard PIR is that this sensor includes an onboard microcontroller called the z8 Encore! XP MCU.

You can connect to the ePIR in two ways: through hardware interface or through serial interface. In hardware mode, you can adjust the sensitivity of the sensor, the delay -- how long after detecting motion before the sensor will look again -- and you can add a light sensor to take into account the ambient light conditions. Serial mode offers all of the same features as hardware mode and also some more advanced configurations. You can set a sensitivity value and a light gate threshold value. You can also ask the sensor to look for motion in only one direction. See the Key Concepts section for more information.

Key Concepts

There are two ways of connecting to the ePIRó hardware interface mode and serial interface mode. The ePIR uses asynchronous serial communication and runs at a 9600 baud rate.

The hardware interface mode allows you to adjust the sensitivity of the sensoró in other words, you can adjust how much motion is required to trigger the sensor. You can also adjust the delay, which determines the interval after the sensor is tripped before it will be active again. There is also an option to input a value for the ambient light level so that the sensor will not be accidentally triggered by changing light values.

The serial interface mode is basically a souped up version of the hardware mode. It has all of the same features as the hardware interface mode, but it also allows for advanced configuration. You can tailor the sensor through the sensitivity settings and also a threshold for the light gate. You can change the range of the sensor so that it is either regular range (3m x 3m) or extended range (5m x 5m). You can also choose to read the directionality of motion. And you can adjust the frequency response settings. Objects in the lower frequency are horizontal, like pets. The ePIR can either react to objects in all frequencies or objects that are just in the upper frequency. This would be a useful setting, for example, if you wanted to create a motion-activated alarm that reacted to people but not pets.

You communicate these advanced configurations by sending ASCII values to the sensor. Here is a list of some of the commands for the ePIR:

  • 'a': Read Motion Status. You will receive 'N' for no motion and 'Y' for motion.
  • 'b': Read Current Light Gate Input Level. You will receive a value between 0-255.
  • 'l': Read Light Gate Threshold. You will receive a value between 0-255.
  • 'L': Write Light Gate Threshold. Then send a value between 0-255 to set the treshold.
  • 'e': Read Extended Range Settings. You will receive a 'Y' if extended range is enables and an 'N' if it is not.
  • 'E': Write Extended Range Settings. Send a 'Y' to enable extended range and an 'N' to disable it.
  • 'f': Read Frequency Response Setting. You will receive an 'L' if both low and high frequency motion is being detected and an 'H' if only high frequency movement is being detected.
  • 'F': Write Frequency Response Setting. Send an 'L' to detect both low and high frequency movement and an 'H' to detect only high frequency motion.
  • 's': Read Sensitivity. You will receive a value between 0-255.
  • 'S': Write Sensitivity. Enter a value between 0-255.
  • 'v': Read Direction. You will receive an 'A' if there is motion in any direction, a '+' if there is motion in the rightward direction, and a '-' if there is motion in the leftward direction.
  • 'V': Write Direction. Send an 'A' to detect motion in all directions, a '+' to detect motion in the rightward direction, and a '-' to detect motion in the leftward direction.

Sources

The ePIR is available from Sparkfun for $11.95.

Applications

The ePIR is most often used for security, for example motion-activated lights, cameras, and alarms. It could also be used for animal camera traps, motion-activated pet food dispensers, holiday props, and robotics.

Electrical Characteristics

The datasheet for the ePIR is very helpful.

The ePIR runs off of 2.7-3.6V. It draws 8.9 mA of current when active at 3.3V. It draws only 2.3 mA when in sleep mode.

The ePIR has an automatic Brownout Reset Threshold to protect the sensor from damage. The brownout typically takes effect at 2.4V.

Pin Descriptions

Pins 1 and 8 are ground. Pin 2 is power. The sensor takes between 2.7 and 3.6V.

Pin 4 is the key for selecting which mode you would like to use. If you supply pin 4 with 0 to 1.8 V, you will be in hardware mode and the amount of voltage you supply this pin will determine the sensitivity of the sensor. 0V is the highest sensitivity, and 1.8V is the lowest sensitivity. If you supply pin 4 with more than 2.5V, you will enter serial interface mode. In serial mode, pin 4 is used to transmit data.

In hardware mode, pin 3 is the delay. This determines how long the sensor will wait after it has detected motion to look again. The delay can be anywhere from 2 seconds to 15 minutes. This feature is useful if youíre tracking people entering a room, for example. You donít want to activate multiple times for the same person, so you institute a properly timed delay. In serial mode, pin 3 is used to receive data.

Pin 5 is motion detection in hardware mode. It reads 0 when motion is detected, 1 when no motion is detected. In serial mode, pin 5 can either be motion detection or reset. It defaults to acting as a reset pin.

Pin 6 is the light gate for both hardware and serial modes. The best way to use this pin is to attach a light sensor like a photocell that will take into account the ambient light in the environment so that changes in light donít falsely trigger the ePIR. When I first set up my circuit, I attached a potentiometer to this pin so that I could adjust the levels manually and see how it affected the sensor.

Pin 7 is sleep. Sleep mode is useful to conserve energy when the sensor does not need to be in use. Like the motion detection pin, this is an active low pin, so when it is sent Ď0í, it goes into sleep mode.

Microcontroller Connections

This is a drawing of the hookup to an Arduino Uno for the hardware interface mode. This is a diagram of the microcontroller connections for the hardware interface mode. There is a photocell connected to pin 6 to take in the ambient light levels.

The most interesting part of this circuit is the potentiometer hooked up to pin 4. The amount of voltage supplied to pin 4 determines whether you go into hardware mode or serial mode. If you give pin 4 between 0 and 1.8V, you go into hardware mode. The entire sensor can take up to 3.6V, which is two times 1.8. So the potentiometer is connected to power and ground through 10K resistors. This splits the voltage evenly. So if youíre connecting to a full 3.6, your max voltage here will be 1.8V. Then you can turn the potentiometer down if you want to lower the voltage, which would increase the sensitivity of the ePIR.

This is a drawing of the hookup for the serial interface to an Arduino Uno. When the sensor powers on, we are sending the full voltage to pin 4 to indicate that we want to use the serial interface. There are two connections to the arduino now, one for reading and one for writing.

Code Sample

ePIR Hardware Interface Sample. Here is an example of the hardware mode in action.

ePIR Serial Interface Sample. Arduino simply acts as a pass-through, you can write your code directly in Processing. Here is an example of the serial mode in action.

Keywords

motion detection, movement, ePIR, PIR, passive infrared, zilog