To Remotely Control The LED with IBoard

To Remotely Control The LED with IBoard

Previously we introduced how to remotely monitor temperature in the room by using IBoard with DHT11 temperature sensor and LEWEI50 platform. Now, we want to go further, we do not only monitor the sensor data, but also realize remote control – of light at home from the office for example. Here we will use IBoard with an LED electronic brick for demonstration.

For hardware, we still use the plug-and-play electronic brick module, and the LED electronic brick will be linked to A0 pin of IBoard with connection cable.

In the experiment, we still use LEWEI50 as the network service platform. Anyway, as mentioned in the previous article, LEWEI50 only provides the control services with Chinese interface, while the English website does not support the control devices for now. So we still need to register a LEWEI50 account and get User Key and the corresponding gateway information, and then add and configure the corresponding devices and sensors. In this example, IBoard is to read the switch status information of the switch icon of the corresponding sensor in LEWEI50 platform via the address information. When the switch status is read as 1, the LED lamp will be turned on; when the switch status is read as 0, the LED lamp will be turned off.
The Chinese registration address is?首页 - 乐联网 - 乐为物联开放平台 - 物联网云服务运营专家 , and you can download the official library directly in the Chinese website: GitHub - lewei50/LeweiClient: An arduino example(HTTP) with Lewei50 (IOT) platform for free use .
After registration and downloading, log into the website. Click “Set up personal information” button under "My Account" directory, then the account information will be shown at the right side of the page under "Set up personal information" menu, record the current "user KEY ". Value of "User KEY" is the value of "LW_USERKEY" in control example of LeweiClient library. In this example, the user KEY is "2e9f9105bb784f39a111e75c48d49b02".

Click "My gateway” button under “My LEWEI50 device" directory, fill in the blanks according to the following examples in "Add New Gateway" page and then click the “Save” button. Among which, the ID value is the "LW_GATEWAY" value in the control example of LeweiClient library; "Name" value is the "MY_NAME" value in the control example of LeweiClient library; "Gateway introduction" value is "MY_DESC" value in the control example of LeweiClient library. In this example, the gateway ID value is 01; gateway "Name" is UNO1; "Gateway introduction" is "UNO test case". Then tick in the "Controllable or not" options and in " Allow " option of "Public network access ".

After adding the new gateway, a measurement device must be added for it. Click the "New" button under "Control device" of "My Device" bar to enter the page for adding control device. Fill in the blanks in accordance with the following examples, and then click Save. Among which, the "abbreviation" value is the ID value of control LED lamp in control example of LeweiClient library, and "DA" indicates to control LED lamp 1. After adding the device, the list information of control LED lamp control device abbreviated "DA" can be seen on the page.



After saving the settings, use Arduino IDE to open control examples in LeweiClient library. First, we need to replace the "LW_USERKEY" value with the user KEY "2e9f9105bb784f39a111e75c48d49b02" obtained during registration, the "LW_GATEWAY" value with the gateway ID value "01", the "MY_NAME" value with gateway name value "UNO1", "MY_DESC" value with the gateway name value "UNO test case" and the ID value defining LED with the abbreviation value of control device "DA". If we follow the previous steps 1-4, "LW_GATEWAY", "MY_NAME", "MY_DESC" and the ID value defining LED will need no modifications. In the codes, we use A0 pin of IBoard to control LED lamp, and we replace the ledPin_da value with "A0" and the ledPin_da2 value with "A1" or any of the unoccupied pins (to prevent it from interrupting running of the program).

After compiling of program passed, use FOCA to connect Iboard with the computer and download the program to IBoard .
Since the routine to control LED lamp must be realized with cross-segment network, we need to set up the service port of virtual server on the router. First, open the serial port of Arduino IDE, after running for a while, the serial port monitor will display Iboard's IP address and port number. In this example, Iboard IP address is "10.0.0.135", and port is "8889." Next, open the address of the router on the webpage, find the "Virtual Server" settings page under "Route Settings", and then add Service Port "8889" to the Iboard with IP address "10.0.0.135". After the addition,the function of controlling LED lamp can be achieved through the webpage.


Click "User center"on LEWEI50 webpage, after entering the Welcome page, click the "My Device" button under "My LEWEI50 device" directory, under the "Control" column of "Control Devices" list, we can see the icon of LED lamp 1, its color will change each time when the icon is switched. When the color of switch icon is blue, it indicates that the switch is open and LED lamp will be turned on; when the color of switch icon is red, it means the switch is closed and LED lamp will be turned off; when the color of switch icon is gray, it indicates switch is open while Iboard is not connected yet.





As we mentioned before, because LEWEI50 only provides control interface of Chinese version, if you know some English platform offering such network services, please let us know and we will do test there and then offer a detailed tutorial to show you how to realize remote monitoring and control by using IBoard, IBoard Ex, etc with such networking platforms.