How to Interface Arduino with Zilog ePIR Motion Detector.

I am trying to interface Arduino with Zilog ePIR motion detector. Here is the data sheet: As per prescribed on Pg.56 fig.13 on the datasheet, i did the following connection: PIR pin 1 --> Arduino GND pin 2 --> 3v3 (vcc)

PIR pin 1 GND --> Arduino PINS:  GND
      pin  2 VDD -->                        3v3 (vcc)
      pin  3 RXD -->                        TX  Pin1
      pin  4 TXD -->                        RX Pin0 + 100k Resistor to 3v3.
      pin  5 RST -->                        Pin 2
      pin  6 LG  -->                        100k resistor + photodiode to gnd to VCC i.e. 3v3
      pin  7 SLP -->                         Arduino Pin 3
      pin  8 GND -->                         GND

The code I have used to sense the motion is:

int ledPin =  13;    // LED connected to digital pin 13
int pirPin = 2;
int motion = 0;

void setup()   {                
  pinMode(ledPin, OUTPUT);
  pinMode(pirPin, INPUT);

void loop()                     
  motion = digitalRead(pirPin);
    if (motion == HIGH) {
      digitalWrite(ledPin, HIGH);
    } else {
      digitalWrite(ledPin, LOW);

I face the following problem: When I upload this program on Arduino Duemilanove, it turn the led on pin 13 ON all the time. Where as, it should be on only when there is motion in front of the sensor. Where am I going wrong? Thank you.

Looking at the datasheet, you need this device to be in hardware mode. You seem to be pulling up the mode select pin (4) with a resistor. when the datasheet says ..

The Hardware Interface Mode is selected when TXD/SNS is between 0 V and 1.8 V during power ON or when exiting SLEEP Mode.

Its an interesting looking device though. Out of interest why did you select it over a passive IR device?

There has been some discussion about this device on the old forum.

Theres even a library:

Ive used one myself and they are quite easy to use. As Si said you need it in the correct mode.


@Si Frankly speaking, i am using this sensor, since i found it in my garage. I am interested in interfacing it, and look how it works. @GordonEndersby I have google'd for the posts related but i found vague information. I need a bit more lucrative information. And the library which you have addressed, is providing me sufficient data, but i am confused right now. Can you please give me some more information on the connection in detail. As you have used them, will you provide me the schematic data and code? Thanks.

Im not sure what else you need. I used the data sheet and read through the older posts and cobbled something together to work quite quickly. This was before the library cindly contributed by DigitalJohnson was available.

1st step is to wire it up to a power supply and the arduino as per the data sheet and the library example. I also connected the ldr to the epir board rather than the Arduino to save pins.

Have you successfully run the example with the library?


Gordon: I haven't tried using the library but downloaded it and did the pin connection as per given in it. And I am trying to start it in Serial Interface mode, since i think using with arduino i will need to use it with serial only. And one more thing i would like to make note of is: I am using only 1 Resistor i.e. 100k from PIR pin 4 to 3v3 as pull up. Is there requirement for any more resistor? When i do the arrangement of schematic as stated, i see the led ON even when motion is not detected and I have noticed that, the led remains ON when i am connecting any pin to Motion Detect mode pin i have set up on arduino. (Here is am using arduino digital pin 3 for MD.) LDR basically acts as the controller for ambient light, but i am trying it doing in dark or in different light conditions. Still I am facing the problem.

@Anurag I'm the one who wrote the ePIR library. Thanks for your interest. First, I only have an Arduino MEGA, so I wrote the library to use one of the additional serial ports Serial1(pins 19-18), Serial2(pins 17-16) or Serial3(pins 15-14). The first Serial port, pins 0 & 1, are used to by the arduino to communicate with your computer via the arduino's Serial Monitor. You should NOT use pins 0 and 1 to communicate with the ePIR. It's good practice to not use those pins because they're used to upload your sketch and recieve data from the arduino. You could loose the ability to upload sketches if you dont know what you're doing. If you don't have a MEGA the library will have to be changed to use the SoftwareSerial library or the NewSoftSerial library. I have never used either of them (Because I have a MEGA). I'm not experienced enough to port a library to other boards yet. However, if one of the more talented members of this forum (YOU KNOW WHO YOU ARE) would like to coach me a little or point me in the right direction, help in debugging, etc., then I'll give it a try. I love to learn. Anyway, if you have a MEGA, use port 1, 2 or 3 (pins 19-18, 17-16, 15-14) for RX and TX on the arduino. Laod the ePIR example sketch , select the correct serial port with EPIR.Init() function which needs to be called first [before using any other EPIR.function() call] to initialize the device. The device needs a little time to settle before it will detect movement (less than a minute). One more thing, the MD pin of the ePIR is normally HIGH and is pulled LOW when motion is detected. I hope this helps. If you have more questions post them here and I'll answer if I can.

Thanks, DigitalJohnson

I just set this sensor up with SparkFun's relay board and arduino pro mini. Works great. I wanted hardware mode so I tied pins 1& 8 to ground, 2 to 3.3v, 3 to ground for high sensitivity, 4 to ground for the shortest delay, 5 to an analog pin (map anything less than .5v as LOW), pins 6 & 7 to vcc. No resistors necessary. Easy as pie.

LOW on input pin sends HIGH to relay pin and lamp turns on for however long the program says.

Now I'm trying to cobble a code that will reset the on time start if there is motion while lamp is already on. Am trying to mod "blink without delay" or "state change" tutorials, but no luck so far.

Could be an Arduino Mega 2560 linked to an EPIR Zilog senzor without rezistor and read data on analog pin like the simple example above? I connected just as above said, with 3 and 4 pins of EPIR in the +5V. I then collect data on serial from the analog pin 5 that I use and I get like: 0.0000000000 679.0000000000 674.0000000000 683.0000000000 682.0000000000 674.0000000000 5.0000000000 675.0000000000 677.0000000000 674.0000000000 675.0000000000 675.0000000000 0.0000000000 0.0000000000 679.0000000000

Is this correct way to use the above method described?

I used the ePIR module just recently for as a motion trigger for my camera. It is pretty easy to set up. Just have a look at my Fritzing schematic in this post: