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:
This ESP8266 Arduino Wifi Extension Shield can be purchased in : https://osoyoo.store/collections/arduino-robot-car-v2-0/products/esp8266-wifi-shield-for-osoyoo-robot-car
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.
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.
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:
DHT can be downloaded from following link:
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:
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 “184.108.40.206” 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):
220.127.116.11 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:
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 .
DownLoad Url osoyoo.com