Buy from US Buy from UK Buy from DE Buy from FR Buy from IT Buy from ES ここでご購入を!

Here, we will show how to use OSOYOO Smart Home IoT Kit with OSOYOO IoT APP to control some electronic devices, such as LEDs, active buzzers, fan modules, relay modules, etc.

In this lesson, we will learn how to use OSOYOO IoT APP to remotely turn on or turn off the LED and control the brightness of the LED. . . Using the same principle, you can also control other electronic devices

HARDWARE

SOFTWARE

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

Make sure that jumper caps in the following red circle are installed. These two jumper caps connect A9 to ESP_TX and A8 to ESP_RX.

Connect the LED Module to the D2 port as below:

Prerequisite:

To install above two zip files, please need to go to Arduino IDE →Sketch →Include Library →Add, Zip library to load above zip files into Arduino IDE.

Download, Edit, and Run lesson2-1 Arduino Code
Step 1) P
lease download the code from following link, unzip it:
https://osoyoo.com/driver/smart-home-v2-udp/lesson1/smart-home-lesson1.zip

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

Notice: Shut off your battery or unplug your power adapter when upload sketch code to Arduino.

Step 3 Open Arduino IDE:  Choose corresponding board type and port type for your project.

Step 4 Arduino IDE:  Click file – Open, then choose code in the folder, load up the sketch onto your Arduino.

Note: In the sketch, find   lines 17 to 18 and replace your Wi-Fi ssid/password

char ssid[] = "***”;//replace this line with your Wi-Fi ssid
char pass[] = "***”; //replace this line with your Wi-Fi password

Upload the sketch to the board. Wait until you see something like this:
Done uploading

Step 5: Now open Serial monitor in the upper right corner, you should see your Arduino IP address and Port number as following:

Congratulations! You have installed Arduino Sketch successfully! Next step is to install an OSOYOO IoT APP in your mobile device:

Step 6 Download OSOYOO IoT APP by searching OSOYOO IoT UDP robot car app from Apple Store(iPhone/iPad) or Google Play Store (Android device)


You can also download an Android APP from https://osoyoo.com/driver/udp-app.apk if you can’t access Google Play.

Step 7: Set IP Address in APP

1)Open APP, click Setting button in upper right corner

2)Use the Arduino IP address you get in Step 8 to replace default IP 192.168.1.255

3)keep default port number 8888 without changing

4)Click Save button to save the changes you just made
5)Click Back Arrow to go back to APP front UI

Press the F1 Button on the APP, then the remote LED (which is connected to D2 port of Wi-Fi board) will be turned on.
Once the Arduino board turns on LED, it will send a message “LED is ON” to APP, you will see this message in APP response display area as following:

Press the F2 Button on the APP, then the remote LED will be turned off.
Once the Arduino board turns on LED, it will send a message “LED is OFF” to APP, you will see this message in APP response display area too.

Following tutorial is only for advance users who want to get more deep understanding about the APP and the Sample Code.

Brief Introduction about OSOYOO IoT UDP APP and How to use Arduino Software to receive send/receive UDP message:
When you press a button key in Arduino IDE, the APP actually send a brief message through UDP protocol to remote device whose IP and port are defined in setting page in Step 10.
In the lower part of the setting page, you will see the fields which defines the default messages which are sent by each button:

In the above picture, you can see F2 is associated to ‘G’, this means when you press F2, you will send a single letter message ‘G’ to remote device by UDP protocol.
If you click the letter G, you can actually change F2’s message. For example, if you change ‘G’ to ‘Hello’, then the message ‘Hello’ will be sent after F2 is pressed.
You can download a UDP protocol receiving Arduino code from the following link:
https://osoyoo.com/driver/smart-home-v2-udp/lesson1/UdpReceive.zip

Open above sketch code, change its SSID and Password in line 19 and 20, then run it. You can open a serial monitor to check message you received from each button from your APP.

UDP is a useful internet communication protocol used in IoT applications and email transfer. We hope you can get some hand-on UDP programming experience through this   project.