Introduction: Remotely Monitored Motion Detector With Wia

About: Founder at Wia.

For this tutorial, we will be creating a motion detector that can be monitored from anywhere in the world using Wia ( Wia is a cloud platform that enables makers to bring their ideas to life without having to worry about building a real-time infrastructure, managing servers or designing databases.

You will need a Wia account to do this tutorial. You can create one here

Step 1: Parts

Here's a list of the required parts and where you can find them on Amazon (UK).

Step 2: Setup Your Raspberry Pi

Go to to download the latest version of Raspbian. Here's the installation guide on how to prep your MicroSD card and install an image

Now we will connect the PIR to your Raspberry Pi.

  • Connect VCC to GPIO port 2.
  • Connect GND to GPIO port 6.
  • Connect OUT to GPIO port 12.

See the diagram above showing the different ports.

Now connect the Ethernet cable and power supply to your Raspberry Pi.

Step 3: Install Node.js on Your Raspberry Pi

The instructions for this are copied from here

Download Node.js source
Raspberry Pi Model A, B, B+ and Compute Module

tar -xvf node-v4.0.0-linux-armv6l.tar.gz
cd node-v4.0.0-linux-armv6l

Raspberry Pi 2 Model B

tar -xvf node-v4.0.0-linux-armv7l.tar.gz
cd node-v4.0.0-linux-armv7l

Copy to /usr/local

sudo cp -R * /usr/local/

Step 4: Connect to Wia and Publish an Event

Create a device in the Wia dashboard ( Make a note of the device token. You can find it in the device's settings.

Create your project

cd ~
mkdir wia-motion-detector
npm init

Note: Just press 'y' to everything in npm init.

Add packages

npm install --save wia
npm install --save onoff

Create a Device client

touch index.js
nano index.js
var wia = require('wia')('token');

Watch PIR for motion

var Gpio = require('onoff').Gpio,
	pir = new Gpio(18, 'in'); (err, value) {
	if (err) {     throw err;   }{name: "motionDetected"});


node index.js

To check your events, go to the Events tab for your device.