Project tutorial
BLE Motion Detector - ARTIK Cloud

BLE Motion Detector - ARTIK Cloud © GPL3+

Simple motion detector built from a Passive Infrared Sensor and an Arduino/Genuino 101 with a basic nodejs script to log to ARTIK Cloud.

  • 2,194 views
  • 0 comments
  • 4 respects

Components and supplies

Apps and online services

About this project

Overview

This is another sensor for the home automation system. PIR sensors are pretty simple, this project is nearly identical to the connected door switch I made earlier.

Connect the Sensor to the Arduino 101

I bought a generic PIR detector off of Amazon. First thing you want to do is verify the pinout of the 3-pin connector. My pinout was printed on the silkscreen beneath the fresnel lens assembly.

Connect Vcc to 5V, Gnd to Ground, and Out to digital pin 2. Also, connect out to ground with a 10k pulldown resistor. That's it for the wiring - there's two trimpots that control the sensitivity of the PIR and the length of time that it signals high. I set both pots towards the middle, giving me a roughly 5min signal time and a decent amount of sensitivity. You may need to adjust the sensitivity a bit.

The Sketch

It's a pretty simple sketch - it basically reads pin digital pin 2 and changes the value of the BLE characteristic to 1 if motion is detected, or 0 if motion is not. Upload the sketch from the repository to your Arduino/Genuino 101 and away we go!

ARTIK Cloud

Go to your device dashboard and add another device by clicking on "Connect another device..."

Search for PIR Motion Detector and add it to your dashboard.

Click on the gear for your new device and generate a Token. Copy down the Device ID and Token for the upload script.

Uploading Values

Either download the zip or clone the github repository with:

git clone https://github.com/zanycadence/motion_sensor.git

At a command line, enter the directory and then:

Install the dependencies by executing:


npm install

and change the motionBearer and motionId to the Token and ID values generated earlier

//device info 
var motionBearer = "Bearer INSERT_DEVICE_TOKEN_HERE"; 
var motionId = "INSERT_DEVICE_ID_HERE"; 

Note that the dustBearer variable should start with "Bearer " and then your device token.

The script itself is pretty basic - it connects to the 101 and subscribes to the notifications for the motion sensor. When the state of the sensor changes, it connects to the ARTIK Cloud and logs the data. Pretty simple, but having data on motion opens up the possibility of creating powerful and flexible rules that will work with my other connected devices.

Sample Data

Last but not least, here's some sample data I generated of my motion sensing in my office. Works pretty well!

Code

PIR Code
node.js script and arduino sketch for connecting a pir motion detector to the Samsung ARTIK Cloud

Comments

Similar projects you might like

BLE Sharp Dust Sensor - ARTIK IoT Cloud

Project tutorial by Elijah Scheele

  • 4,322 views
  • 1 comment
  • 21 respects

Send Tweets Using Arduino with Artik Cloud

Project tutorial by Jasper

  • 1,653 views
  • 0 comments
  • 9 respects

Water Quality Monitoring Using MKR1000 and ARTIK Cloud

Project tutorial by Team Animo!

  • 7,075 views
  • 12 comments
  • 30 respects

Monitor Fire and Temperature Using ARTIK Cloud

Project tutorial by Samsung IoT

  • 2,585 views
  • 0 comments
  • 21 respects

Smart Home - Smart Rules using ARTIK Cloud & Photon

Project tutorial by Raghavendra Ponuganti

  • 4,126 views
  • 2 comments
  • 13 respects

IoT Command Center - Using Samsung ARTIK Cloud

Project in progress by CJA3D

  • 3,735 views
  • 1 comment
  • 23 respects
Add projectSign up / Login