Language Switcher

Human Presence Detect and Time Record Lamp

Make things

Let’s make your room lamp smarter. The lamp turns on automatically when it detects human presence. And It also records the time the lamp turns on at a file on Dropbox.

Materials

How to make

Body

First, attach a Servo Motor to a switch of a lamp on the wall. Please adjust the position of the Servo Motor to put the switch.

Hardware connection

Connect parts to an obniz Board like the table and the image below by referring to Servo Motor Library and PIR Sensor HC-SR505 Library.

obniz parts
0 [Servo Motor] GND
1 [Servo Motor] VCC
2 [Servo Motor] Signal
9 [PIR Sensor HC-SR505] GND
10 [PIR Sensor HC-SR505] Signal
11 [PIR Sensor HC-SR505] VCC

Software

The lamp will turn on by the Servo Motor if it detects human presence.

It also records the time it turns on at a file named “obniz.txt” on Dropbox at this part of turnon function.

dbx.filesUpload({path: '/obniz.txt', contents: "[ON] " + new Date() + "n", mode: 'overwrite' })
  .catch((error) => {
    alert(error);
});

Get Dropbox API Key by referring to the lesson of Integration with Dropbox. Then, change <YOUR ACCESS TOKEN HERE> of program line 1 into your API Key.

This program has a test mode. You can move the Servo Motor by moving the obniz Board switch to the left.

Program