Get in touch

Donate

There are many types of Spy Gadgets in market. The App that we are going to discuss in this article can have many utilities, for example :

It can be used to monitor number of times light of a room is switched on/off.

If your child has an independent room you can find out if he is really having good sleep at night.

It can also be used to check some ones sleep pattern because generally when someone wake up at night he turns on light.

So basically this app will give us information of how many times light of a room was turned on and off. Data will be collected by our device built with Arduino. We will use Light Dependent Resistor/Photo-resistor and Blue-tooth module (HC-05) to build our hardware. The Device will keep track of no of times light was turned on and keep transmitting it to the paired/connected devices. The App will be able to establish connection with device and request the count of times light was on.

We can created different health monitoring apps just by modifying some of the things in this app. For example we can use pulse sensor instead of LDR, collect data and view it in different graphical formats in the App.

Connections :

Blue-tooth module is connected same as our previous tutorial. One side of Photo-resistor is connected via 4.7K Ohm resistor to ground, another one is connected to 5v and A0 pin.

Below is the code for our device :

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

#include <SoftwareSerial.h>

SoftwareSerial BTserial(0,1);// RX | TX

unsignedlongcountLightOn=0;

intflag=0;

constintsensitivity=500;

voidsetup(){

// initialize serial communications (for debugging only):

Serial.begin(9600);

}

voidloop(){

// read the sensor:

intsensorReading=analogRead(A0);

// print the sensor reading so you know its range

if(sensorReading<=sensitivity){

flag=0;

}

if(flag==0){

if(sensorReading>sensitivity){

countLightOn++;

flag=1;

}

}

Serial.println(countLightOn);

Serial.println(";");

delay(3000);// delay in between reads for stability

}

In the above code we are using SoftwareSerial library to transmit data. Pins 0 and 1 i.e. Rx and Tx are used for serial communicated between Arduino and Bluetooth module. ‘Sensitivity’ constant determines how much light should give signal of light turned on. A0 pin is used to read signal from Photo-resistor to Arduino. So when LDR signal is higher than its sensitivity then we increase the light counter by one.

The above code is very similar to the code used in our previous tutorial. The new part is that when user taps “No of times light Switched On” button, data from our device is retrieved. The data is long string of data being transmitted since the time connection is established between Device and App. So, to get the latest count we are using delimiter and splitting string to get latest count.