Introduction About Osoyoo Wifi Shield for Arduino:
Osoyoo Wifi Shield for Arduino is Wifi device which allows Arduino compatible boards(UNO,MEGA2560,Leonardo etc) to connect to Wifi network and become a node of Internet of Things(IoT).

To exchange data with other IoT devices, Osoyoo Wifi shield can make Arduino to work under three different roles:

  1. Work as an IoT client and send data to remote web server by HTTP protocol.
  2. Work as as a Web Server which allows other clients(browser or mobile APP etc) to get data from Arduino or send control command to Arduino through HTTP.
  3. Work as MQTT client which allows Arduino to Publish data to remote MQTT broker.

Purpose of this lesson:
In this lesson, we will teach you  how to make Arduino working as an IoT client (Role 1). You will connect our wifi shield to Arduino board and add a DHT11 Temperature/Humidity sensor into Arduino. Then Arduino will send the temperature and sensor data to a remote web server.

The remote web server will record the sensor data into database. You can see the history data from web browser.

Circuit Graph:

Above circuit graph is pretty straight forward.
First, you need insert Osoyoo Wifi Shield into Arduino board.

You should be care if the two jumper caps showed in above circuit graph. The picture shows the default position of these two jumper caps which allow ESP8266 TX connecting to D3 and ESP8266 RX connection to D2. Therefore, in Arduino Sketch, you need define software serial port RX as D3 and TX as D2.
(If you use Leonardo or MEGA2560, you can also connect ESP8266 RX/TX to Leonardo/MEGA2560 TX1/RX1 pin)

The DHT11 data pin should connect to D5 , VCC to 5V pin and GND to Arduino GND pin.

Software Prerequisite:
Before installing sketch into Arduino IDE, we need two libraries first: DHT library which get data from DHT11 sensor and WifiESP library which allows Osoyoo Wifi Shield to connect Wifi and Internet.

WifiESP library can be downloaded from following link:
http://osoyoo.com/driver/WiFiEsp-master.zip

DHT can be downloaded from following link:
http://osoyoo.com/wp-content/uploads/samplecode/DHT.zip

You need go to Arduino IDE ->Sketch ->Include Library ->Add ,Zip library to load above zip files into Arduino IDE.

Software Sketch on Arduino:
Please download the software sketch from following link:
http://osoyoo.com/download/code/esp_client.zip

Unzip above file and double click esp_client.ino file, you will open the sketch code into your Arduino IDE.
Before compiling the sketch, you need to make some change first:
Line 26 wifi_hotspot_ssid, please change it to your own wifi hotspot ssid
Line 27 wifi_password , please change to your own wifi password

Line 30 device_name, please rename it for a unique name which is easy for you to distinguish your device.
Line 38 "45.33.77.221" is our test server, you can change it to your own server IP or domain name here.
Line 46    Serial1.begin(115200);  this line set Baud rate of ESP8266, you can change it to 9600 if your ESP8266 does not work properly.

Now your can click right arrow button in Arduino IDE and load the sketch into Arduino board.

Running the Sketch:
Open the serial monitor in Arduino IDE, you will see following message:

You can see that the Wifi Shield visited following url (sketch code  line 87):
http://45.33.77.221/esp8266.php?device_name=dht11&temperature=26&humidity=35
45.33.77.221 is the server IP you set in Sketch server variable  ,temperature=26 and humidity=35 data get from DHT11 in line 73 - 76.

Above URL will open a PHP code file esp8266.php in  our server and server will read Temperature/humidity and device name from above url and write them into database.

You can visit the recent 50 DHT11 records from link:
http://45.33.77.221/showlog.php

The server and database code are in the zipfile server folder. If you have some basic PHP/Mysql knowledge, you can find the code are  very simple .

Above PHP server code is just an example to get data from URL(HTTP GET method) . You can customize the server program code in your own way .