React Native Simple Spy App

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 :

  1. It can be used to monitor number of times light of a room is switched on/off.
  2. If your child has an independent room you can find out if he is really having good sleep at night.
  3. 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 :

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.

Below is the code for our React Native App :

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.

Video Tutorial :