Difference between revisions of "LinkNode R1: Arduino-compatible WiFi relay controller"

From LinkSprite Playgound
Jump to: navigation, search
(Tutorials)
(Tutorials)
Line 73: Line 73:
  
 
[[File:R1-ways.png| 640px]]
 
[[File:R1-ways.png| 640px]]
 +
 +
 +
const int Relay = 16;
 +
 +
void setup()
 +
{
 +
// initialize digital pin GPIO2/D9 as an output.
 +
pinMode(Relay, OUTPUT);
 +
}
 +
 +
// the loop function runs over and over again forever
 +
void loop()
 +
{
 +
digitalWrite(Relay, HIGH);  // turn the LED on (HIGH is the voltage level)
 +
delay(1000);              // wait for a second
 +
digitalWrite(Relay, LOW);    // turn the LED off by making the voltage LOW
 +
delay(1000);              // wait for a second
 +
}
 +
After finish uploading, please check the Relay on the LinkNode R1, is it open or close?
 +
2. Hello World
 +
 +
Take the steps above and run the following code :
 +
void setup()
 +
{
 +
Serial.begin(115200);
 +
}
 +
 +
// the loop function runs over and over again forever
 +
void loop()
 +
{
 +
Serial.println("Hello world!");
 +
delay(1000);              // wait for a second
 +
}
 +
 +
* After finish uploading, and open the Serial Monitor in Arduino IDE
 +
* The serial will print Hello world! in every second.
 +
 +
3. Connect to 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 R1 to communicate with LinkSprite IO platform.
 +
 +
a. Prepare
 +
 +
Open Arduino IDE and go to Sketch --> Include Library --> Manage Libraries
 +
Search the wifimanager and install it
 +
Register to LinkSprite.IO
 +
Download the LinkSpriteIO code
 +
Move the code to Arduino-xxx/libraies/
 +
Open File -> Examples -> LinkSpriteIO -> LinkSpriteIO
 +
b. 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.

Revision as of 03:40, 21 April 2017

Introduction

LinkNode R1 is a WiFi development board which is powered by the high integrated WiFi chip ESP-8266EX.

Thanks for the contribution from open source community who have developed Arduino core for ESP8266, this let Aduino IDE program LinkNode R1 without any change. At the same time, LinkNode R1 has Arduino-compatible pin out which make it very easy to connect to Arduino Sensors.


DSC 2845-2.jpg

DSC 2847-2.jpg

DSC 2851-2.jpg

DSC 2848-2.jpg

Features

  • Powered by ESP-8266EX
  • 6 Digital I/O pins
  • 1 Analog Input pin
  • 1 Digital I/O for Relay
  • 1 DC port for power/configure
  • Power jack for 5V power input
  • Compatible with Arduino programming
  • Compatible with NodeMCU
  • OTA -- Wireless Upload(Program)

Tutorials

1. Get started in Arduino

If you have used Arduino before, you will feel that the LinkNode R1 is as same as Arduino, and there is no difference between their programming. The only limitation of LinkNode R1 is that it only has 6 digital ports and 1 analog input port.


a. Requirements


b. Install hardware package for LinkNode R1


R1-1.png


  • 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).


R1-2.png


c. Check the configuration of Board

Because the LinkNode R1 has not been added into the offcial ESP8266 Arduino core repository yet, so you can't find LinkNode R1 board on the boards list, but you can use the WeMos D1(Retired), this board is fully compotiable with LinkNode R1.


R1-3.png


d. Create a Arduino Project

  • Connect LinkNode R1 with a USB to TTL board to your PC
  • Check your serial port which your PC recognize
  • Enter the following source code and click the Upload button
  • Chose the Upload way and then uoloaded selecte Run way


R1-ways.png


const int Relay = 16;

void setup() { // initialize digital pin GPIO2/D9 as an output. pinMode(Relay, OUTPUT); }

// the loop function runs over and over again forever void loop() { digitalWrite(Relay, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(Relay, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second } After finish uploading, please check the Relay on the LinkNode R1, is it open or close? 2. Hello World

Take the steps above and run the following code : void setup() { Serial.begin(115200); }

// the loop function runs over and over again forever void loop() { Serial.println("Hello world!"); delay(1000); // wait for a second }

  • After finish uploading, and open the Serial Monitor in Arduino IDE
  • The serial will print Hello world! in every second.

3. Connect to 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 R1 to communicate with LinkSprite IO platform.

a. Prepare

Open Arduino IDE and go to Sketch --> Include Library --> Manage Libraries Search the wifimanager and install it Register to LinkSprite.IO Download the LinkSpriteIO code Move the code to Arduino-xxx/libraies/ Open File -> Examples -> LinkSpriteIO -> LinkSpriteIO b. 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.