Buy from US | Buy from UK | Buy from DE | Buy from IT | Buy from FR | Buy from ES | ここでご購入を! |
This lesson is our final project, which is a little bit complicated and more exciting. In the previous lesson, we only used a browser or cell phone to make humans talk. In this lesson, we will use one mainboard to communicate with another mainboard through the Internet UDP protocol. You need to buy two sets of our IoT learning kits. We will use the first OSOYOO basic board (called basic A) to connect a PIR motion sensor, and another mainboard (basic B) to connect a buzzer. When an intruder is detected by the PIR motion sensor in basic A, an alarm signal will be sent from basic A to basic B, and the buzzer will beep.
Insert the ESP8266 Wi-Fi Shield into your mainboard
OSOYOO Basic Board | PIR |
D3 | OUT |
GND | GND |
5V | VCC |
OSOYOO Basic Board | Buzzer |
D9 | I/O |
GND | GND |
5V | VCC |
Step A)Install the latest IDE (if you have IDE version 1.1.16 or later, please skip this step). Download the IDE from https://www.arduino.cc/en/Main/Software?setlang=en and then install the software.
Step B) Connect the OSOYOO Basic Board to the computer via a USB cable.
Step C) Open the IDE and choose the corresponding board type and port type for your project.
Step D) Download the sketch file from: https://osoyoo.com/driver/Esp8266_Arduino_IOT/lesson12/esp8266-lesson12.zip
char ssid[] = "******"; // your network SSID (name) char pass[] = "******"; // your network password
Please replace the ****** with your correct Wi-Fi SSID and password, otherwise, your project cannot connect to the Internet.
Step E) After changing the above lines, load the sketch into the IDE.
Open your Serial Monitor, and you can see your router will assign an IP address to your IDE as follows:
char ssid[] = "******"; // your network SSID (name) char pass[] = "******"; // your network password
Please replace the ****** with your correct Wi-Fi SSID and password, otherwise, your project cannot connect to the Internet.
Step 5) Then, search for the following line:
byte remoteIp[] = { 10,0,0,244 }; //...
You need to change the line’s remoteIp[] variable, replace the IP address 10.0.0.244 with the one you recorded from Step A. In our example, Step A shows the buzzer IDE IP is 192.168.50.13, so we make the line:
byte remoteIp[] = { 192,168,50,31 }; //…
Then you can compile and upload the motionsensor.ino file to IDE.
Test result:
Turn on power of both ESP8266 shield and OSOYOO Basic boards. When you move your hand in front of the motion sensor, the remote buzzer will beep.
DownLoad Url osoyoo.com