Cheap PIR hack

P1040700c I picked up a motion sensitive nightlight at a thrift store. It runs on 3 AA batteries and lights up 3 pretty bright LED’s if an object approaches the sensor. The one I have goes under different names sysch as the YL-253 (YL stands for Yilin). In the Netherlands it is sold at the ACTION shops for 2.59 euro

As it goes through its batteries pretty fast and one of the dead cells had leaked in the battery comportment, I wondered if I could perhaps use it as a motion sensor for my Arduino.

The case opens with 4 screws and then reveals a circuit board with an LP0001 chip on it and a big fat photosensitive element that probably is a PIS209S or a D203s. The D, S and G of this sensor do not stand for Drain.Source and Gate, but for Drain, Source and Ground. The signal is picked up from the Source. It is a Dual Element detector with an openings angle of 120 degrees. It operates between 3 and 15 Volts and has a load resistance of 47k.

The DIL16 chip is an LP0001. That is a PIR (passive infra-red controller) and supposedly one of the most stable that is available. Sometimes the chip is called TL0001 or BISS0001.

A datasheet gives the following circuit:
Screenshot from 2014-04-10 08:58:05

This is not exactly the circuit in the night light, but it comes close. The Nightlight  e.g. does not have a relay but 3 bright LED’s are driven. It also does not have a an LDR but a photodiode. The function of the  diode (or LDR) is to ensure the night light only works at night. The board also has  switch for On-Off and Auto. On using the circuit, it becomes clear that the LED’s stay on for a  specified amount of time, that is called the Trigger time. The Trigger time is determined by 24576 xR10 x C6. Once triggered, the chip cannot be triggered again for a certain amount of time that is called the Inhibition time. This inhibition time or Ti is defined  by Ti≈24 xR9xC7  (watch out, the Chinese data sheet has switched these two values, the English data sheet is correct). With the current values that wild give a Trigger time of 2.5 seconds and  an inhibition time of 0.036 secs. (These values are for the circuit of the datasheet. in the night lamp the on time is abt 5 seconds)
To get rid of the light/dark function, it suffices to  replace the photo diode with a resistor in the region of 220kOhm.

The data sheet of the LP0001 shows 3 outputs: Output 1 (on pin 16) and Output 2 (on pin 12) as wel as Vo (on pin 2).
Vo is the detector output that is used to drive a transistor (that drives a relay) and it can be used as such. The other two outputs deliver an analog signal.
Output 1 is the output of an opamp (with + and – input). That has a gain of  R7/R8 which is equal to 2M/47K= 40 Output 1 is fed to input 2. That opamp has a gain of R6/R5 = 100. So it seems most logic to pick up the final PIR signal from either opamp 1 or opamp 2. The best seems to be from the Output of opamp 2 on pin 12


What one then only needs to do is to solder a wire to PIN 12 of the chip to pick up the PIR signal and to lead that to an analog input on the arduino.

P1040698c After you have soldered the wire connect that to e.g. analog pin 0 on your arduino and connect the Ground as well.

Copy the following program in your Arduino:

int pirPin=0; 
  Void setup() { 
  pinMode(pirPin, INPUT);
  void loop() { 

Move your hand to and fro the sensor

theoretically this will give readings between 0 and 1023.

If that works and the sensor readings seem to have at least some correlation with your hand movements that means the sensor works.

One can do several things with this output, e.g. use it to drive an LED or a lamp with analogWrite, or use it for a threshold value above or below which e.g. a lamp or relay is switched on or off.

Whatever one choses, it is generally a good idea to take the average of a few readings and one can do that as follows:

int pirPin=0; 
int value=0; 
void setup() 
  Serial.begin(9600); //just to check
  pinMode(pirPin, INPUT); 
void loop() 

int sample(int z) 
/* This function will read the Pin 'z' 5 times and 
   take an average. 
   Afterwards it will be mapped by dividing by 4 
   Could of course immediately divide by 20 but this 
   way it is easier to follow the program 
  int i; 
  int sval = 0; 
  for (i = 0; i < 5; i++){
  sval = sval + analogRead(z);// sensor on analog pin 'z' 
  sval = sval / 5; // average 
  sval = sval / 4; // scale to 8 bits (0 - 255) 
  return sval; 


The digital signal (from Vo) ofcourse can be easily incorporated in a program that reads a digital pin on the Arduino.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s