Introduction: Be Aware- Kids Nearby!

It happened to almost every person, child touched or destroyed something valuable.

Our device will help detect when someone is approaching the product, it will send an alert to the owner's mobile phone and also alert with an alarm beep until the person will move away from the product.

Supplies

Hardware

1 X ESP8266 board

1 X HC- SR04

1x LDR

1 X Arduino Speaker

2 X 330 ohm resistor

1X LED

15 X Arduino jumper cables

1 X micro USB cable

1 X Breadboard (to connect everything together)

Software

Arduino program

Blynk (download to your mobile phone)

Adafruit.io user

Step 1: Config ESP8266

first, if you haven't done it already, download the Arduino program.

now we want to connect the ESP8266, this is a low-cost WIFI microchip.

connect the micro usb to the component and put it on your breadboard for your convenience.

You can use the image above when you do it yourself.

now to config this component to your Arduino program, you can use this excellent guide:

https://randomnerdtutorials.com/how-to-install-esp8266-board-arduino-ide/

Step 2: Includes

in the top of your Arduino project, you want to include few libraries.

the first one will help you to connect to the ESP8266.

the last one will help you to connect to the Blynk app usin WIFI.

all others will help you to transfer data to Adafruit.io.

Step 3: ESP8266

To make the ESP8266 work and to be connected to the Blynk app you want to define in your code the details of the WIFI you are connected to.

in the WLAN_SSID you need to fill the name of your WIFI.

in the WLAN_PASS you need to fill your WIFI password.

Step 4: Connect to Blynk App

if you don't have the Blynk app, you need to download it now.

after you downloaded the app and created a user, you want to open a new project.

you can use the photo above as an example.

after the project was created, you will get an email with an Auth Token. we will use it in the next step.

Step 5: Config Blynk in Your Code

now we want to define the following lines.

the ESP_SSID is the name of the WIFI user.

the ESP_PASS is the password of the WIFI.

in "auth[]" you need to fill the auth token you received by email.

Step 6: Code

to setup the Blynk app use this line:

Blynk.begin(auth, ssid, pass);

in the beginning of the loop you should put the next line:

Blynk.run();

you can watch the full code in the end of this guide :)

Step 7: Connect the SC-SR04

connect the SC-SR04 to the breadboard according to this picture.

this component will help you to check if someone is coming next to your valuable object.

Step 8: Code

define the pins according to the connections you made.

#define echoPin D5 // Echo Pin
#define trigPin D6 // Trigger Pin

(D5 and D6 in our example)

define the following-

long duration, distance_data; // Duration used to calculate distance

don't forget to setup-

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

the code above is belong to the loop,

it calculates the distance from any object to our product.

.

Step 9: Connect the LDR

connect the LDR using the photo above.

the connection to the Arduino is same for the ESP8266.

Step 10: Code

define the following-

const int ledPin = 5;
const int ldrPin = A0;

don't forget to setup-

pinMode(ledPin, OUTPUT);
pinMode(ldrPin, INPUT);

the code above is the calculation in every loop.

Step 11: Blynk Notifications

in the project you opened,

tap on the screen and choose notifications.

now you can see it on your board.

Step 12: Code

now we want to make the connection.

create the connection function. you need to call it at the end of the setup.

you also need to check the connection is open at the beginning of the loop:

// ping adafruit io a few times to make sure we remain connected
if (! mqtt.ping(3)) {

// reconnect to adafruit io

if (! mqtt.connected()) {

connect();

}

}

Step 13: Connect the Speaker

now we want to connect the speaker, you can use the picture above.

the purpose of the speaker is to make sound if someone is coming close to the object.

Step 14: Code

define the speaker-

int Speaker = 13; // GPIO13

you also need to setup-

pinMode(Speaker, OUTPUT);
digitalWrite(Speaker, HIGH);

Step 15: Notification and Noise

this part is at the end of the loop,

we will check the relevant values and send a notification and sound when someone is getting close to your object.

you can use our music (in the code) or define anything you want to.

Step 16: Hardware

now your hardware should look similar to the picture above.

Step 17: Adafruit.io

we want to see the log of the distance in the adafruit.io.

first, you need to create a user.

after you create a user, you need to save your Key value- we will use it in the next level. you can see in the picture above how to find the key product.

Step 18: Define Adafruit.io

define your account using this lines-

#define AIO_SERVER "io.adafruit.com"

#define AIO_SERVERPORT 1883

#define AIO_USERNAME "****"

#define AIO_KEY "aio_LOsr380zMS0xHlfCWdECFzjhDRul"

AIO_USERNAME is the user name of your account.

AIO_KEY is the key from the last step.

the code above (you can find it at the end of this guide) is the feeds you want to create, in our example the feed is "distance".

Step 19: Create Distance Chart

create a new block,

choose the kind of block you want to see (it can be a log, chart and many other options).

Step 20:

choose the value you want to track and then put the relevant details.

Step 21: Publish Data

publish data using this lines:

// Publish data
if (! distance.publish((int)distance_data)) {

Serial.println("Failed to publish temperature");

} else {

Serial.println("Distance published!");

}

//Delay 50ms before next reading.

delay(5000); }

Step 22: Run!

run your arduino code :)

when someone is getting close to the object:

1. you will get a notification in your phone.

2. you can see the history of distances in adafruit.io

3. you will hear an alarm that won't stop until the person will go away.

4. you can add a led that will turn on (optional)

Step 23: Code

you can use this full code :)

Step 24: Illustration

https://drive.google.com/open?id=1gMBL5vJBsMn7VVsiwUFVhBp9QX2RCwwY