Buy from US Buy from UK Buy from DE Buy from FR Buy from IT Buy from ES ここでご購入を!

In this lesson, we will show you how to use motion sensor to detect human movement and how to use MEGA-IoT Shield to report the intruder status to remote computer(browser).

OSOYOO Advanced Board for Arduino MEGA2560 x 1
OSOYOO MEGA-IoT extension board x 1
USB Cable x 1
Red LED PnP module x 1
Green LED PnP module x 1
Yellow LED PnP module x 1
White LED PnP module x 1
Ultrasonic distance SensorPnP module x 1
3-pin PnP cable x 4
4-pin PnP cable x 1

First, please plug OSOYOO MEGA-IoT Extension Board into OSOYOO Advanced Board for Arduino MEGA2560:

Then connect the modules with the OSOYOO MEGA-IoT Extension Board with four 3-pin PnP cables as below:

(Jumper Cap should connect ESP8266 RX with A8, TX with A9)

White LED Module – D9

Yellow LED Module – D10

Red LED Module – D11

Green LED Module – D12

Ultrasonic distance SensorPnP module- Ultrasonic port (4-pin PnP cable)

Notice: Shut off your battery or Unplug your power adapter when upload sketch code to OSOYOO Advanced Board for Arduino MEGA2560.

Step 1 Install latest IDE (If you have IDE version after 1.1.16, please skip this step)
Download IDE from https://www.arduino.cc/en/software, then install the software.

Step 2 WifiEsp Library Installation (if you have installed WifiESP library, please skip this step)

OSOYOO MEGA-IoT extension TX/RX pin to OSOYOO Advanced Board for Arduino MEGA2560 A9/A8 pin by default. So in sketch code, we need use Software Serial Port to communicate with ESP8266 (set A9 as TX and A8 as RX in softwareserial object).

To use this wifi shield in IDE, we need download?WiFiEsp-master library from following link:
https://osoyoo.com/driver/WiFiEsp-master.zip

Open IDE,click Sketch – Include Library- Add .Zip library to load above zip files into IDE.

Step 3 After installing above library, please download the main code from following link, unzip it, you will see a folder called “smarthome-lesson17”:

https://osoyoo.com/driver/smarthome/smarthome-lesson17.zip

Step 4 After above operations are completed, connect OSOYOO MEGA2560 Board to PC with USB cable.

Step 5 IDE:  Choose corresponding board type and port type for you project .

Step 6 IDE:  Click file – Open, then choose code “smarthome-lesson17.ino” in the folder, load up the  sketch onto your OSOYOO Advanced Board for Arduino MEGA2560.

Note: In the  sketch, find  following lines:

char ssid[] = "******"; // your network SSID (name)
char pass[] = "******"; // your network password

please replace the ****** with your correct wifi SSID and password, otherwise your project can not connect to Internet.

After loading the sketch to OSOYOO Advanced Board for Arduino MEGA2560 , open the serial monitor in the upper-right corner of IDE, you will see following result:


From the serial monitor ,  you can see the IP address of your MEGA2560 board in the read circle (in above picture, 192.168.50.102).

Put some obstacle object in front of the ultrasonics sensor,  use your browser to visit the website http://mega2560-ip-address (in above case, http://192.168.50.102), you will see following result:

You will see the red LED will turn on at the same time.

As you slowly move the object from ultrasonic sensor to close distance location, the LED will turn to Green, Yellow, white .

The browser will also show the similar result(but you can not move very fast, browser only update its status every 5 seconds).