Difference between revisions of "LinkNode R8: Arduino-compatible WiFi relay controller"
(→2. Remotely control LinkNode R8 with LinkSprite.IO platform) |
(→1. Get started in Arduino programming) |
||
(35 intermediate revisions by 2 users not shown) | |||
Line 3: | Line 3: | ||
LinkNode R8 is a WiFi relay controller and it is powered by ESP-12f ESP8266 WiFi module which is comptiable with Arduino programming. There are 8 relay channels and each channel allows you to control high-power devices (up to 10 A) via the on-board relay. LinkNode R8 can be used to remotely turn lights, fans and other devices on/off. The WiFi interface will allow you to associate the board with your existing WiFi network and send the commands over the network. | LinkNode R8 is a WiFi relay controller and it is powered by ESP-12f ESP8266 WiFi module which is comptiable with Arduino programming. There are 8 relay channels and each channel allows you to control high-power devices (up to 10 A) via the on-board relay. LinkNode R8 can be used to remotely turn lights, fans and other devices on/off. The WiFi interface will allow you to associate the board with your existing WiFi network and send the commands over the network. | ||
− | |||
− | == | + | [[File:LinkNode R8-5.jpg|640px]] |
+ | |||
+ | [[File:LinkNode R8-6.jpg|640px]] | ||
+ | |||
+ | [[File:LinkNode R8-7.jpg|640px]] | ||
+ | |||
+ | [[File:LinkNode R8-8.jpg|640px]] | ||
+ | |||
+ | [[File:LinkNode R8-9.jpg|640px]] | ||
+ | |||
+ | [[File:LinkNode R8-10.jpg|640px]] | ||
+ | |||
+ | == Features == | ||
*ESP-12f ESP8266 WiFi module | *ESP-12f ESP8266 WiFi module | ||
Line 11: | Line 22: | ||
**277V AC, 10A | **277V AC, 10A | ||
**125V AC, 12A | **125V AC, 12A | ||
− | * | + | *5V DC power |
*Two work modes: | *Two work modes: | ||
**Program via UART | **Program via UART | ||
**Boot from flash | **Boot from flash | ||
− | * | + | *8 indiator LEDs |
== LinkNode R8 Diagram == | == LinkNode R8 Diagram == | ||
− | + | == Control logic == | |
− | == | + | [[File:1-262-a.jpg]] |
+ | |||
+ | == How to use Android APP to control LinkNode R8 == | ||
+ | |||
+ | LinkNode R8 is an open source 8-Channel relay controller which is powered by the ESP8266 WiFi SoC. | ||
+ | |||
+ | |||
+ | |||
+ | The following will introduce how to use Android APP to control the LinkNode R8. | ||
+ | |||
+ | === '''Steps''' === | ||
+ | |||
+ | '''1. Install Android APP And IOS APP''' | ||
+ | *Download the APK file from the [https://github.com/delongqilinksprite/LinkNodeR4-app/blob/master/LinkNode-Rx-2016-12.apk LinkNode-Rx-2016-12.apk] and install it. | ||
+ | *If your equipment is iphone/ipad,you can get the app form appstore and name is "LinkNode Relay". | ||
+ | *IOS App download link :[https://itunes.apple.com/cn/app/linknode-relay/id1163468201?mt=8 LinkNode Relay] | ||
+ | |||
+ | '''2. Login LinkSpriteIO''' | ||
+ | *If you never register an account on LinkSpriteIO, please enter Email and your password, then click the '''REGISTER''' button | ||
+ | *If you have an account on LinkSpriteIO, please enter Email and your password, then click the '''SIGN IN''' button | ||
+ | |||
+ | [[File:LinkNode R4 1.png]] | ||
+ | |||
+ | '''3. Go to Relay device list''' | ||
+ | |||
+ | *Click the plus icon on the upper right quarter to add a new LinkNode R8. | ||
+ | |||
+ | [[File:LinkNode R4 2.png]] | ||
+ | |||
+ | '''4. Scan the QRcode''' | ||
+ | |||
+ | *Get the device information and register it to your account. | ||
+ | |||
+ | [[File:LinkNode R4 3.png]] | ||
+ | [[File:LinkNode R4 4.png]] | ||
+ | |||
+ | |||
+ | '''5. Configure to accece WiFi AP''' | ||
+ | *Supply the power for LinkNodeR8, the LinkNode R8 will create a AP called LinkNodeAP | ||
+ | *Use your mobile phone to connect this AP | ||
+ | *Open a browser and enter the ip address 10.0.1.1 and you will see the following website: | ||
+ | |||
+ | [[File:LinkNode R4 5.png]] | ||
+ | |||
+ | *Click the button configure WiFi | ||
+ | *Select your WiFi AP which you want to connect and enter your wifi password. | ||
+ | *If connecting failed, you can go to the same website to configure it again. | ||
+ | *After that, LinkNode R8 will connect to Linksprite IO via the internet. | ||
− | + | '''6. Control your 4-channel relay''' | |
+ | *control the button on the right side to turn on or off the relays, and you can click the relay's name to change it. | ||
+ | [[File:LinkNode R4 6.png]] | ||
== Tutorial == | == Tutorial == | ||
Line 38: | Line 98: | ||
** Hardware** | ** Hardware** | ||
− | * | + | *5V 1A DC power is recommanded. |
*USB TTL UART cable | *USB TTL UART cable | ||
Line 59: | Line 119: | ||
c. Check the configuration of Board | c. Check the configuration of Board | ||
− | Because the LinkNode R8 has not been added into the offcial ESP8266 Arduino core repository yet, so you can't find | + | Because the LinkNode R8 has not been added into the offcial ESP8266 Arduino core repository yet, so you can't find LinkNode R8 board on the boards list, but you can use the WeMos D1(Retired), this board is fully compotiable with LinkNode R8. |
− | [[File:1- | + | [[File:1-178.png]] |
d. Create a Arduino Project | d. Create a Arduino Project | ||
Line 85: | Line 145: | ||
e. Test | e. Test | ||
− | |||
+ | [[File:540px-LinkerNodeR8_a.jpg|540px]] | ||
*Jump out the S5 on LinkNode R8 and select program via UART | *Jump out the S5 on LinkNode R8 and select program via UART | ||
*Connect DC power to LinkNode R8 | *Connect DC power to LinkNode R8 | ||
Line 97: | Line 157: | ||
=== 2. Remotely control LinkNode R8 with LinkSprite.IO platform === | === 2. Remotely control LinkNode R8 with LinkSprite.IO platform === | ||
− | [https://github.com/YaoQ/pcduino-doc/blob/master/LinkNodeR4/www.linksprite.io LinkSprite IO] is an IoT platform which supports RESTful API and WebSocket. These make the mobile APP, website application or device connect it very easily. The following I will introduce is about how to use LinkNode | + | [https://github.com/YaoQ/pcduino-doc/blob/master/LinkNodeR4/www.linksprite.io LinkSprite IO] is an IoT platform which supports RESTful API and WebSocket. These make the mobile APP, website application or device connect it very easily. The following I will introduce is about how to use LinkNode R8 to communicate with LinkSprite IO platform. |
a. Create a new account and device on LinkSprite.io | a. Create a new account and device on LinkSprite.io | ||
Line 128: | Line 188: | ||
To make it more convinent, we add WiFi manager library in this demo. | To make it more convinent, we add WiFi manager library in this demo. | ||
− | The ESP8266 WiFi Connection manager with web captive portal, this Arduino library can make configure AP's SSID and password via web page when you want LinkNode | + | The ESP8266 WiFi Connection manager with web captive portal, this Arduino library can make configure AP's SSID and password via web page when you want LinkNode R8 to connect to AP. |
*Open Arduino IDE and go to Sketch --> Include Library --> Manage Libraries | *Open Arduino IDE and go to Sketch --> Include Library --> Manage Libraries | ||
Line 237: | Line 297: | ||
*Click the button ON and OFF | *Click the button ON and OFF | ||
*Check the status of relay on LinkNode R8, is it following your control? | *Check the status of relay on LinkNode R8, is it following your control? | ||
+ | |||
+ | ==Dimension== | ||
+ | |||
+ | [[File:Dimension R8.png]] | ||
+ | |||
+ | |||
+ | ==3D printing enclosure== | ||
+ | |||
+ | [[File:LinkNode_R8a.png]] | ||
+ | |||
+ | [[File:LinkNode_R8b.png]] | ||
+ | |||
+ | [https://s3.amazonaws.com/cutedigi/Linknode+R8/LinkNode+R8a.STL Linknode R8 3D Builder a] | ||
+ | |||
+ | [https://s3.amazonaws.com/cutedigi/Linknode+R8/LinkNode+R8b.stl Linknode R8 3D Builder b] |
Latest revision as of 07:14, 18 May 2017
Contents
Introduction
LinkNode R8 is a WiFi relay controller and it is powered by ESP-12f ESP8266 WiFi module which is comptiable with Arduino programming. There are 8 relay channels and each channel allows you to control high-power devices (up to 10 A) via the on-board relay. LinkNode R8 can be used to remotely turn lights, fans and other devices on/off. The WiFi interface will allow you to associate the board with your existing WiFi network and send the commands over the network.
Features
- ESP-12f ESP8266 WiFi module
- 8 Channel relays,supporting:
- 277V AC, 10A
- 125V AC, 12A
- 5V DC power
- Two work modes:
- Program via UART
- Boot from flash
- 8 indiator LEDs
LinkNode R8 Diagram
Control logic
How to use Android APP to control LinkNode R8
LinkNode R8 is an open source 8-Channel relay controller which is powered by the ESP8266 WiFi SoC.
The following will introduce how to use Android APP to control the LinkNode R8.
Steps
1. Install Android APP And IOS APP
- Download the APK file from the LinkNode-Rx-2016-12.apk and install it.
- If your equipment is iphone/ipad,you can get the app form appstore and name is "LinkNode Relay".
- IOS App download link :LinkNode Relay
2. Login LinkSpriteIO
- If you never register an account on LinkSpriteIO, please enter Email and your password, then click the REGISTER button
- If you have an account on LinkSpriteIO, please enter Email and your password, then click the SIGN IN button
3. Go to Relay device list
- Click the plus icon on the upper right quarter to add a new LinkNode R8.
4. Scan the QRcode
- Get the device information and register it to your account.
5. Configure to accece WiFi AP
- Supply the power for LinkNodeR8, the LinkNode R8 will create a AP called LinkNodeAP
- Use your mobile phone to connect this AP
- Open a browser and enter the ip address 10.0.1.1 and you will see the following website:
- Click the button configure WiFi
- Select your WiFi AP which you want to connect and enter your wifi password.
- If connecting failed, you can go to the same website to configure it again.
- After that, LinkNode R8 will connect to Linksprite IO via the internet.
6. Control your 4-channel relay
- control the button on the right side to turn on or off the relays, and you can click the relay's name to change it.
Tutorial
1. Get started in Arduino programming
a. Requirements
Software
- Arduino IDE, (the latest version is 1.6.8 )
- The Arduino core for LinkNode R8
** Hardware**
- 5V 1A DC power is recommanded.
- USB TTL UART cable
b. Install Arduino core for ESP8266
- Install Arduino 1.6.8 from the Arduino website.
- Start Arduino and go to File --> Preferences .
- Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs field. You can add multiple URLs, separating them with commas.
- Open Boards Manager from Tools --> Board menu --> Boards Manager.
- Search and install esp8266 platform (and don't forget to select your ESP8266 board from Tools --> Board menu after installation).
c. Check the configuration of Board
Because the LinkNode R8 has not been added into the offcial ESP8266 Arduino core repository yet, so you can't find LinkNode R8 board on the boards list, but you can use the WeMos D1(Retired), this board is fully compotiable with LinkNode R8.
d. Create a Arduino Project
- Enter the following source code and compile
/*Turn on and off the S3 relay in every second */ void setup() { pinMode(12,OUTPUT); Serial.begin(9600); } void loop() { digitalWrite(12,HIGH); Serial.println("Relay ON\n"); delay(1000); digitalWrite(12,LOW); Serial.println("Relay OFF\n"); delay(1000); }
e. Test
- Jump out the S5 on LinkNode R8 and select program via UART
- Connect DC power to LinkNode R8
- Connect USB TTL UART cable to UART port of LinkNode R8
- Connnect the other side to PC
- Check your serial port which your PC recognize
- Click the **Upload* on Arduino IDE
- After finished, jump out the S5 on LinkNode R8 and select boot from flash
2. Remotely control LinkNode R8 with LinkSprite.IO platform
LinkSprite IO is an IoT platform which supports RESTful API and WebSocket. These make the mobile APP, website application or device connect it very easily. The following I will introduce is about how to use LinkNode R8 to communicate with LinkSprite IO platform.
a. Create a new account and device on LinkSprite.io
Go to www.linksprite.io and sign up Enter your Email and password to create a new account Go to My Account to get your own API Key. The API Key is fatal because only add the Key in your codes, can the data sync to your IoTgo account.
- Click My Device, and choose Create DIY Device.
- Click the created device icon and get the DeviceID.
b. Query the source code using your own apikey and device ID
Device API which the LinkSprite IO support is JSON-based, which means all request and response data is enclosed in JSON format. Currently it supports 3 kind of request.
- Update: Update device status to LinkSprite IO
- Query: Get device status from LinkSprite IO
This demo will send http POST request to query the param--light on linksprite.io, if the light is on, then turn one relay on, if off, then turn off the relay.
c. Install WiFi Manager library
To make it more convinent, we add WiFi manager library in this demo.
The ESP8266 WiFi Connection manager with web captive portal, this Arduino library can make configure AP's SSID and password via web page when you want LinkNode R8 to connect to AP.
- Open Arduino IDE and go to Sketch --> Include Library --> Manage Libraries
- Search the wifimanager and install it
d. Develope source code
- Enter the following source code
- Configure your apikey and deviceID in the source code
#include <ESP8266WiFi.h> #include <WString.h> //the library are needed for autoconfig WiFi #include <DNSServer.h> #include <ESP8266WebServer.h> #include <WiFiManager.h> // replace with your own API key and device ID, String apikey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"; const char* deviceID="xxxxxxxxxxxxx"; const char* server = "www.linksprite.io"; WiFiClient client; void setup() { Serial.begin(115200); pinMode(12, OUTPUT); WiFiManager wifiManager; wifiManager.setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0)); wifiManager.autoConnect("LinkNodeAP"); Serial.print("WiFi Connected ...\n"); Serial.println("WiFi connected"); } void loop() { if (client.connect(server,80)) { String postStr ="{"; postStr +="\"action\":\"query\","; postStr +="\"apikey\":\""; postStr += apikey; postStr +="\","; postStr +="\"deviceid\":\""; postStr += deviceID; postStr +="\","; postStr += "\"params\":"; postStr += "["; postStr += "\"light\""; postStr +="]"; postStr +="}"; client.print("POST /api/http HTTP/1.1\n"); client.print("Host: "); client.print(server); client.print("\nContent-Type: application/json\n"); client.print("Content-Length: "); client.print(postStr.length()); client.print("\n\n"); client.print(postStr); } delay(1000); Serial.println("Store response..."); String request = ""; while (client.available()) { char c = client.read(); request +=c; } if (request!= NULL) { int index1 = request.indexOf(":{"); int index2 = request.indexOf("},"); String param = request.substring(index1, index2 + 1); Serial.print("The param is "); Serial.println(param);
if(param.indexOf("off")>0){ digitalWrite(12, LOW); Serial.println("OFF"); } else if(param.indexOf("on")>0){ digitalWrite(12, HIGH); Serial.println("ON"); }
client.stop(); Serial.println("Waiting..."); delay(2000); } }
e. Configure to accece WiFi AP
- Take the step above to upload the program, the LinkNode R8 will create a AP called LinkNodeAP
- Use your mobile phone to connect this AP
- Open a browser and enter the ip address 10.0.1.1 and you will see the following website:
- Click the button configure WiFi
- Select your WiFi AP which you want to connect and enter your wifi password.
- If connecting failed, you can go to the same website to configure it again.
- Also, you can use Serial Monitor in Arduino IDE to check the status.
- After that, LinkNode R8 will connect to Linksprite IO via the internet.
f. Test
- Open the serial monitor to check the status
- Open your light device which is create on linksprite.io
- Click the button ON and OFF
- Check the status of relay on LinkNode R8, is it following your control?
Dimension