Table of Contents

Introduction............................................................................................................................... 4
OSOYOO MEGA-IoT Shield.................................................................................................. 8
What is OSOYOO Mega-IoT Shield.............................................................................. 8
Features.............................................................................................................................8
Specifications.................................................................................................................... 9
Lesson 1: Internet of Things.................................................................................................11
What is the Internet of Things?.................................................................................... 11
What is HTTP?............................................................................................................... 12
What is HTML?...............................................................................................................13
Lesson 2: Model Installation.................................................................................................15
Parts & Devices.............................................................................................................. 15
Model Installation........................................................................................................... 18
Lesson 3: Hello World........................................................................................................... 26
Objective..........................................................................................................................26
Parts & Devices..............................................................................................................26
How to Make................................................................................................................... 26
How to Code................................................................................................................... 28
How to Play..................................................................................................................... 32
Lesson 4: Remote Control LED...........................................................................................34
Objective..........................................................................................................................34
Parts & Devices.............................................................................................................. 34
How to Make................................................................................................................... 34
How to Code................................................................................................................... 35
How to Play..................................................................................................................... 40
Lesson 5: RGB Module.........................................................................................................42
Objective......................................................................................................................... 42
Parts & Devices.............................................................................................................. 42
How to Make................................................................................................................... 42
How to Code................................................................................................................... 43
How to Play..................................................................................................................... 48
Lesson 6: Active Buzzer....................................................................................................... 50
Objective..........................................................................................................................50
Parts & Devices.............................................................................................................. 50
How to Make................................................................................................................... 50
How to Code................................................................................................................... 51
How to Play..................................................................................................................... 56
Lesson 7: DHT11 Sensor..................................................................................................... 58
Objective..........................................................................................................................58
Parts & Devices.............................................................................................................. 58
How to Make................................................................................................................... 58
How to Code................................................................................................................... 59
How to Play..................................................................................................................... 64
Lesson 8: Switching Door.....................................................................................................66
1

Objective..........................................................................................................................66
Parts & Devices.............................................................................................................. 66
How to Make................................................................................................................... 66
How to Code................................................................................................................... 67
How to Play..................................................................................................................... 72
Lesson 9: Gas Detection...................................................................................................... 75
Objective..........................................................................................................................75
Parts & Devices.............................................................................................................. 75
How to Make................................................................................................................... 75
How to Code................................................................................................................... 77
How to Play.....................................................................................................................81
Lesson10: Flame Detection................................................................................................. 83
Objective..........................................................................................................................83
Parts & Devices.............................................................................................................. 83
How to Make................................................................................................................... 83
How to Code................................................................................................................... 84
How to Play..................................................................................................................... 88
Lesson11: Sound Sensor..................................................................................................... 90
Objective..........................................................................................................................90
Parts & Devices.............................................................................................................. 90
How to Make................................................................................................................... 90
How to Code................................................................................................................... 91
How to Play..................................................................................................................... 95
Lesson12: Light Sensor........................................................................................................ 97
Objective..........................................................................................................................97
Parts & Devices.............................................................................................................. 97
How to Make................................................................................................................... 97
How to Code................................................................................................................... 98
How to Play...................................................................................................................102
Lesson13: PIR Motion Detection...................................................................................... 104
Objective........................................................................................................................104
Parts & Devices............................................................................................................104
How to Make.................................................................................................................104
How to Code................................................................................................................. 105
How to Play...................................................................................................................109
Lesson14: LCD Screen....................................................................................................... 111
Objective........................................................................................................................ 111
Parts & Devices............................................................................................................ 111
How to Make................................................................................................................. 111
How to Code................................................................................................................. 112
How to Play................................................................................................................... 116
Lesson15: 1-Channel Relay...............................................................................................118
Objective........................................................................................................................118
Parts & Devices............................................................................................................ 118
2

How to Make................................................................................................................. 118
How to Code................................................................................................................. 119
How to Play...................................................................................................................123
Lesson16: RFID Switching Door....................................................................................... 125
Objective........................................................................................................................125
Parts & Devices............................................................................................................125
How to Make.................................................................................................................125
How to Code................................................................................................................. 127
How to Play...................................................................................................................132
Lesson17: Tracing Human Movement............................................................................. 134
Objective........................................................................................................................134
Parts & Devices............................................................................................................134
How to Make.................................................................................................................134
How to Code................................................................................................................. 135
How to Play...................................................................................................................139
Lesson18: Two Mega-IoT Devices....................................................................................141
Objective........................................................................................................................141
Parts & Devices............................................................................................................141
How to Make.................................................................................................................141
How to Code................................................................................................................. 142
How to Play...................................................................................................................149
Lesson19: Arduino IoT Capstone Project........................................................................ 151
Objective........................................................................................................................151
Parts & Devices............................................................................................................151
How to Make.................................................................................................................151
How to Code................................................................................................................. 153
How to Play...................................................................................................................155

3

Introduction

4

5

6

7

OSOYOO MEGA-IoT Shield
This ESP8266 is an ultra-low power UART WiFi module. The OSOYOO MEGA-IoT
Shield is based on the ESP-12s with the ESP8266 WiFi chip. This shield is designed toeasily connect your Arduino to the IoT world.
It is an Arduino shield which integrates famous ESP-12S WiFi module and provides low
cost WiFi solution with any Arduino MEGA2560 projects. It is compatible with Arduino
Mega2560, and possibly other pin compatible main boards.
Because of IoT (Internet of Thing), everything should be connected to Internet, a crucial
element is WiFi that provides wireless connection to Internet. We have been carrying ESP
module and many have used it. However it is not user friendly enough for beginner. The
module is 3.3V powered and the pins are not properly broken out. Intergrating it to yourmicrocontroller e.g.: Arduino will require some skill and electronics interface.
With this OSOYOO MEGA-IoT Shield, it will be plug and use for Arduino user. The shieldcome preassembled with ESP12S module which offers WiFi connection to your Arduino
MEGA2560 board or project. No additional soldering or wiring needed, just stack theshield on to Arduino or any compatible Arduino main board, select the pins for serial
communication with mini jumpers and the hardware connection is completed! Focus inprogram development, and the good news, there are plenty of libraries that you can utilize,
we will show you the steps!
The ESP12S comes pre-flashed with an AT-command firmware, so it can be controlled by
any UART/Serial, but it also breaks out and provides command access to all of the
ESP8266’s I/O. The shield itself does not limit to AT command, we have breakout most of
the IO and you can program the ESP12S module directly. Whether you want to add AT
commands of your own, or flash custom firmware on the ESP8266, this feature may comein handy especially with it utilizing the UART pin selectors.

1. Standard pin interface to achieve full compatibility with the pitch Arduino Uno,
Mega and so on. (Unless the standard size Arduino, such as Nano, Mini)

2. 3.3V power supply using advanced chip (with the official expansion board power8

chip ESP12S same), so 3.3V Arduino board provided more accurate, so ESP8266
as official chip work as normal, there is no gap.

3. It leads to a WiFi module power supply / service interface to facilitate developers
to extend the power supply and maintenance.

4. Onboard ESP8266-12 stable industrial grade serial WiFi module, using anenhanced PCB antenna, signal better.

5. You can quickly switch DIP switch ESP8266-12 industrial grade WiFi stable
operation mode (such as operating mode and upgrade mode) module, integrated
serial chip, quickly flashing the firmware.

6. Built-in 5V to 3.3V TTL level converter to prevent high-pressure Arduino TTL levelof the WiFi module damage.

7. Onboard ESP8266-12 stable industrial grade WiFi module with a metal shield,
immunity to interference.

8. Onboard ESP8266-12 standard pitch leads to a stable industrial grade WiFi
module all interfaces, enabling developers to easily develop deep.

9. Use stackable design, it can continue to accumulate above the other modules,
easy to use.

10. Onboard four LED displays the status of ESP8266, namely PWR, L, STA

9

Input Voltage: +5VDC Internal Source+7V to 9VDC[External Source)
ESP8266 Module Supply: +3.3VDC
ESP Shield Default Baudrate Settings are 9600 kbps baudrate, 8 bit data, 1 stop bit andno parity
Onboard ESP12S WiFi module with preloaded AT firmware
Jumper selectors for software or hardware UART and PC-ESP communication.
Stackable Digital I/O header: This header pin is Digital I/O pin stacked to the OSOYOO
MEGA2560 board. Other Arduino shield can be stacked on top of this stackable header.
Stackable Analog Input pin header: This header pin is Analog Input pin stacked to the
OSOYOO MEGA2560 board. Other Arduino shield can be stacked on top of this stackable
header.
Serial Selector: User may select A8 as the RX pin, select A9 as the TX pin from OSOYOO
MEGA2560 board with the mini jumpers.

10Lesson 1: Internet of Things
In a nutshell, the Internet of Things is the concept of connecting any device (so long as it
has an on/off switch) to the Internet and to other connected devices. The IoT is a giant
network of connected things and people – all of which collect and share data about theway they are used and about the environment around them.
The Internet of Things is actually a pretty simple concept, it means taking all the things in
the world and connecting them to the internet.

There are three key elements of IoT:
 Devices — Rather than conventional devices like smartphones and computers,“devices” in IoT can be anything from a toaster to complex machines in industries.
 Data — This is where IoT holds its value. Data is of utmost importance, as this is thebasis for intelligent decision making.
 Connectivity – Obviously, the devices require some sort of network connection tocommunicate. There are a bunch of network architectures available today, which canbe used for seamless transmission of data. A lot of IoT-specific networks are also in
the works.
Why IoT Matters?
In short words, IoT will improve our life quality and productivity in an amazing way. In

11next 5 to 10 years, as the 5G network being deployed to every corner of our world, IoT will
be part of daily life and generate a lot of business opportunities and job positions. So it isnever too late to learn IoT technology in the coming smart society.

HTTP stands for Hyper Text Transfer Protocol.
Introduction
The WEBInternet (or The Web) is a massive distributed client/server information system as
depicted in the following diagram.

Many applications are running concurrently over the Web, such as web browsing/surfing,e-mail, file transfer, audio & video streaming, and so on.
In order for proper
communication to take place between the client and the server, these applications must
agree on a specific application-level protocol such as HTTP, FTP, SMTP, POP, and etc.
WORLD WIDE WEB COMMUNICATION
The World Wide Web is about communication between web clients and web servers.
Clients are often browsers (Chrome, Edge, Safari), but they can be any type of programor device.
Servers are most often computers in the cloud.

12

HYPERTEXT TRANSFER PROTOCOL (HTTP)







HTTP (Hypertext Transfer Protocol) is perhaps the most popular application protocol
used in the Internet (or The WEB).
HTTP is an asymmetric request-response client-server protocol as illustrated. An
HTTP client sends a request message to an HTTP server. The server, in turn,
returns a response message.
In other words, HTTP is a pull protocol, theclient pulls information from the server (instead of server pushes information down totheclient).

HTTP is a stateless protocol. In other words, the current request does not know what
has been done in the previous requests.
HTTP permits negotiating of data type and representation, so as to allow systems to
be built independently of the data being transferred.
Quoting from the RFC2616: “The Hypertext Transfer Protocol (HTTP) is anapplication-level protocol for distributed, collaborative, hypermedia information
systems. It is a generic, stateless, protocol which can be used for many tasks beyond
its use for hypertext, such as name servers and distributed object management
systems, through extension of its request methods, error codes and headers.”

HTTP REQUEST / RESPONSE
Communication between clients and servers is done by requests and responses:
A client (a browser) sends an HTTP request to the web
An web server receives the request
The server runs an application to process the request
The server returns an HTTP response (output) to the browser
The client (the browser) receives the response13HTML is the standard markup language for creating Web pages.
 HTML stands for Hyper Text Markup Language HTML describes the structure of a Web page
 HTML consists of a series of elements
 HTML elements tell the browser how to display the content
 HTML elements are represented by tags
 HTML tags label pieces of content such as “heading”, “paragraph”, “table”, and so on
 Browsers do not display the HTML tags, but use them to render the content of thepage

A SIMPLE HTML DOCUMENT
ExampleTry it Yourself »Example Explained

You can learn more about HTML from: https://www.w3schools.com/html/default.asp

14

Lesson 2: Model InstallationNo.

Device1

PictureQty.

Accessories

Wooden House Model

1

Rubber Rings

2

OSOYOO MEGA2560
Board

1

3

OSOYOO MEGA-IoT
Extension Board

1

4

Photosensitive Sensor

15Temp & Hum Sensor

1

6Buzzer Module

1

7Flame Detection Sensor

115

1-Channel Relay

1

9

Micro Servo Motor

1

10

RGB Module

1

11

Ultrasonic Sensor

1

12

PIR Motion Sensor

1

13

Microphone Module1

141602 I2C LCD Screen

115

Gas Detection Module

1

16

RFID Module

1

8

16

17

4*4 Keypad

118

Yellow LED Module

1

19

Red LED Module

1

20

Green LED Module

1

21White LED Module

1

22

Red Button Module1

23

Blue Button Module1

24

Philips Screwdriver

125

M1.4*10 Screws & Nuts

4

17

26

M2 Push Pin Rivets

227

M3 Push Pin Rivets

1028

M4 Push Pin Rivets

38

1. FLOOR BOARD
Please plug OSOYOO MEGA-IoT Extension Board in OSOYOO Mega2560 board.
(If the extension board has been plugged, please keep it. )18

Then use M3 Push Pin Rivets to install OSOYOO Mega2560 board on the wooden floorboard.
Notice: Please install the M3 Push Pin Rivets from the back side of the floor board.

2 BACK BOARD
19

Use M4 Plastic Fastener to install the following modules on the back board:

3 LEFT BOARD
Use M4 Plastic Fastener to install the following modules on the left board:

4 RIGHT BOARD
Use M4 Plastic Fastener to install the following modules on the right board:20

5 PARTITION BOARD
Use M4 Plastic Fastener to install the following modules on the partition board:

6 FRONT BOARD
Install the following modules on the partition board:21

7 ASSEMBLE
Step1: Insert the Back Board into Floor Board and fasten it with rubber rings (see picture).

Step2: Insert the Left Board into Floor Board and fasten it with rubber rings.

22

Step3: Insert the Right Board into Floor Board and fasten it with rubber rings.

Step4: Insert the Partition Board into middle of Floor Board.

23

Step5: Insert the L-Partition Board between Left Board and Partition Board.

Step6: Insert the Front Board into Floor Board and fasten it with rubber rings.

24

The model installation is completed, the wire connection and projects please view thesubsequent lessons of OSOYOO Smart Home IoT Learning Kit with MEGA2560.

25

Lesson 3: Hello World
In order to connect our Things to Internet, we need select some Internet communication
protocol so that different internet device can talk with each other. Some commonly used
IoT protocols are HTTP, MQTT etc.
In this lesson, we will learn how to use HTTP protocol andhow to make simple HTTP
web server with Osoyoo MEGA-IoT shield and MEGA2560 micro-controller and show a“Hello World!” web page to remote browser . The web page also shows the input voltageof A0 pin which is detected by Arduino analogRead() functions.






OSOYOO MEGA 2560 board x 1
OSOYOO MEGA-IoT extension board x 1
USB Cable x 1
Male to Male jumper wire x 11) . Please plug OSOYOO MEGA-IoT Extension Board into MEGA2560 board:262) . Connect A0 to 5V by Male to Male jumper wire. (Jumper Cap should connect
ESP8266 RX with A8, TX with A9).

27

Notice: Unplug your power adapter when upload sketch code
to Arduino.

Software Installation
Open-source Arduino
Software(IDE)

Download Arduino IDE here:
https://www.arduino.cc/en/Main/Software?setlang=en

7 zip is a free zip
utility that un-zips zip files

Download 7zip here for freehttps://www.7-zip.org/

Step 1 Install latest Arduino IDE (If you have Arduino IDE version after 1.1.16, please skip
this step).
Download Arduino IDE from https://www.arduino.cc/en/Main/Software?setlang=en, theninstall the software.

Step 2 OSOYOO MEGA-IoT extension TX/RX pin to Arduino A9/A8 pin by default. So in
28

Arduino sketch code, we need use Software Serial Port to communicate with ESP8266(set A8 as RX and A9 as TX in software serial object).we need download WiFiEsp-masterlibrary from following link firstly: http://osoyoo.com/driver/WiFiEsp-master.zip
Step3 Open Arduino IDE ->Sketch ->Include Library ->Add ,Zip library to load above zip
files into Arduino IDE.

Step 4 After installing above library, please download the main code from following
link.unzip the download zip file lesson3.zip, you will see a folder called
smarthome-lesson3.
http://osoyoo.com/driver/smarthome/smarthome-lesson3.zip
Step 5 After above operations are completed, connect OSOYOO MEGA2560 Board to
PC with USB cable.

29

Step 6 Open the Arduino IDE and choose corresponding board type and port type for you
project.

Step 7 Arduino IDE: Click file -> click Open -> choose code “smarthome-lesson3”, loadup the sketch onto your Arduino.
30

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.

31

After loading the sketch to Arduino , open the serial monitor in the upper-right corner ofArduino IDE, you will see following result:32

From the serial monitor, you can see the IP address of your MEGA2560 board in the readcircle (in above picture, 192.168.50.102).
Then use your browser to visit the website http://mega2560-ip-address (in above case,
http://192.168.50.102), you will see following result:

Above result also shows the A0 pin input voltage through analogRead(0) function in line
94. analogRead() can read the input 0-5V voltage and return a value between 0 to 1023
standing for the voltage. We have connected A0 to 5V, so above Analog input A0: shows
1023.

33

Lesson 4: Remote Control LED
In this lesson, we will show you how to make simple Internet of Things (IoT) project – toturn on/off an LED from a remote browser .
We will use OSOYOO Mega-IoT Shield to connect LED and MEGA2560 MCU board.
Arduino MEGA2560 board can work as a web server. Remote browser can access thisweb server and control the LED connected to D13 pin of MEGA2560.








OSOYOO MEGA2560 Board x 1
OSOYOO MEGA-IoT Extension Board x 1
LED PnP Module x 1
OSOYOO 3-Pin PnP Cable x 1
USB Cable x 1
PC x 1First, please plug OSOYOO MEGA-IoT Extension Board into MEGA2560 board:

34

Then connect the LED module to the D13 port of the OSOYOO MEGA-IoT Extension
Board with a 3-pin PnP cable as below (Jumper Cap should connect ESP8266 RX with A8,
TX with A9):

Notice: Unplug your power adapter when upload sketch code
to Arduino.

Step 1 Install latest Arduino IDE (If you have Arduino IDE version after 1.1.16, please skip
this step)

Download Arduino IDE from https://www.arduino.cc/en/Main/Software?setlang=en , theninstall the software.

35

Step 2 WifiEsp Library Installation (if you have installed WifiESP library, please skip thisstep)
OSOYOO MEGA-IoT extension TX/RX pin to Arduino A9/A8 pin by default. So in Arduino
sketch code, we need use Software Serial Port to communicate with ESP8266 (set A8 as
RX and A9 as TX in softwareserial object).
To use this wifi shield in Arduino IDE, we need download WiFiEsp-master library fromfollowing link:
http://osoyoo.com/driver/WiFiEsp-master.zip
Open Arduino IDE, click Sketch – Include Library- Add .Zip library to load above zip files
into Arduino IDE.

36

Step 3 After installing above library, please download the main code from following link,unzip it, you will see a folder called “smarthome-lesson4”:
http://osoyoo.com/driver/smarthome/smarthome-lesson4.zip
Step 4 After above operations are completed, connect OSOYOO MEGA2560 Board to
PC with USB cable.

37

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

Step 6 Arduino IDE: Click file – Open, then choose code “smarthome-lesson4.ino” in thefolder, load up the sketch onto your Arduino.

38

Note: In the sketch, find line 24，25 as following: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.

39

After loading the sketch to Arduino , open the serial monitor in the upper-right corner ofArduino IDE, you will see following result:40

From the serial monitor, you can see the IP address of your MEGA2560 board in theread circle (in above picture, 192.168.50.102).
Then use your browser to visit the website http://mega2560-ip-address (in above case,
http://192.168.50.102), you will see following result:

Click the two links as showed in above picture, you will turn on/off the LED module whichis connected to your MEGA2560 through the IoT Shield.

41

Lesson 5: RGB Module
In this lesson, we will show you how to control the RGB LED from a remote browser .
We will use Osoyoo Mega-IoT Shield to connect the RGB and MEGA2560 MCU board.
Arduino MEGA2560 board can work as a web server. Remote browser can access thisweb server and control the RGB connected to the RGB interface of this shield.







OSOYOO MEGA2560 Board x 1
OSOYOO MEGA-IoT extension board x 1
USB Cable x 1
RGB PnP module x 1
4-pin PnP cable x 1First, please plug OSOYOO MEGA-IoT Extension Board into MEGA2560 board:

Then connect the RGB module to the RGB port of the OSOYOO MEGA-IoT Extension
Board with a 4-pin PnP cable as below (Jumper Cap should connect ESP8266 RX with A8,42

TX with A9):

Notice: Unplug your power adapter when upload sketch code
to Arduino.

Step 1 Install latest Arduino IDE
skip this step).

(If you have Arduino IDE version after 1.1.16, please

Download Arduino IDE from https://www.arduino.cc/en/Main/Software?setlang=en, theninstall the software.

43

Step 2 WifiEsp Library Installation (if you have installed WifiESP library, please skip thisstep)
OSOYOO MEGA-IoT extension TX/RX pin to Arduino A9/A8 pin by default. So in Arduino
sketch code, we need use Software Serial Port to communicate with ESP8266 (set A8 as
RX and A9 as TX in softwareserial object).
To use this wifi shield in Arduino IDE, we need download WiFiEsp-master library fromfollowing link:
http://osoyoo.com/driver/WiFiEsp-master.zip
Open Arduino IDE ->Sketch ->Include Library ->Add ,Zip library to load above zip files into
Arduino IDE.

44

Step 3 After installing above library, please download the main code from following
link.unzip the download zip file lesson5.zip, you will see a folder called
smarthome-lesson5.
http://osoyoo.com/driver/smarthome/5/smarthome_lesson5.zip

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

45

Step 5 Open the Arduino IDE and choose corresponding board type and port type for you
project.

Step 6 Arduino IDE: Click file -> click Open -> choose code “smarthome-lesson5”, loadup the sketch onto your Arduino.
46

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.

47

After loading the sketch to Arduino , open the serial monitor in the upper-right corner ofArduino IDE, you will see following result:48

From the serial monitor, you can see the IP address of your MEGA2560 board in the readcircle (in above picture, 192.168.50.8).
Then use your browser to visit the website http://mega2560-ip-address (in above case,
http://192.168.50.8), you will see following result:

Click the three links as showed in above picture, you will switch the color of RGB module
which is connected to your MEGA2560 through the IoT Shield.

49

Lesson 6: Active Buzzer
In this lesson, we will show you how to control an active buzzer from a remote browser .
We will use Osoyoo Mega-IoT Shield to connect the active buzzer and MEGA2560
MCU board. Arduino MEGA2560 board can work as a web server. Remote browser canaccess this web server and control the active connected to the buzzer connected to D5
pin of MEGA2560.








OSOYOO MEGA2560 Board x 1
OSOYOO MEGA-IoT Extension Board x 1
Active Buzzer PnP module
OSOYOO 3-Pin PnP Cable x 1
USB Cable x 1
PC x 1First, please plug OSOYOO MEGA-IoT Extension Board into MEGA2560 board:

50

Then connect the buzzer module to the D5 port of the OSOYOO MEGA-IoT Extension
Board with a 3-pin PnP cable as below (Jumper Cap should connect ESP8266 RX with A8,
TX with A9):

Notice: Unplug your power adapter when upload sketch code
to Arduino.

Step 1 Install latest Arduino IDE (If you have Arduino IDE version after 1.1.16, please skip
this step)
Download Arduino IDE from https://www.arduino.cc/en/Main/Software?setlang=en , theninstall the software.

51

Step 2 WifiEsp Library Installation (if you have installed WifiESP library, please skip thisstep)
OSOYOO MEGA-IoT extension TX/RX pin to Arduino A9/A8 pin by default. So in Arduino
sketch code, we need use Software Serial Port to communicate with ESP8266 (set A8 as
RX and A9 as TX in softwareserial object).
To use this wifi shield in Arduino IDE, we need download WiFiEsp-master library fromfollowing link:
http://osoyoo.com/driver/WiFiEsp-master.zip
Open Arduino IDE, click Sketch – Include Library- Add .Zip library to load above zip files
into Arduino IDE.

52

Step 3 After installing above library, please download the main code from following link,unzip it, you will see a folder called “smarthome-lesson6”:
http://osoyoo.com/driver/smarthome/6/smarthome_lesson6.zip
Step 4 After above operations are completed, connect OSOYOO MEGA2560 Board to
PC with USB cable.

53

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

Step 6 Arduino IDE: Click file – Open, then choose code “smarthome-lesson6.ino” in thefolder, load up the sketch onto your Arduino.

54

Note: In the sketch, find the lines as following: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.

55

After loading the sketch to Arduino, open the serial monitor in the upper-right corner ofArduino IDE, you will see following result:56

From the serial monitor, you can see the IP address of your MEGA2560 board in the readcircle (in above picture, 192.168.50.8).
Then use your browser to visit the website http://mega2560-ip-address (in above case,
http://192.168.50.8), you will see following result:

Click the two links as showed in above picture, you will turn on/off the active buzzer
module which is connected to your MEGA2560 through the IoT Shield.

57

Lesson 7: DHT11 Sensor
In this lesson, we will show you how to get DHT11 data remotely, this example shows how
value can be pushed from Arduino to a remote browser.
We will use Osoyoo Mega-IoT Shield to connect DHT11 sensor and MEGA2560 MCU
board. Arduino MEGA2560 board can work as a web server. Remote browser can accessthis web server and get the data of DHT11 connected to D2 pin of MEGA2560.







OSOYOO MEGA2560 Board x 1
OSOYOO MEGA-IoT extension board x 1
USB Cable x 1
DHT11 PnP module x 1
3-pin PnP cable x 1First please plug OSOYOO MEGA-IoT Extension Board into MEGA2560 board:

58

Then connect the DH11 Temp & Hum Sensor to the D2 port of the OSOYOO MEGA-IoT
Extension Board with a 3-pin PnP cable as below ： (Jumper Cap should connect
ESP8266 RX with A8, TX with A9):

Notice: Unplug your power adapter when upload sketch code
to Arduino.

Step 1 Install latest Arduino IDE (If you have Arduino IDE version after 1.1.16, please skip
this step)
Download Arduino IDE from https://www.arduino.cc/en/Main/Software?setlang=en , theninstall the software.

59

Step2 WifiEsp Library Installation (if you have installed WifiESP library, please skip thisstep)
OSOYOO MEGA-IoT extension TX/RX pin to Arduino A9/A8 pin by default. So in Arduino
sketch code, we need use Software Serial Port to communicate with ESP8266 (set A8 as
RX and A9 as TX in softwareserial object).
To use this wifi shield in Arduino IDE, we need download WiFiEsp-master library fromfollowing link:
http://osoyoo.com/driver/WiFiEsp-master.zip
You need go to Arduino IDE ->Sketch ->Include Library ->Add ,Zip library to load above
zip files into Arduino IDE.

60

To use the DHT11 sensor here, you also need to install the DHT11 library as above
operations.

61

Step 3 After installing above libraries, please download the main code from following link,unzip it, you will see a folder called “smarthome-lesson7”:
http://osoyoo.com/driver/smarthome/7/smarthome_lesson7.zip
Step 4 After above operations are completed, connect OSOYOO MEGA2560 Board to
PC with USB cable.

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

62Step 6 Arduino IDE: Click file – Open, then choose code “smarthome-lesson7.ino” in thefolder, load up the sketch onto your Arduino.

Note: In the sketch, find line 24，25 as following: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.

63

After loading the sketch to Arduino , open the serial monitor in the upper-right corner ofArduino IDE, you will see following result:64From the serial monitor, you can see the IP address of your MEGA2560 board in the readcircle (in above picture, 192.168.50.8).
Then use your browser to visit the website http://mega2560-ip-address (in above case,
http://192.168.50.8), you will see following result:From here, you can see a simple web server that shows the temperature and humidity
data of the DHT11 sensor. The web page will be automatically refreshed each 20 seconds.
Wait a minute, you may see the following data on the web page：65

Lesson 8: Switching DoorIn previous lessons, we have showed how to use web browser to access Arduino Board
through Internet. In these examples, we used a protocol called HTTP. Arduino works as a
HTTP server(web server) and response to request from browser(client) .
In this lesson, we will teach you to use a very simple and power protocol called UDP whichis commonly used for Email service and control signal. We will use a cell phone APP tosend angle control signal to remote Arduino and make the servo to make a rotate at a
specific angle.
We will also show you how to use a Keypad to control the servo locally.









OSOYOO MEGA2560 Board x 1
OSOYOO MEGA-IoT Extension Board x 1
LED PnP Module x 1
Servo x 1
OSOYOO 3-Pin PnP Cable x 1
USB Cable x 1
PC x 1First, please plug OSOYOO MEGA-IoT Extension Board into MEGA2560 board:

66

Then connect the LED module to the D12 port of the OSOYOO MEGA-IoT Extension
Board with 3-pin PnP cable, connect servo motor to the D3 port as below (Jumper Cap
should connect ESP8266 RX with A8, TX with A9):

Notice: Unplug your power adapter when upload sketch code
to Arduino.
67

Step 1 Download OSOYOO Wifi UDP Robot Car control APP
In Google Play or Apple Store, please search key words “OSOYOO Wifi UDP Robot Car”,
you will find an orange icon APP as following:

Step 2 WifiEsp Library Installation (if you have installed WifiESP library, please skip thisstep)
OSOYOO MEGA-IoT extension TX/RX pin to Arduino A9/A8 pin by default. So in Arduino
sketch code, we need use Software Serial Port to communicate with ESP8266 (set A8 as
RX and A9 as TX in softwareserial object).
To use this wifi shield in Arduino IDE, we need download WiFiEsp-master library fromfollowing link:
http://osoyoo.com/driver/WiFiEsp-master.zip
In order to use the keypad, you also need download and install a keypad library from:https://osoyoo.com/driver/smarthome/Keypad.zip
Open Arduino IDE, click Sketch – Include Library- Add .Zip library to load above zip files
into Arduino IDE.

68

Step 3 To use the Servo in Arduino IDE, we need download Servo.h library from thislink and save it as above operations.
Step 4 After installing above library, please download the main code from following link,unzip it, you will see a folder called “smarthome-lesson8B”:
https://osoyoo.com/driver/smarthome/smarthome_lesson8B.zip
Step 5 After above operations are completed, connect OSOYOO MEGA2560 Board to
PC with USB cable.

69

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

Step 7 Arduino IDE: Click file – Open, then choose code “smarthome-lesson8.ino” in thefolder, load up the sketch onto your Arduino.

70

Note: In the sketch, find line 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.

71After loading the sketch to Arduino , open the serial monitor in the upper-right corner ofArduino IDE, you will see following result:72

You will Arduino’s IP address and Port Number as following:

From the serial monitor, you can see the IP address of your MEGA2560 board in theread circle (in above picture, 192.168.50.47) and default port number is 8888, you needwrite the IP address into your APP Setting as following:73

Click the two links as showed in above picture, you will control the servo which isconnected to your MEGA2560 through the IoT Shield.
Now in your APP,
when you click ◄ button, the servo will point zero degree, Green LED is OFF.
Serial Monitor will show Close THE DOOR!
when you click ▲ button, the servo will point 90 degree, Green LED is OFF.
Serial Monitor will show Half Close THE DOOR!
when you click ► button, the servo will point 180 degree, Green LED is ON.
Serial Monitor will show OPEN THE DOOR!
You can also use Keypad to control the servo.
when you click * Button, the servo will point zero degree, Green LED is OFF.
Serial Monitor will show Close THE DOOR!
when you click 0 button, the servo will point 90 degree, Green LED is OFF.
Serial Monitor will show Half Close THE DOOR!
when you click # button, the servo will point 180 degree, Green LED is ON.
Serial Monitor will show OPEN THE DOOR!

74

Lesson 9: Gas Detection
In this lesson, we will show you how to make use Internet to monitor remote Smoke
Sensor status.
We will use Osoyoo Mega-IoT Shield to connect Fire Sensor, LEDs and MEGA2560 MCU
board. Arduino MEGA2560 board can work as a web server. Remote browser can accessthis web server to shows fire sensor real time status.









OSOYOO MEGA2560 Board 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
Gas Sensor PnP module x 1
3-pin PnP cable x 3

First please plug OSOYOO MEGA-IoT Extension Board into MEGA2560 board:

75

Then connect the modules to the OSOYOO MEGA-IoT Extension Board with 3-pin PnP
cables as below. (Jumper Cap should connect ESP8266 RX with A8, TX with A9)Green LED module—D12
Red LED module—-D11
Gas Detection module—A3 (Make sure the Gas Detection module’s switch is put on D
(NOT A) on the left side)76

Notice: Unplug your power adapter when upload sketch code
to Arduino.

Step 1 Install latest Arduino IDE (If you have Arduino IDE version after 1.1.16, please skip
this step)
Download Arduino IDE from https://www.arduino.cc/en/Main/Software?setlang=en , theninstall the software.

Step 2 WifiEsp Library Installation (if you have installed WifiESP library, please skip thisstep)
OSOYOO MEGA-IoT extension TX/RX pin to Arduino A9/A8 pin by default. So in Arduino
sketch code, we need use Software Serial Port to communicate with ESP8266 (set A8 as
RX and A9 as TX in softwareserial object).
To use this wifi shield in Arduino IDE, we need download WiFiEsp-master library fromfollowing link:
http://osoyoo.com/driver/WiFiEsp-master.zip
You need go to Arduino IDE ->Sketch ->Include Library ->Add ,Zip library to load above
zip files into Arduino IDE.

77

Step 3 After installing above library, please download the main code from following link,unzip it, you will see a folder called “smarthome-lesson9”:
http://osoyoo.com/driver/smarthome/smarthome-lesson9.zip

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

78

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

Step 6 Arduino IDE: Click file – Open, then choose code “smarthome-lesson9.ino” in thefolder, load up the sketch onto your Arduino.
79

Note: In the sketch, find line 24，25 as following: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.

80

After loading the sketch to Arduino , open the serial monitor in the upper-right corner ofArduino IDE, you will see following result:81

From the serial monitor, you can see the IP address of your MEGA2560 board in the readcircle (in above picture, 192.168.50.102).
Then use your browser to visit the website http://mega2560-ip-address (in above case,
http://192.168.50.102), you will see following result:

Above result means there is no Smoke signal is detected. The Red LED on the D13 pin of
MEGA-IoT shield is off and Green LED is ON which shows the same result.
Now let’s use a gas lighter to leak some gas to fire sensor, the gas will trig fire signal to
Arduino. You will see the Green LED on IoT shield will be off and Red LED will turn ON.
Now check the web browser , after about 2 to 5 seconds, the browser will show following
result.

82

Lesson10: Flame Detection
In this lesson, we will show you how to make use Internet to monitor remote Fire Sensor
status.
We will use Osoyoo Mega-IoT Shield to connect Fire Sensor, LEDs and MEGA2560 MCU
board.Arduino MEGA2560 board can work as a web server. Remote browser can accessthis web server to shows fire sensor real time status.










OSOYOO MEGA2560 Board x 1
OSOYOO MEGA-IoT Extension Board x 1
Red LED PnP Module x 1
Green LED PnP Module x 1
Flame Detection PnP Module x 1
Buzzer Module x 1
OSOYOO 3-Pin PnP Cable x 4
USB Cable x 1PC x 1

First,please plug OSOYOO MEGA-IoT Extension Board into MEGA2560 board:

83

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):
Green LED Module - D12
Red LED Module - D11
Buzzer Module - D5
Flame Detection Sensor - A1

Notice: Unplug your power adapter when upload sketch code
to Arduino.

Step 1 Install latest Arduino IDE (If you have Arduino IDE version after 1.1.16, please skip
this step).
Download Arduino from https://www.arduino.cc/en/Main/Software?setlang=en , theninstall the software.

84

Step 2 WifiEsp Library Installation (if you have installed WifiESP library, please skip thisstep).
OSOYOO MEGA-IoT extension TX/RX pin to Arduino A9/A8 pin by default. So in Arduino
sketch code, we need use Software Serial Port to communicate with ESP8266 (set A8 as
RX and A9 as TX in softwareserial object).
To use this wifi shield in Arduino IDE, we need download WiFiEsp-master library fromfollowing link:http://osoyoo.com/driver/WiFiEsp-master.zip
Open Arduino IDE, click Sketch – Include Library- Add .Zip library to load above zip files
into Arduino IDE.

85

Step 3 After installing above library, please download the main code from following link,unzip it, you will see a folder called “smarthome-lesson10”:
http://osoyoo.com/driver/smarthome/smarthome-lesson10.zip
Step 4 After above operations are completed, connect OSOYOO MEGA2560 Board to PC
with USB cable.

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

86

Step 6 Arduino IDE: Click file-Open,then choose code “smarthome-lesson10.ino” in thefolder, load up the sketch onto your Arduino.

Note: In the sketch, find line 24，25 as following: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.

87

Notice: Please use the Philips Screwdriver to adjust the Flame Detection Module's
sensitivity by adjusting the potentiometer, when there's no fire, you should adjust
the module to the green light.
After loading the sketch to Arduino, open the serial monitor in the upper-right corner ofArduino IDE, you will see following result:88

From the serial monitor , you can see the IP address of your MEGA2560 board in theread circle (in above picture, 192.168.50.102).Then use your browser to visit the website
http://mega2560-ip-address (in above case, http://192.168.50.102), you will see following
result:Above result means there is no Fire signal is detected. The Red LED on the D12 pin of
MEGA-IoT shield is off and Green LED is ON which shows the same result.
Now let's use a gas lighter to turn a small flame, the gas flame will trig some IR signal tosensor. You will see the Green LED on IoT shield will be off and Red LED will turn ON,
buzzer will alarm.
Now check the web browser , after about 2 to 5 seconds, the browser will show following
result:89

Lesson11: Sound Sensor
In this lesson, we will show you how to make use Internet to monitor remote sound sensor
status.
We will use Osoyoo Mega-IoT Shield to connect sound Sensor, LEDs and MEGA2560
MCU board. Arduino MEGA2560 board can work as a web server. Remote browser canaccess this web server to shows sound sensor real time status.









OSOYOO MEGA2560 Board 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
Sound Sensor PnP module x 1
3-pin PnP cable x 3

First,please plug OSOYOO MEGA-IoT Extension Board into MEGA2560 board:

Then connect the modules with the OSOYOO MEGA-IoT Extension Board with four 3-pin
90

PnP cables as below:(Jumper Cap should connect ESP8266 RX with A8, TX with A9):
Green LED Module - D12
Red LED Module - D11
Sound Sensor-A2

Notice: Unplug your power adapter when upload sketch code
to Arduino.

Step 1 Install latest Arduino IDE (If you have Arduino IDE version after 1.1.16, please skip
this step).
Download Arduino from https://www.arduino.cc/en/Main/Software?setlang=en , theninstall the software.

91

Step 2 WifiEsp Library Installation (if you have installed WifiESP library, please skip thisstep).
OSOYOO MEGA-IoT extension TX/RX pin to Arduino A9/A8 pin by default. So in Arduino
sketch code, we need use Software Serial Port to communicate with ESP8266 (set A8 as
RX and A9 as TX in softwareserial object).
To use this wifi shield in Arduino IDE, we need download WiFiEsp-master library fromfollowing link:http://osoyoo.com/driver/WiFiEsp-master.zip
Open Arduino IDE, click Sketch – Include Library- Add .Zip library to load above zip files
into Arduino IDE.

92

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

http://osoyoo.com/driver/smarthome/smarthome-lesson11.zip
Step 4 After above operations are completed, connect OSOYOO MEGA2560 Board to PC
with USB cable.

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

93

Step 6 Arduino IDE: Click file-Open,then choose code “smarthome-lesson11.ino” in thefolder, load up the sketch onto your Arduino.

Note: In the sketch, find line 24，25 as following: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.

94After loading the sketch to Arduino, open the serial monitor in the upper-right corner ofArduino IDE, you will see following result:95

From the serial monitor , you can see the IP address of your MEGA2560 board in theread circle (in above picture, 192.168.50.102).Then use your browser to visit the website
http://mega2560-ip-address (in above case, http://192.168.50.102), you will see following
result:Above result means there is no sound signal is detected. The Red LED on the D11 pin of
MEGA-IoT shield is off and Green LED is ON which shows the same result.
Now let's make some noise. We connect a buzzer pin to D5 slot. You will hear very big
noise. Put the buzzer close to sound sensor. You will see the Green LED on IoT shield
will be off and Red LED will turn ON.
Now check the web browser , after about 2 to 5 seconds, the browser will show following
result.

96

Lesson12: Light Sensor
In this lesson, we will show you how to make use Internet to monitor remote Light Sensor
status.
We will use Osoyoo Mega-IoT Shield to connect Light Sensor(photoresistor), LEDs and
MEGA2560 MCU board. Arduino MEGA2560 board can work as a web server. Remotebrowser can access this web server to shows light sensor real time status.










OSOYOO MEGA2560 Board 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
Light Sensor PnP module x 1
Buzzer Module x 1
3-pin PnP cable x 4First,please plug OSOYOO MEGA-IoT Extension Board into MEGA2560 board:

97

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)Green LED Module – D12
Red LED Module – D11
Buzzer Module – D5
Light (Photoresistor) Sensor - A0

Notice: Unplug your power adapter when upload sketch code
to Arduino.

Step 1 Install latest Arduino IDE (If you have Arduino IDE version after 1.1.16, please skip
this step).
Download Arduino from https://www.arduino.cc/en/Main/Software?setlang=en , theninstall the software.

98

Step 2 WifiEsp Library Installation (if you have installed WifiESP library, please skip thisstep).
OSOYOO MEGA-IoT extension TX/RX pin to Arduino A9/A8 pin by default. So in Arduino
sketch code, we need use Software Serial Port to communicate with ESP8266 (set A8 as
RX and A9 as TX in softwareserial object).
To use this wifi shield in Arduino IDE, we need download WiFiEsp-master library fromfollowing link:http://osoyoo.com/driver/WiFiEsp-master.zip
Open Arduino IDE, click Sketch – Include Library- Add .Zip library to load above zip files
into Arduino IDE.

99

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

http://osoyoo.com/driver/smarthome/smarthome-lesson12.zip
Step 4 After above operations are completed, connect OSOYOO MEGA2560 Board to
PC with USB cable.

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

100

Step 6 Arduino IDE: Click File - Open, then choose code “smarthome-lesson12.ino” in thefolder, load up the sketch onto your Arduino.

Note: In the sketch, find line 24，25 as following: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.

101

After loading the sketch to Arduino, open the serial monitor in the upper-right corner ofArduino IDE, you will see following result:102

From the serial monitor , you can see the IP address of your MEGA2560 board in the readcircle (in above picture, 192.168.50.102).
Now use your hand to block all the light over the light sensor, Then use your browser tovisit the website http://mega2560-ip-address (in above case, http://192.168.50.102), youwill see following result:

Above result means there is no light signal is detected. The Red LED on the D13 pin of
MEGA-IoT shield is off and Green LED is ON which shows the same result.
Now expose the light sensor to light source, You will see the Green LED on IoT shield will
be off and Red LED will turn ON, buzzer will alarm.
Now check the web browser , after about 2 to 5 seconds, the browser will show following
result.

103

Lesson13: PIR Motion Detection
In this lesson, we will show you how to make use Internet to monitor remote motion
sensor status and detect intruder.
We will use Osoyoo Mega-IoT Shield to connect motion Sensor(photoresistor), LEDs
and MEGA2560 MCU board. Arduino MEGA2560 board can work as a web server.
Remote browser can access this web server to shows motion sensor real time status.










OSOYOO MEGA2560 Board 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
motion Sensor(Photoresistor) PnP module x 1
Buzzer Module x 1
3-pin PnP cable x 4First, please plug OSOYOO MEGA-IoT Extension Board into MEGA2560 board:

104

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)Green LED Module - D12
Red LED Module - D11
Buzzer Module - D5
Motion Sensor-D4

Notice: Unplug your power adapter when upload sketch code
to Arduino.

Step 1 Install latest Arduino IDE (If you have Arduino IDE version after 1.1.16, please skip
this step).
Download Arduino from https://www.arduino.cc/en/Main/Software?setlang=en , theninstall the software.

105

Step 2 WifiEsp Library Installation (if you have installed WifiESP library, please skip thisstep).
OSOYOO MEGA-IoT extension TX/RX pin to Arduino A9/A8 pin by default. So in Arduino
sketch code, we need use Software Serial Port to communicate with ESP8266 (set A9 as
TX and A8 as RX in software serial object).
To use this wifi shield in Arduino IDE, we need download WiFiEsp-master library fromfollowing link:http://osoyoo.com/driver/WiFiEsp-master.zip
Open Arduino IDE, click Sketch – Include Library- Add .Zip library to load above zip files
into Arduino IDE.

106

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

http://osoyoo.com/driver/smarthome/smarthome-lesson13.zip
Step 4 After above operations are completed, connect OSOYOO MEGA2560 Board to
PC with USB cable.

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

107

Step 6 Arduino IDE: Click file-Open,then choose code “smarthome-lesson13.ino” in thefolder, load up the sketch onto your Arduino.

Note: In the sketch, find line 24，25 as following: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.

108

After loading the sketch to Arduino, open the serial monitor in the upper-right corner ofArduino IDE, you will see following result:109

From the serial monitor, you can see the IP address of your MEGA2560 board in the readcircle (in above picture, 192.168.50.102).
Then use your browser to visit the website http://mega2560-ip-address (in above case,
http://192.168.50.102), you will see following result:

Above result means there is no intruder (motion signal) is detected. The Red LED on theD13 pin of MEGA-IoT shield is off and Green LED is ON which shows the same result.
Now put your hand close to motion sensor, You will see the Green LED on IoT shield will
be off and Red LED will turn ON, buzzer will alarm.
Now check the web browser , after about 2 to 5 seconds, the browser will show following
result.

110

Lesson14: LCD Screen
In this lesson, we will show you how to make use Internet send message from remotebrowser to remote 16x2 LCD.
We will use Osoyoo Mega-IoT Shield to connect 1602 LCD and MEGA2560 MCU
board. Arduino MEGA2560 board can work as a web server. We will use browser cansend "your name" string to this web server and display Welcome your name message
in the 1602 LCD screen.







OSOYOO MEGA2560 Board x 1
OSOYOO MEGA-IoT Extension Board x 1
USB Cable x 1
1602 LCD Screen PnP module x 1
4-Pin PnP Cable x 1First,please plug OSOYOO MEGA-IoT Extension Board into MEGA2560 board:

111

Then connect the I2C 1602 LCD Screen to the I2C_1 port of the OSOYOO MEGA-IoT
Extension Board with a 4-pin PnP cable as below (Jumper Cap should connect ESP8266
RX with A8, TX with A9):

Notice: Unplug your power adapter when upload sketch code
to Arduino.

Step 1 Install latest Arduino IDE (If you have Arduino IDE version after 1.1.16, please skip
this step).
Download Arduino from https://www.arduino.cc/en/Main/Software?setlang=en , theninstall the software.

112

Step 2 WifiEsp Library Installation (if you have installed WifiESP library, please skip thisstep).
OSOYOO MEGA-IoT extension TX/RX pin to Arduino A9/A8 pin by default. So in Arduino
sketch code, we need use Software Serial Port to communicate with ESP8266 (set A8 as
RX and A9 as TX in softwareserial object).
To use this wifi shield in Arduino IDE, we need download WiFiEsp-master library fromfollowing link:http://osoyoo.com/driver/WiFiEsp-master.zip
Open Arduino IDE, click Sketch – Include Library- Add .Zip library to load above zip files
into Arduino IDE.

113

Step 3 You need install I2C library and save it as above operations. You can test 1602
LCD I2C address, please read following tutorial:
http://osoyoo.com/2017/07/09/arduino-lesson-i2c-lcd1602-display/
Step 4 After installing above library, please download the main code from following link,unzip it, you will see a folder called “smarthome-lesson14”:

http://osoyoo.com/driver/smarthome/smarthome-lesson14.zip
Step 5 After above operations are completed, connect OSOYOO MEGA2560 Board to
PC with USB cable.

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

114

Step 7 Arduino IDE: Click file-Open,then choose code “smarthome-lesson14.ino” in thefolder, load up the sketch onto your Arduino.

Note: In the sketch, find line 24，25 as following: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.

115

After loading the sketch to Arduino, open the serial monitor in the upper-right corner ofArduino IDE, you will see following result:116

From the serial monitor, you can see the IP address of your MEGA2560 board in the readcircle (in above picture, 192.168.50.102).
Then use your browser to visit the website http://mega2560-ip-address (in above case,
http://192.168.50.102), you will see following result:

In put your name "Alex" in the text field and click Submit button.
You will see message showed in remote LCD screen as following:

WelcomeAlex

117

Lesson15: 1-Channel Relay
Relay is a useful electronics switch which can be controlled by low voltage signal. Relay isoften used by computer to control high voltage circuit.
In this lesson, we will show you how to turn on/off Relay and Buzzer from a remotebrowser through internet .
We will use Osoyoo Mega-IoT Shield to connect Relay, LED and MEGA2560 MCU
board. Arduino MEGA2560 board can work as a web server. Remote browser can accessthis web server and control the Relay connected to D13 pin of MEGA2560.










OSOYOO MEGA2560 Board x 1
OSOYOO MEGA-IoT Extension Board x 1
USB Cable x 1
Relay module x 1
Buzzer module x 1
PnP cable x 1
male to female Jumper x 3
male to male Jumper x 1

First,please plug OSOYOO MEGA-IoT Extension Board into MEGA2560 board:118

Jumper Cap should connect ESP8266 RX with A8, TX with A9.
Relay - OSOYOO MEGA-IoT Extension Board
Relay Module - D6
COM - 5V (Jumper)
Buzzer Module - OSOYOO MEGA-IoT Extension Board
VCC - 5V (Jumper)
GND - GND (Jumper)
Relay - Buzzer Module
No - SIG (Jumper)

Notice: Unplug your power adapter when upload sketch code
to Arduino.
119

Step 1 Install latest Arduino IDE (If you have Arduino IDE version after 1.1.16, please skip
this step).
Download Arduino from https://www.arduino.cc/en/Main/Software?setlang=en , theninstall the software.

Step 2 WifiEsp Library Installation (if you have installed WifiESP library, please skip thisstep).
OSOYOO MEGA-IoT extension TX/RX pin to Arduino A9/A8 pin by default. So in Arduino
sketch code, we need use Software Serial Port to communicate with ESP8266 (set A8 as
RX and A9 as TX in softwareserial object).
To use this wifi shield in Arduino IDE, we need download WiFiEsp-master library fromfollowing link:http://osoyoo.com/driver/WiFiEsp-master.zip
Open Arduino IDE, click Sketch – Include Library- Add .Zip library to load above zip files
into Arduino IDE.

120

Step 3 After installing above library, please download the main code from following link,unzip it, you will see a folder called “smarthome-lesson15”:https://osoyoo.com/driver/smarthome/smarthome-lesson15.zip
Step 4 After above operations are completed, connect OSOYOO MEGA2560 Board to
PC with USB cable.

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

121

Step 6 Arduino IDE: Click file-Open,then choose code “smarthome-lesson15.ino” in thefolder, load up the sketch onto your Arduino.

Note: In the sketch, find line 24，25 as following: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.

122After loading the sketch to Arduino, open the serial monitor in the upper-right corner ofArduino IDE, you will see following result:123

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

Then use your browser to visit the website http://mega2560-ip-address (in above case,
http://192.168.50.102), you will see following result:

Click the two links as showed in above picture, you will turn on/off the Relay module whichis connected to your MEGA2560 through the IoT Shield.
If Relay is turned on, you will hear buzzer alarm, if relay is off, buzzer will also be turned
off.

124

Lesson16: RFID Switching DoorIn this project, we will make a simple RFID (IC card) + IoT controlled security door system.
We use Cell phone APP to send control signal through UDP protocol similar to Lesson 8.
Security Door normally is often opened by servo motor. To make things simple, we justuse servo turning 180 degree to imitate door open and rotate back to 0 degree to imitate
door close.
The whole procedure will be work as follows:
When an IC card detected by RC522 RFID module, Arduino will verify if its ID matches
record.
If ID matches record, then servo turn 90 degree . Green LED turn on and Red LED turnoff.
If ID does not match record, then, servo does not move, instead, the buzzer will alarm(youneed use browser to turn off alarm from remote computer).
At any time, remote browser can open the door(servo rotate to 90 degree) or close thedoor (servo back to 0 degree) or turn off buzzer and monitor door status.












OSOYOO MEGA2560 Board x 1
OSOYOO MEGA-IoT Extension Board x 1
LED module Green x 1, Red x 1
Buzzer module x 1
Micro Servo Motor x 1
RFID Module x 1
PnP Cable x 3
8pin 12cm Female to Female Cable x 1
USB Cable x 1
PC x 1First,please plug OSOYOO MEGA-IoT Extension Board into MEGA2560 board:
125

Then connect the modules with the OSOYOO MEGA-IoT Extension Board with three
3-pin PnP cables and one 8pin 12cm Female to Female Cable as below (Jumper Cap
should connect ESP8266 RX with A8, TX with A9):
Green LED Module - D12
Red LED Module - D11
Buzzer Module - D5
Micro Servo Motor - D3
RFID Module - RFID

126

Notice: Unplug your power adapter when upload sketch code
to Arduino.
Step 1 Download OSOYOO Wifi UDP Robot Car control APP
In Google Play or Apple Store, please search key words “OSOYOO Wifi UDP Robot Car”,
you will find an orange icon APP as following:

Step 2 WifiEsp Library Installation (if you have installed WifiESP library, please skip thisstep).
OSOYOO MEGA-IoT extension TX/RX pin to Arduino A9/A8 pin by default. So in Arduino
sketch code, we need use Software Serial Port to communicate with ESP8266 (set A8 as
RX and A9 as TX in softwareserial object).
To use this wifi shield in Arduino IDE, we need download WiFiEsp-master library fromfollowing link:http://osoyoo.com/driver/WiFiEsp-master.zip
Open Arduino IDE, click Sketch – Include Library- Add .Zip library to load above zip files
into Arduino IDE.

127

Step 3 RFID Library Installation

You need install RFID library and save it as above operations. Please readfollowing article to test RFID library:https://osoyoo.com/2019/10/14/osoyoo-mega-iot-shield-rfid-tutorial/
Remember to change write down the RFID number of one ID card.

Step 4 After installing above library, please download the main code from following link,unzip it, you will see a folder called “smarthome-lesson16B”:
https://osoyoo.com/driver/smarthome/smarthome-lesson16B.zip
Step 5 After above operations are completed, connect OSOYOO MEGA2560 Board to
PC with USB cable.

128

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

Step 7 Arduino IDE: Click file-Open,then choose code “smarthome-lesson16.ino” in thefolder, load up the sketch onto your Arduino.
129Remember to change the lines 19 of the code with the card number you got from
Step 3): unsigned char my_rfid[] = {186,11,86,89,190}; // replace {186,11,86,89,190} withyour own RFID card number

Note: In the sketch, find line 31, 32 as following:130

char ssid[] = "******"; // your network SSID (name)char pass[] = "******"; // your network
passwordplease replace the ****** with your correct wifi SSID and password, otherwise your project
can not connect to Internet.

131

After loading the sketch to Arduino, open the serial monitor in the upper-right corner ofArduino IDE, you will see following result:132

From the serial monitor, you can see the IP address of your MEGA2560 board in the readcircle (in above picture, IP is 192.168.50.47), default port 8888, you need to set this IP
address and port number in cell phone APP.
Now Open your Orange color APP and click Setting, write IP address into the APP as
following:

Running Result:
When you use an IC card which matches the value in code line 19, the door willopen(servo rotate to 90 degree) and Green LED is ON.
When you use an IC card which does not match value of line 19, the door will NOT open
and RED LED is ON. Buzzer will also alarm.
If you use Cell phone APP to control the Servo, the control method

will be as following:when you click ◄ button, the servo will point zero degree, Green LED is OFF.
Serial Monitor will show Close THE DOOR!
when you click ▲ button, the servo will point 90 degree, Green LED is OFF.
Serial Monitor will show Half Close THE DOOR!
when you click ► button, the servo will point 180 degree, Green LED is ON.
Serial Monitor will show OPEN THE DOOR!
when you click || button, the buzzer will turn off.
133

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









OSOYOO MEGA2560 Board x 1
OSOYOO MEGA-IoT Extension Board x 1
USB Cable x 1
LED module Red x 1 Greenx 1 Yellowx 1
Ultrasonic Distance Sensor PnP Module x 1
3-pin PnP cable x 44-pin PnP cable x 1

Whitex 1

First,please plug OSOYOO MEGA-IoT Extension Board into MEGA2560 board:

134

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 Sensor - Ultrasonic slot (4-pin PnP cable)

Notice: Unplug your power adapter when upload sketch code
to Arduino.

Step 1 Install latest Arduino IDE (If you have Arduino IDE version after 1.1.16, please skip
this step).
Download Arduino from https://www.arduino.cc/en/Main/Software?setlang=en , theninstall the software.

135

Step 2 WifiEsp Library Installation (if you have installed WifiESP library, please skip thisstep).
OSOYOO MEGA-IoT extension TX/RX pin to Arduino A9/A8 pin by default. So in Arduino
sketch code, we need use Software Serial Port to communicate with ESP8266 (set A8 as
RX and A9 as TX in softwareserial object).
To use this wifi shield in Arduino IDE, we need download WiFiEsp-master library fromfollowing link:http://osoyoo.com/driver/WiFiEsp-master.zip
Open Arduino IDE, click Sketch – Include Library- Add .Zip library to load above zip files
into Arduino IDE.

136

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 Arduino IDE:Choose corresponding board type and port type for you project.

137

Step 6 Arduino IDE: Click file-Open,then choose code “smarthome-lesson17.ino” in thefolder, load up the sketch onto your Arduino.

Note: In the sketch, find line 24，25 as following: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.

138

After loading the sketch to Arduino, open the serial monitor in the upper-right corner ofArduino IDE, you will see following result:139

From the serial monitor, you can see the IP address of your MEGA2560 board in the readcircle (in above picture, 192.168.50.102).
Put some obstacle object in front of the ultrasonics sensor, use your browser to visit thewebsite 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).

140

Lesson18: Two Mega-IoT Devices
In previous lessons, we have learnt many example on how to use web browser in PC tomonitor to control a remote device through HTTP protocol. Such HTTP protocol hassome problem.
First, it needs run a web server in Arduino which has limited memory. Therefore theperformance is slow and not stable.
Second, it can only has one direction control (from PC to control remote device). It is not a
100% Thing to Thing connection required by many IoT applications.
This lesson we will discuss how to use two MEGA-Iot Shields to make Things-to-Things
communication by UDP protocol.
Please be noted that if you need do experiment in this lesson, you need buy two
pcs of Osoyoo Mega-IoT extension shields.
In order to make duplex communication between two IoT, we need use a new internet
protocol called UDP. UDP is very commonly used by email and IP phone service. It is avery simple protocol which allows internet device to send one way data to destination
device. You only need tell UDP software the IP address and Port number, then destination
can get the message.



OSOYOO MEGA2560 Board x 2
OSOYOO MEGA-IoT Extension Board x 2
USB Cable x 2First,please plug OSOYOO MEGA-IoT Extension Board into MEGA2560 board:141

Notice: Unplug your power adapter when upload sketch code
to Arduino.

Step 1 Install latest Arduino IDE (If you have Arduino IDE version after 1.1.16, please skip
this step).
Download Arduino from https://www.arduino.cc/en/Main/Software?setlang=en , theninstall the software.

142

Step 2 WifiEsp Library Installation (if you have installed WifiESP library, please skip thisstep).
OSOYOO MEGA-IoT extension TX/RX pin to Arduino A9/A8 pin by default. So in Arduino
sketch code, we need use Software Serial Port to communicate with ESP8266 (set A8 as
RX and A9 as TX in softwareserial object).
To use this wifi shield in Arduino IDE, we need download WiFiEsp-master library fromfollowing link:http://osoyoo.com/driver/WiFiEsp-master.zip
Open Arduino IDE, click Sketch – Include Library- Add .Zip library to load above zip files
into Arduino IDE.

Step 3 After installing above library, please download the main code from following link,unzip it, you will see a folder called “smarthome-lesson18”:https://osoyoo.com/driver/smarthome/smarthome-lesson18.zip
Unzip the downloaded zip file, you will see two sub-folders in smarthome-lesson18:
143

UdpSend andUDPreceive .

UdpSend should be installed in the sender Arduino device. It is to send UDP data(in thesample code,message is "what's your name?"
UDPreceive should be installed on the other Arduino device which receive data fromsender device. It is to show incoming UDP message and send response "my name isalice" back to sender device).
Step 4 After above operations are completed, connect OSOYOO MEGA2560 Board to
PC with USB cable.

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

144

Load UdpReceive.ino to Receiver Arduino device
Step 6 Please run sample code for receiver device in lesson 3, please record the receiverdevice IP address, you'll need it in the step below.

Step 7 Arduino IDE: Click file – Open to load UdpReceive.ino to Receiver Arduino device

145Note: In the sketch, find line 24，25 as following: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.

146

Load UdpSend.ino to Sender Arduino device
Step 8 Arduino IDE: Click file – Open to load UdpSend.ino to Sender Arduino devicev

Note: In the sketch, find line 16,17 as following: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.

147

You also need change line 20 as following (recorded in step 6):
char remote_server[] = "192.168.50.102"; // replace receiver device ip address here.
If you don't know receiver device IP address, you need run sample code for receiverdevice in lesson 3

148

After loading the sketch to Arduino, open the serial monitor in the upper-right corner ofArduino IDE, you will see following result:149

Open receiver's serial monitor, you will see following screen:

You can see Sender's message "What's your name?"
Now back to sender's serial monitor, you will see following screen:

Now you can see new response message "I am Alice" which is from receiver device.

150

Lesson19: Arduino IoT Capstone
Project
In this lesson, we will make a complex Capstone project which will use many of ourprevious knowledge. We will make two groups of sensors and actuators installed on two
MEGA-IoT shields (to make things simple, we call Device A and Device ). We also needuse ArduinoJson Library which can use short string to transfer data through json format.

The project has following functions:
Device A has DHT 11 temperature sensor which will send data to Device B and display
temperature/humidity value in 1602 LCD in Device B.
Device A has Gas Sensor
in Device B will alarm.

which will send data to Device B . If Gas is detected , buzzer

Device A has RFID module which can send IC card ID to Device B 1602 LCD .
Device B has Red LED which can be turned on/off by push buttons in Device A











OSOYOO MEGA2560 Board x 2
OSOYOO MEGA-IoT Extension Board x 2
USB Cable x 2
Red LED PnP module x 2
Push Button PnP Module x 2
I2C 1602 LCD PnP module x 1
Gas detection PnP module x 1
RFID modules x 1
Buzzer PnP module x 1First,please plug OSOYOO MEGA-IoT Extension Board into MEGA2560 board:
151

Then connect the modules with two OSOYOO MEGA-IoT Extension Boards with PnP
cables as below. (Jumper Cap should connect ESP8266 RX with A8, TX with A9)Modules - Device A
DHT11 - D2
RFID Module - RFID
Gas Sensor - A3
Push Button Module - D7
Modules - Device B
1602 LCD Module - I2C
Buzzer Module - D5
Red LED Module - D11

152

Notice: Unplug your power adapter when upload sketch code
to Arduino.

Please be noted that in this lesson, you need two pcs of Osoyoo Mega-IoT
extension shields,mega 2560 and devices (Device A and Device B).
Step 1 Install latest Arduino IDE (If you have Arduino IDE version after 1.1.16, please skip
this step).
Download Arduino from https://www.arduino.cc/en/Main/Software?setlang=en , theninstall the software.

Step 2 WifiEsp Library Installation (if you have installed WifiESP library, please skip thisstep).
OSOYOO MEGA-IoT extension TX/RX pin to Arduino A9/A8 pin by default. So in Arduino
sketch code, we need use Software Serial Port to communicate with ESP8266 (set A8 as
RX and A9 as TX in softwareserial object).
To use this wifi shield in Arduino IDE, we need download WiFiEsp-master library fromfollowing link:http://osoyoo.com/driver/WiFiEsp-master.zip
Step 3 Open Arduino IDE, click Sketch – Include Library- Add .Zip library to load above
zip files into Arduino IDE.
153

Step 4 Download ArduinoJson library fromhttps://osoyoo.com/driver/smarthome/ArduinoJson.zip
Save it as above operations.
Step5 Download ArduinoJson library fromhttps://osoyoo.com/driver/smarthome/ArduinoJson.zip
Save it as above operations.
Step 6 After installing above library, please download the main code from following
link.unzip the download zip file lesson19.zip, you will see a folder called
smarthome-lesson19
https://osoyoo.com/driver/smarthome/smarthome-lesson19.zip
Unzip the downloaded zip file, you will see two sub-folders in smarthome-lesson19:
deviceA and deviceB
Step 7 After above operations are completed, connect OSOYOO MEGA2560 Boards to154

PCs with USB cables.
Step 8 Open the Arduino IDE and choose corresponding board type and port type for you
project.

Step 9 Arduino IDE: Click file -> click Open -> choose code “smarthome-lesson19”, load
up sketch in folder deviceA to Device A and sketch in deviceB folder to device B.

Note:
In sketch deviceA, you need change Wifi SSID and password in Line 28,29, you also needset device B IP address in line 32.
In sketch deviceB, you need change Wifi SSID and password in Line 22,23, you also needset device A IP address in line 26.

Step 1) Please load deviceA.ino to Sender Arduino device.
Make sure have changed line 22,28,32 with correct wifi password,ssid and device B IP
address.

155

If you don't know receiver device IP address, you need run sample code in lesson 3
Open serial monitor, put a IC card to RFID module, you will see following screen:

As receiver Arduino sketch is not running, you can not get any action at this moment.
Step 2) please load deviceB.ino to device B Arduino board, also change the wifi ssid,
password and device A Ip address properly.
156

Open serial monitor, you will see following screen:

At the beginning , there is some error because no IC card detected in device A. After you
Put an IC card to device A RFID moduel, it will show RFID number in serial monitor.
Now check the LCD which is connected to I2C 1 slot of Device B, it will show Temperature,
Humidity and RFID# which is sent from Device DHT11 sensor and RFID module.
Red LED in Device B which can be turned on/off by push buttons in Device A.
Let’s use a gas lighter to leak some gas to gas sensor, buzzer in Device B will alarm.
You can add some more sensors and actuators in this project and make far more complex
IoT projects. If you have any question, please contact support@osoyoo.info to get help.

157