#121 Making a DIY PIR sensor on protoboard

A few years ago I wanted to use some type of sensor for security purposes in my workshop.
I just needed something to sense movement and send a radio signal to my Roboguard device.
An actual Roboguard beam was too expensive, too bulky and large and was not rechargeable… not to mention a bit overkill for my application.
So I decided to look for a low power and small sized PIR sensor. Eventually I was able to find an affordable and small PIR sensor that can operate at 3.3V. I found the MH-SR602 PIR sensor which offers an adjustable delay time with a detection distance of 0 – 3.5 Metres. it has a built in regulator with a range of 3.3 – 15VDC but adds a bit of extra current draw… since I was already using 3.3V for my IC and RF circuits I was able to de-solder the included regulator to save a bit of current. This would help me greatly especially since I was going to use deep sleep.


Now the main MCU is the ATTiny212 and the RF module used is the WL102-341… not sure on the authenticity of the module but it works range is good and the current draw is up to spec + the EN pin does disable the unnecessary current draw when pulled low. The LDO regulator I used is the classic HT7333-A.
After soldering everything and checking for shorts I was able to program the MCU and then power up the device with an recycled 550mAh vape battery. First thing I noticed the device would constantly trigger the PIR. Eventually after a long time of troubleshooting I replaced one of the ceramic capacitors used to stabilize the output of the HT7333-A and now everything worked… Now when looking at the capacitor I didn’t understand exactly why it was not working, there was no short only a really high resistance and the capacity was a bit higher than the specified uf.
Before hand I made sure the PCB would fit into a standard rectangular project box. I just needed to drill a hole for the PIR sensor to stick out. After drilling a hole for the micro USB charging port the project was complete and working.
While testing I was able to achieve a very low current draw in deep sleep mode. I did some basic calculations and the MCU should last more then a year without needing a charge. Later after leaving the device in my workshop I was able to confirm this with the device lasting over a year and a half with mild triggering whenever I was working in the workshop. making use of the ATtiny PIT for long sleep timing and interrupts for waking up the device after some code refactoring I was able to make things super efficient. I programmed everything in C. ASMM is a bit to much for low level stuff in my opinion though I would like to make time to learn it one day. Still I was able to create a program of 956 bytes using ram of 18 bytes. So under 1k was nice since the smallest ATtiny size is 2k so I’ve still got plenty of space.



One thing I can say for sure is that this project really activated a habit in me to try make everything as small and as efficient as possible whenever I program 8-bit microcontrollers for my personal projects. I must say I was also able to save some money when buying IC’s by improving my code and what can I say it feels very good once a project is completed and as small and efficient as I could make it.
With that being said sometimes when using a microcontroller like the ESP8266 or ESP32 the resource abundance feels crazy but once I start populating all that space with HTML and bitmaps + other media I quickly realized that even that space can get used up very fast.
C.A Torino
