Updates for Wio Terminal’s Network Connectivity: What does “Wio” Stand For, A Brief Introduction of Realtek RTL8720DN, and How to Connect Wio Terminal to Wi-Fi and Obtain Data from the Internet
Today’s update for Wio Terminal is about one of its highlight features – its reliable & powerful network connectivity! In this post, we will talk about:
- What does “Wio” Stand for
- A Brief Introduction of Wio Terminal’s Wireless Core: Realtek RTL8720DN
- How to Connect Wio Terminal to Wi-Fi and Obtain Data from the Internet
What does “Wio” Stand for
Before we start, many of you might have a quick question: what does the “Wio” of Wio Terminal ever mean?
It is an abbreviation of “Wireless input and output”, a platform including hardware and software created by Seeed, aiming to simplify IoT development for makers. With the help of the Wio Family, even beginners can build his/her own IoT application within 5 minutes, no hardware programming, no breadboard, no jumper wires, no soldering.
Wio Terminal is the newest member of the Wio family. You must have noticed that it is quite different from its elder brothers, not a single embedded functional module but a simple and tiny device with highly-integrated design, packing multiple functions in a 72 x 57 x 12mm tiny but stylish enclosure. Together with its reliable wireless connectivity, setting up an IoT project is simpler than ever.
You can use Wio Terminal to make demos showing real-time data from the internet, for example, the live data of local weather or currency exchange rates., etc., without too many hard works. It even has built-in magnets and 2 mounting holes so you can fix it at almost any place you like as a monitor or dashboard.
A Brief Introduction of Wio Terminal’s Wireless Core: Realtek RTL8720DN
To empower Wio Terminal with powerful wireless connectivity, we adopted Realtek RTL8720DN, which can support both BLE / BLE 5.0 and Dual-Band 2.4Ghz / 5Ghz Wi-Fi, providing the backbone for IoT projects.
Here at Seeed, we also provide a Realtek RTL8720DN 2.4G/5G Dual Bands Wireless and BLE5.0 Combo Module for you. It is worth saying that this little module can support WiFi 5G and Bluetooth Low Energy 5.0 as well. With the main chip RTL8720DN, it can be regarded as an SoC for the WiFi and Bluetooth application with typical SBCs.
How to Connect Wio Terminal to Wi-Fi and Obtain Data from the Internet
Here comes the most important part: How to use Wio Terminal to obtain data from the internet? Today we will introduce how to use Wio Terminal to access to HTTPS server and grab live data from the internet. In this demo, Wio Terminal is used to obtain data from MicroPython’s Github repository and displayed on its LCD screen.
If you have your own Github repository, you can obtain data from yours, and attract Wio Terminal to your desktop so that you can know how many people star or fork your code without opening the page. Sounds quite excited for a maker, right? Of course, you can implement the Demo to other API such as grabbing weather information, Youtube Stats and etc. The possibilities are endless!
If you are a beginner to Wio Terminal, we have prepared many documents for you. Make sure you have updated the latest firmware for the Wireless Core Realtek RTL8720 on Wio Terminal before getting started with this demo. If you are not sure about how to configure Wi-Fi connectivity on Wio Terminal, check our detailed tutorial here.
Let’ s get started!
Hardware Requirement
Arduino libraries needed
- Install the LCD screen Library
Seeed_Arduino_LCD
, please visit Wio Terminal LCD for more information. - Visit the ArduinoJson repositories and download the entire repo to your local drive.
- Now, the ArduinoJson library can be installed to the Arduino IDE. Open the Arduino IDE, and click
sketch
->Include Library
->Add .ZIP Library
, and choose theArduinoJson
file that you’ve have just downloaded.
- Now, the ArduinoJson library can be installed to the Arduino IDE. Open the Arduino IDE, and click
- For more information about Https connection, please visit here.
Arduino Instructions
- Download the
Free_Fonts.h
header file so that can use abbreviations for the free fonts included in the LCD library. Please make sure to put this header file in the same location as the Arduino Sketch. - Download the Complete code here or copy the following.
- Upload the code.
Complete Code
Note: Change the ssid
and password
to your Network Wi-Fi.
#include <WiFiClientSecure.h>
#include <ArduinoJson.h>
#include"Free_Fonts.h"
#include"TFT_eSPI.h"
TFT_eSPI tft;
const char* ssid = "yourNetworkName";
const char* password = "yourNetworkPassword";
//29*27
const unsigned char watchIMG[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00,
0x00, 0xFC, 0x07, 0x00, 0x00, 0xFF, 0x1F, 0x00, 0x80, 0x1F, 0x3F, 0x00,
0xC0, 0x07, 0x7C, 0x00, 0xE0, 0x03, 0xF8, 0x00, 0xF0, 0xE1, 0xF0, 0x01,
0xF8, 0xF1, 0xF1, 0x01, 0xF8, 0xF8, 0xF1, 0x03, 0xFC, 0xF8, 0xF1, 0x03,
0xF8, 0xF0, 0xF1, 0x03, 0xF0, 0xF1, 0xF0, 0x01, 0xF0, 0x01, 0xF8, 0x00,
0xE0, 0x03, 0x78, 0x00, 0xC0, 0x07, 0x3E, 0x00, 0x80, 0xFF, 0x1F, 0x00,
0x00, 0xFE, 0x0F, 0x00, 0x00, 0xF8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char starIMG[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
0x00, 0xC0, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0x01, 0x00,
0x00, 0xF0, 0x01, 0x00, 0x00, 0xF0, 0x03, 0x00, 0x00, 0xF8, 0x03, 0x00,
0x00, 0xF8, 0x07, 0x00, 0x00, 0xFE, 0x0F, 0x00, 0xFE, 0xFF, 0xFF, 0x1F,
0xFE, 0xFF, 0xFF, 0x0F, 0xFC, 0xFF, 0xFF, 0x07, 0xF8, 0xFF, 0xFF, 0x03,
0xF0, 0xFF, 0xFF, 0x01, 0xC0, 0xFF, 0xFF, 0x00, 0x80, 0xFF, 0x7F, 0x00,
0x00, 0xFF, 0x3F, 0x00, 0x80, 0xFF, 0x3F, 0x00, 0x80, 0xFF, 0x3F, 0x00,
0x80, 0xFF, 0x3F, 0x00, 0x80, 0xFF, 0x7F, 0x00, 0x80, 0xBF, 0x7F, 0x00,
0xC0, 0x1F, 0x7E, 0x00, 0xC0, 0x07, 0x78, 0x00, 0xC0, 0x01, 0x70, 0x00,
0x40, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const unsigned char forkIMG[] = {
0xF8, 0x00, 0x00, 0x00, 0xFE, 0x03, 0x00, 0x00, 0x0F, 0x07, 0x00, 0x01,
0x07, 0x07, 0xE0, 0x0F, 0x07, 0x07, 0x78, 0x1E, 0x9E, 0x07, 0x38, 0x38,
0xFC, 0x01, 0x38, 0x38, 0xF8, 0x00, 0x38, 0x3C, 0xF8, 0x00, 0xF0, 0x1F,
0xF8, 0x00, 0xE0, 0x07, 0xF8, 0x00, 0xC0, 0x07, 0xF8, 0x00, 0xE0, 0x07,
0xF8, 0x00, 0xE0, 0x07, 0xF8, 0x00, 0xF8, 0x03, 0xF8, 0x00, 0xFE, 0x01,
0xF8, 0xE0, 0xFF, 0x00, 0xF8, 0xFF, 0x7F, 0x00, 0xF8, 0xFF, 0x1F, 0x00,
0xF8, 0xFF, 0x03, 0x00, 0xF8, 0x1F, 0x00, 0x00, 0xF8, 0x03, 0x00, 0x00,
0xF8, 0x01, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0xFC, 0x01, 0x00, 0x00,
0x9E, 0x07, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
0x0F, 0x07, 0x00, 0x00, 0xFE, 0x03, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00,
};
const char* server = "api.github.com"; // Server URL
const char* test_root_ca = \
"-----BEGIN CERTIFICATE-----\n"
"MIIEsTCCA5mgAwIBAgIQBOHnpNxc8vNtwCtCuF0VnzANBgkqhkiG9w0BAQsFADBs\n"
"MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n"
"d3cuZGlnaWNlcnQuY29tMSswKQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5j\n"
"ZSBFViBSb290IENBMB4XDTEzMTAyMjEyMDAwMFoXDTI4MTAyMjEyMDAwMFowcDEL\n"
"MAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZMBcGA1UECxMQd3d3\n"
"LmRpZ2ljZXJ0LmNvbTEvMC0GA1UEAxMmR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gNH\n"
"E+r1hspZcX30BJZr01lYPf7TMSVcGDiEo+afgv2MW5gxTs14nhr9hctJqvIni5ly\n"
"/D6q1UEL2tU2ob8cbkdJf17ZSHwD2f2LSaCYJkJA69aSEaRkCldUxPUd1gJea6zu\n"
"xICaEnL6VpPX/78whQYwvwt/Tv9XBZ0k7YXDK/umdaisLRbvfXknsuvCnQsH6qqF\n"
"0wGjIChBWUMo0oHjqvbsezt3tkBigAVBRQHvFwY+3sAzm2fTYS5yh+Rp/BIAV0Ae\n"
"cPUeybQ=\n"
"-----END CERTIFICATE-----\n";
// You can use x.509 client certificates if you want
//const char* test_client_key = ""; //to verify the client
//const char* test_client_cert = ""; //to verify the client
String github_data;
WiFiClientSecure client;
void setup() {
//Initialize serial and wait for port to open:
Serial.begin(115200);
delay(100);
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
WiFi.begin(ssid, password);
tft.begin();
tft.setRotation(3);
tft.fillScreen(TFT_BLACK);
tft.setTextSize(2);
tft.setCursor((320 - tft.textWidth("Connecting to Wi-Fi.."))/2, 120);
tft.print("Connecting to Wi-Fi..");
// attempt to connect to Wifi network:
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
// wait 1 second for re-trying
delay(1000);
}
Serial.print("Connected to ");
Serial.println(ssid);
tft.fillScreen(TFT_BLACK);
tft.setCursor((320 - tft.textWidth("Connected!"))/2, 120);
tft.print("Connected!");
getData();
}
void loop() {
// do nothing
}
void getData() {
client.setCACert(test_root_ca);
//client.setCertificate(test_client_key); // for client verification
//client.setPrivateKey(test_client_cert); // for client verification
tft.fillScreen(TFT_BLACK);
tft.setCursor((320 - tft.textWidth("Conectting to Server.."))/2, 120);
tft.print("Connecting to Server..");
Serial.println("\nStarting connection to server...");
if (!client.connect(server, 443)) {
Serial.println("Connection failed!");
tft.fillScreen(TFT_BLACK);
tft.setCursor((320 - tft.textWidth("Connection failed!"))/2, 120);
tft.print("Connection failed!");
} else {
Serial.println("Connected to server!");
tft.fillScreen(TFT_BLACK);
tft.setCursor((320 - tft.textWidth("Connected to Server!"))/2, 120);
tft.print("Connected to Server!");
// Make a HTTP request:
client.println("GET https://api.github.com/repos/micropython/micropython HTTP/1.0");
client.println("Host: api.github.com");
client.println("User-Agent: Seeed-Studio");
client.println("Connection: close");
client.println();
while (client.connected()) {
String line = client.readStringUntil('\n');
if (line == "\r") {
Serial.println("headers received");
break;
}
}
while(client.available())
{
String line = client.readStringUntil('\r');
github_data = line;
}
//Serial.println(github_data);
client.stop();
Serial.println("closing connection");
}
//ArduinoJson to parse data, plesae check ArduinoJson for more info
const size_t capacity = 2*JSON_OBJECT_SIZE(18) + JSON_OBJECT_SIZE(77) + 6050;
DynamicJsonDocument doc(capacity);
deserializeJson(doc, github_data);
int subscribers_count = doc["subscribers_count"];
int forks = doc["forks"];
int stargazers_count = doc["stargazers_count"];
Serial.println(subscribers_count);
Serial.println(forks);
Serial.println(stargazers_count);
//TFT SCREEN SESSION
tft.setFreeFont(FSS9);
tft.setTextSize(1);
tft.setTextColor(TFT_WHITE);
tft.fillScreen(TFT_BLACK);
tft.drawString("MicroPython Github",20,10);
tft.drawFastHLine(185,18,120 ,TFT_RED);
tft.drawFastHLine(185,19,120 ,TFT_RED);
tft.drawFastHLine(185,20,120 ,TFT_RED);
tft.drawFastHLine(10,33,300 ,TFT_NAVY);
tft.drawFastHLine(10,34,300 ,TFT_NAVY);
tft.drawFastHLine(10,35,300 ,TFT_NAVY);
tft.drawXBitmap(20,60, watchIMG, 29, 27, TFT_WHITE);
tft.drawXBitmap(20,120, starIMG, 30, 30, TFT_WHITE);
tft.drawXBitmap(20,180, forkIMG, 30, 30, TFT_WHITE);
tft.setFreeFont(FMB9);
tft.drawString("Watchers: ",60, 68);
tft.drawString("Stars: ",60, 128);
tft.drawString("Forks: ",60, 188);
tft.drawNumber(subscribers_count, 165, 68);
tft.drawNumber(stargazers_count, 130, 128);
tft.drawNumber(forks, 130, 188);
}
You can find more awesome demos with detailed tutorials at our wiki. Stay tuned with us and know more updates about Wio Terminal!