Buy from US | Buy from UK | Buy from DE | Buy from IT | Buy from FR | Buy from ES | Buy from JP |
This lesson is our final project which is a little bit complicated and more exciting. In previous lesson, we only use browser or cell phone to make human-Arduino talk. In this lesson, we will one Arduino to talk with another Arduino through Internet UDP protocol. You need to buy two set of our Arduino IoT learning kits.
We will use first OSOYOO Uno board(call UNO A) to connect PIR motion sensor and another UNO board(UNO B) to connect buzzer. When an intruder is detected by PIR motion sensor in UNO A, an Alarm signal will be sent from UNO A to UNO B and make the buzzer beep.
First, please insert the ESP8266 wifi Shield into your UNO board,
UNO Board | PIR |
D3 | OUT |
GND | GND |
5V | VCC |
Hardware B)Arduino UNO B+ESP8266 WIFI shield connects to buzzer
Buzzer I/O pin connect to D9 as per following picture:
UNO Board | Buzzer |
D9 | I/O |
GND | GND |
5V | VCC |
Step B) Connect the Arduino UNO board to computer via USB cable,
Step C) Open the Arduino IDE and choose corresponding board type and port type for you project.
Step D) Download the sketch file from:https://osoyoo.com/driver/Esp8266_Arduino_IOT/lesson12/esp8266-lesson12.zip
After unzip above file, you will see a folder “esp8266-lesson12” , enter this folder, you will see two sub-folders(buzzer and motionsensor).
Enter buzzer folder and double click the buzzer.ino file, 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.
Step E) After change above lines, load the sketch into Arduino IDE.
Open your Serial Monitor, you can see your router will assign an IP address to your Arduino as following: In above bove example, 192.168.50.31 is the IP address assigned by router to your buzzer Arduino.You have to write down this IP address in a paper. We need to use this IP address to change the sketch code in motionsensor.ino file. You can unplug this Arduino from PC and use some other USB adapter to power this buzzer Arduino.
Step F) Now connect your PIR motion sensor Arduino to your PC, open the folder motionsensor and open the motionsensor.ino file, find following lins:
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.
Step 5) Then search following line:
byte remoteIp[] = { 10,0,0,244 }; //...
You need to change the line remoteIp[] variable , replace the IP address 10.0.0.244 with the one your recorded from Step A. In our example, Step A shows buzzer Arduino IP is 192.168.50.13, so we make the line to:
byte remoteIp[] = { 192,168,50,31 }; //…
Then you can compile and upload the motionsensor.ino file to Arduino.
Test result:
Turn on power of both ESP8266 shield and Arduino boards . When you move your hand in front of the motion sensor, the remote buzzer will beep.
DownLoad Url osoyoo.com