Culture / Edge / IoT

Off-The-Shelf Hacker: Guard the Yard with Passive Infrared Sensors

15 Oct 2016 3:36am, by

Last week we looked at using an ESP8266 WiFi module model 07 to build a passive infrared sensor. My idea is to put several of these devices around my yard and then log any activity to a LAN-connected Linux machine, likely either a Raspberry Pi or a CHIP computer. The data can then be sliced and diced to determine threats, sift through behavior patterns and notify me of activity in real-time.

At first glance, you may look to ESP8266 model 07. It is easy to use and has an external connector for an optional antenna. With the right antenna you can boost the range of the little device to hundreds of feet. The 07 also has 9 general purpose input/output pins (GPIO). It’s a great little device for hooking up a group of sensors and sending their data over the network.

In the case of a backyard PIR sensor, the 07 is a bit overkill though.

01

Luckily, the ESP8266 model 01 has two GPIO pins and isa great fit for a simple passive infrared sensors sensor application. The next couple of articles will discuss how to migrate from the 07 to the 01 model and cover the details of using the 01 device. I’ll also look at the challenges of building a sensor that will need to be reliable outside in the wind, sun and rain. We have lots of things to talk about, some of it even technical.

Model 01 Setup

Aside from the different number of GPIO pins and a simple printed circuit board antenna, the 01 also has an 8 pin header that’s a real bear to use. You can’t desolder the header from the board, because you’ll rip out the nearly microscopic copper circuit board traces around each header pin. Doing that ruins the board and you’ll just have to throw it away.

So, you’re pretty much stuck with the 8-pin header. My solution is to cut up an old IDE hard drive cable connector and then plug that into the header on the 01. Everybody should have some IDE cables from old desktops, in the junk box. You can make multiple connectors out of a single cable.

Here’s a picture. I’ve removed two of the connectors, so there is still one left to salvage

Recycled Hard-Drive IDE-Cable

Recycled Hard-Drive IDE-Cable

If you want to use store-bought connectors, Adafruit has a ton.

Take the plastic retainer off the top of the connector and carefully peel the cable from the pointed pins. A few pins may pull out with the cable. Just detached them and push them back into the connector.

Count out how many pins you’ll need and then use needle nose pliers to remove the next row of pins. So, if you need an 8 pin connector (4 x 2 pins), remove the two pins in row five.

Next, use a cutoff wheel in a Dremel tool to slice through the plastic connector at row five. You may have to turn the connector over and slice through both sides. Use a sharp knife to smooth out the edges.

I like to use a “third hand” to hold the newly created 8-pin connector (4 x 2 pins) while soldering on the 22-gauge solid core wire, I use for these miniature projects. Recycled solid core phone or Ethernet cable is easy to come by and, usually, has four to six pairs of twisted color coded wires. Solid is much easier to use than stranded.

Like all other ESP8266 modules the 01 runs on 3.3 volts. I build a little 3.3-volt regulator thingy into my projects so I can just feed it from 5 to 12 volts. Here’s a picture.

3.3 Volt Regulator And Capacitors

3.3 Volt Regulator And Capacitors

The 01 only has two GPIO viable pins. GPIO pin 00 is used for programming, so really you only have one. Fortunately, that’s all you need for a PIR sensor.

Flexing the Code

In the spirit of recycling, the code for the 07 and 01 are identical. Even the GPIO 02 pins are the same for the PIR connection. The firmware update procedure is also the same. Make sure GPIO 00 is connected to ground. Unplug the TX pin. Short the RESET pin to ground and then plug the TX pin back in before hitting the upload firmware button in the Arduino IDE. Isn’t it nice to be able to reuse code between different versions of hardware?

Planning an “Outdoor” Device

Making electronic devices work in an outdoor environment is tricky. You have to account for obvious things like rain, animals/birds/bugs and human curiosity.

Intangibles might include where you’ll locate the sensor and how you can make it “stealthy.”

My design uses a piece of 1-1/2-inch schedule 40 PVC end cap and coupling from a home improvement or hardware store. PVC is pretty robust and easy to modify. You can also use pipe cement to make waterproof joints.

I simply measured and cut a square hole to match the lens housing on the front of the PIR sensor. The sensor was then hot glued into the hole. There’s enough room inside the end cap to accommodate the sensor circuit board, voltage regulator power supply and the ESP8266-01 module. The idea is to use point-to-point wiring to connect the modules, so they fit in the housing, without the need for the breadboard. I’ll show details about the wiring in the next column. Minimum viable product (MVP) prototypes should just work, be reliable and be constructed quickly.

I’ll either get the PIR sensor electronics working and seal the whole works inside the housing or put a threaded cap on the back so as to accommodate maintenance or mods as needed.

PIR Sensor Inside The PVC End Cap Housing

PIR Sensor Inside The PVC End Cap Housing

Power is another thing you’ll face when deploying outdoor electronic devices. Years ago I installed 12-volt landscape lighting, running 2-conductor cables to various parts of my yard. The power supply for the lights is an old transformer with a mechanical timer. I don’t use those lights anymore so it makes sense to use the existing wiring to run power to my PIR sensors. I’ll probably end up pulling the end-stops out of the timer wheel and just let the transformer supply 12 volts to the cables all the time.

The PIR sensor works well when supplied with 12 volts, while the built-in 3.3-volt voltage regulator will power the 8266 board nicely.

Lastly, there’s the matter of stealth.

Since this is a prototype, my plan is to get the unit working then simply paint the outside of the PVC housing either camo or flat black, to make it inconspicuous. I’ve chosen several “choke-point” spots around my yard for sensor placement. The choke-points are spots where intruders are forced through an area and where I anticipate activity will most likely occur. I’ll also place the sensors so as to draw minimal attention from casual view during the daytime.

An important side-note is that not only will the sensors detect intruders after installation, the data collected and analyzed during prototyping will verify/refute sensor placement, choke-point effectiveness and help refine the “system” for maximum efficiency.

In the Internet of Things, where everything collects data, lots of opportunities materialize for project analysis and improvement, at all stages of development and production. Integrate that concept into your designs.

How about that? Flash! Big Data analysis takes over the yard.

Follow-on Work

We now have an overview of the key parts to building a workable PIR sensor to detect intruders on your property. Next time, we’ll explore more construction techniques, the point-to-point wiring, buttoning up the device and start testing. Get your soldering iron and big magnifying glass ready.

A newsletter digest of the week’s most important stories & analyses.

View / Add Comments

Please stay on topic and be respectful of others. Review our Terms of Use.