This simple project uses a PIR sensor and a Particle Electron to monitor (green alien?) activity on your remote farm. This setup should work with most PIR sensors out in the market. In this example, we are using the PIR sensor that comes with the Electron Sensor Kit.
Things you'll need:
- Particle Electron
- PIR sensor breakout board
- LiPo battery or a USB power source
- Breadboard or a proto-PCB
- Breadboard wires
The sensor operation is very simple. It pull its output pin HIGH every time it detects an activity in its range. You can change the sensitivity and the pulse length (the amount of time the output remains HIGH upon detecting motion) my adjusting the two potentiometers on the sensor board.
Connect the PIR sensor to the Electron as shown below:
- PIR_GND -- Electron GND
- PIR_VCC -- Electron 3V3
- PIR_OUT -- Electron D0
Here is a good article on how PIR sensors work and how to use them in your projects from Adafruit.
The firmware publishes an event every time it detects a motion. You can use this event to trigger, say for example an IFTTT trigger. Simply set up an IFTTT recipe to send you a notification when your Electron publishes an event. Here is an example of such a recipe.
Since Electron is a data sensitive device, this example assumes offline development. Here is a link to how to compile and flash your source code locally to the Electron.
Checkout the develop branch of the Particle firmware repository and create a new folder under
firmware/user/applications/. Let us name it pir. Now navigate to
firmware/modules and use the following command to rebuild your code base:
(this command assumes you are in the develop branch on the particle firmware repository.)
make clean all PLATFORM=electron APP=pir DEBUG_BUILD=y DEBUG=1 PARTICLE_DEVELOP=1 program-dfu
Note: Before executing the above command, make sure your Electron is in DFU mode and connected to your computer!
This command will rebuild the entire source code and flash the binaries in three chunks, system part 1, system part 2 and the user app. In subsequent builds, you don't have to recompile everything. Simply navigate to
firmware/main and use the same command - this will only flash the user app binary.