Overhere, we will demonstrate how to use this kit to remotely collect sensor data through the Blynk APP, In this way, we can use the mobile phone to check the environmental data information at home.
In this project, we will view the button status remotely through the Blynk APP. If the button is pressed, the LED widget on the APP will be lit, otherwise it will be off. Through the same principle, we can remotely measure the state of other sensors in digital mode, such as photosensitive sensor module, flame sensor module, human infrared sensor module, etc.
First, please plug OSOYOO MEGA-IoT Extension Board into MEGA2560 board:
Build the circuit as below:
LED Module – D2
Button Module – D3
Prerequisite:
You need to install Local Blynk Server, Blynk APP, Arduino IDE, Blynk Libraries before running the code of this lesson. If you haven’t done these installations, please read following contents in lesson2-1 link:
https://osoyoo.com/2021/04/29/osoyoo-smart-home-iot-blynk-lesson-2-1-simple-control/#prerequisite
Download and run the lesson2-2 Arduino code
Step 1) Download the code from following link, unzip it:
https://osoyoo.com/driver/Smart_House_IoT_Learning_Kit_V2.0_code/Lesson2-2.zip
Step 2) After above operations are completed, connect OSOYOO MEGA2560 Board to PC with USB cable.
Step 3 Open Arduino IDE: Choose corresponding board type and port type for you 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 these lines 13 as following:
char auth[] =”sM1i_rSJjDlQxesfuhOzrL0h9NiivJkn”;
Replace sM1i_rSJjDlQxesfuhOzrL0h9NiivJkn with your local Blynk Token. If you don’t know how to get token, read this article.
Then find lines 22 23 24 and replace your wifi ssid/password and your blynk server IP address
char ssid[] = "***";//replace this line with your wifi ssid char pass[] = "***"; //replace this line with your wifi password char server_ip[]="192.168.1.81"; // replace this line with your Blynk Server IP address
Upload the sketch to the board. Wait until you see something like this:
Done uploading
Now open your Serial Monitor, you will see Arduino is trying to talk to Blynk server. After 20 to 30 seconds, your Serial monitor will finally shows Arduino’s IP address and a “Ready (ping: 25ms)” ending message.
Congratulations! You are all ready! Your hardware is now connected to the Blynk server.
Nw we need to add an LED widget. Follow the next operations:
Open your project page and press the “+” button to add the “LED” Widget.
LED Widget settings:
Name Column: You can name your widget, whatever you like.
INPUT: V3
After you finished all above operations, open the Serial Monitor and you will see the connection status. Now open the Blynk APP, press the PLAY button “▷“. This will switch the APP from EDIT mode to PLAY mode where you can interact with the hardware.
While in PLAY mode, you won’t be able to drag or set up new widgets, press “□” and get back to EDIT mode.
When you Press/Release the button, and then you will find that the virtual LED widget on the Blynk APP will be turned on/off.
At this time, you can try to use this code to detect the status of your other environmental sensors in digital mode.
Please note: If there is a status switch on your sensor, please flip the switch to the side with the letter “D”.
If you find the device is offline, please check your code, wiring and app settings, and try again.
No. | Picture | Device | Qty. | Link |
1 | OSOYOO MEGA2560 Board | 1 | Click here to buy | |
2 | OSOYOO MEGA-IoT Extension Board | 1 | Click here to buy | |
3 | Photosensitive Sensor | 1 | Click here to buy | |
4 | Temp & Hum Sensor | 1 | Click here to buy | |
5 | OSOYOO Active Buzzer Module | 1 | Click here to buy | |
6 | Flame Detection Sensor | 1 | Click here to buy | |
7 | Fan Motor Module | 1 | Click here to buy | |
8 | Micro Servo Motor | 1 | Click here to buy | |
9 | RGB Module | 1 | Click here to buy | |
10 | Ultrasonic Sensor | 1 | Click here to buy | |
11 | PIR Motion Sensor | 1 | Click here to buy | |
12 | Microphone Module | 1 | Click here to buy | |
13 | 1602 I2C LCD Screen | 1 | Click here to buy | |
14 | RFID Module | 1 | Click here to buy | |
15 | White LED Module | 1 | Click here to buy | |
16 | Red LED Module | 1 | Click here to buy | |
17 | Colorful Light | 1 | Click here to buy | |
18 | Red Button Module | 1 | Click here to buy | |
19 | Blue Button Module | 1 | Click here to buy | |
20 | Philips Screwdriver | 1 | Click here to buy |
DownLoad Url osoyoo.com