Wiznet makers

gavinchang

Published October 03, 2022 ©

50 UCC

23 WCC

56 VAR

0 Contests

1 Followers

0 Following

Original Link

OneNET platform controls LED lights of W5500 development board

OneNET platform controls LED lights of W5500 development board

COMPONENTS Hardware components

WIZnet - W5500

x 1


PROJECT DESCRIPTION

foreword

Some noun explanations about the content of this article

1. Products

   Product refers to the virtual name corresponding to the real device in the user's hands on OneNET, and is the top-level cloud resource of the user on OneNET.

2. Product ID

Product ID refers to an independent ID number assigned by the OneNET backend for one of your real products. If one of your products has two different series (such as Iphone7/Iphone7 PLUS), it is recommended to establish two product to get two product IDs respectively.

3. APIKey

It is used for the authentication and permission control of operations on OneNET. When using the OneNET Restful API, the header field of the HTTP request message must carry the APIKey field, and OneNET will judge whether the user has the corresponding operation permission according to the APIKey field. right.

The permission model of APIKey is described by setting whether cloud resources can be added, viewed, modified, deleted, etc. The minimum permission level can be refined to the access permission to a certain data stream. APIKey is divided into two types:

1. Product APIKey: When creating a product, OneNET will generate a preset APIKey for the product. This APIKey is the Masterkey, which has the maximum permission and can access all resources under the product.

2. Device APIKey: The key created by the user for a device under a certain product is called the device APIKey. The function permission of the device APIKey is limited to the resources of this device, and cannot be accessed to other devices.

4. Device

The "device" in the cloud refers to the entity under the "product" mentioned above, and also refers to the unique virtual name corresponding to a certain real device of the user on OneNET.

5. Device ID (Device ID, DID)

Device ID refers to an independent and unique ID number assigned by the OneNET backend to one of your real devices. There can be multiple devices under one product, and each independent device has a unique device ID.

6. Device number

When users create a device on OneNET, if the device access protocol is HTTP, they need to fill in the "device number". The device number is the unique identification number owned by each real device. It does not need to be assigned by the OneNET background. The user can customize the device number, but the independence and uniqueness of each device must be guaranteed. It is recommended that the user enter the device The serial number of the original product line is used for numbering.

7. Datastream

A data stream can be understood as a type of data, such as the temperature of the sensor, the latitude and longitude of the location, and the humidity of the air. The user can define the data stream name, that is, the data stream ID; one device can add multiple data streams.

8. Datapoint

That is, a specific data value in a data stream. Data points are stored in the "Key-Value" method. The composition of Key includes device ID, data stream ID, time and other information, and the value part can be any data object, such as integer, string or JSON data type.

 

 

 

9. SDK

Divided into open protocol product SDK and private protocol product SDK

Open protocol product SDK: used for the terminal side software development kit whose device access protocol is an open protocol, OneNET provides SDKs in multiple languages, providing basic functions such as device connection and data upload.

Private protocol product SDK: When using the private protocol to access the device, OneNET will automatically generate the SDK source code according to the device data model defined by the developer, and the developer will embed the SDK into the device to automatically realize the docking with the platform. OneNET provides the full source code of the SDK for proprietary protocol products.

The purpose of the experiment is to control the on and off of the LED lights of the W5500 development board through the oneNET official APP and log in to the official website account to operate the product application.

experiment procedure:

1. Register an account on the oneNET platform;

Log in to https://open.iot.10086.cn/ , choose personal registration or enterprise registration according to your personal situation, and log in after registration.

OneNET platform controls LED lights of W5500 development board
 

 

2. Build the product

After logging in, click the developer center in the upper right corner and enter the corresponding product list interface;

 

 OneNET platform controls LED lights of W5500 development board

 

 

Click Create Product to fill in the basic information of the product in the pop-up page. Industry, category and progress can be filled in according to your actual situation;

OneNET platform controls LED lights of W5500 development board
 

 

Fill in the operating system, operator and networking method according to your actual situation. Our W5500 development board does not have an operating system, so choose None. Our development board is wired networking. Here I choose wifi. Which one to choose depends on my actual situation.

OneNET platform controls LED lights of W5500 development board
 

 

 

 

The choice of device access method and access protocol should be judged according to one's own project. There are two types: public and private. Public protocols include EDP, HTTP, MQTT, etc., and private protocols include RGMP. In this experiment we are going to use the EDP protocol.

OneNET platform controls LED lights of W5500 development board
 

 

(Note: There is a development file on the left side of the home page of oneNET, which contains a more detailed guide about the use of oneNET. Users can use this file to understand the use of OneNET more deeply.)

3. New device

After registering and logging in and creating your own product, enter the product page, select Device Management, and click Add Device to start adding devices to your product.

(1) Click on the product and enter the following page

 

 OneNET platform controls LED lights of W5500 development board

(2) Click Device Management and enter the following interface

 

 OneNET platform controls LED lights of W5500 development board

 

 

Follow the prompts to select the information of the new device

 

 OneNET platform controls LED lights of W5500 development board

4. Add a new data flow under the device, click the data flow template to enter the following interface

 OneNET platform controls LED lights of W5500 development board

 

Start adding data stream

OneNET platform controls LED lights of W5500 development board
 

 

(The test needs to upload the status of the four LED lights to the data stream of the device under the product, so it is necessary to create four data streams to receive the uploaded data. In this experiment, the data stream ID uploaded in the code is LED_0_statu, so we are most Well, change it to this, or modify the code part to your own defined ID.)

5. Now the registration and product establishment of oneNET have been basically completed. Next, we will upload data through code and then add device applications according to the uploaded data.

First of all, let's briefly introduce EDP, because we use the EDP protocol to upload/distribute data and commands in this experiment.

Introduction

EDP ​​(Enhanced Device Protocol) is a fully disclosed TCP-based protocol specially customized by the OneNET platform according to the characteristics of the Internet of Things, and can be widely used in household, transportation, logistics, energy and other industrial applications.

Features

long connection protocol

Data encrypted transmission

Terminal data point reporting, the supported data point types are:

floating point number (float)

Integer (int)

string (string)

JSON object

binary data

Platform message distribution (support offline message)

End-to-end data forwarding

 Access process

OneNET platform controls LED lights of W5500 development board
 

 

process:

 After adding a new data stream, the device first establishes a TCP connection with the platform and then establishes an EDP connection. After successful, the data can be uploaded and the command can be issued.

SDK:

 The software development kit provided by oneNET; the SDK used in this experiment is in the file center—open protocol product guide—device access—EDP—SDK

OneNET platform controls LED lights of W5500 development board
 

 

Users who are interested can download their own projects by themselves. This example provides an already ported and available SDK.

6. Code implementation

This routine is oneNET reversely controls the LED light of W5500 on and off, so after getting the routine provided by us, open the project and enter W5500_config.c to modify the IP address and gateway and other data information of the device so that it can be connected with your own computer. The same local area network in order to establish a TCP connection with the oneNET platform on your own computer. After modification, enter tcp_demo.c to modify the device ID and the device APIKEY for the device ID and APIKEY of the own product. Specific path: The device ID is under the established device in the device management.

OneNET platform controls LED lights of W5500 development board
 

 

APIKEY is under product overview

OneNET platform controls LED lights of W5500 development board
 

 

(Note: There are two types of APIKEY, one is the main APIKEY of a product in the screenshot above, which has the maximum permission to access all resources under the product and is generated by default when we build the product; the other is the device APIKEY, the user can add the APIKEY of the device under a certain device. Its function is limited to the resource operation under the device. The specific path is in the APIKEY management in the screenshot above. After clicking Add APIKEY, new information will pop up. box, users can add a device APIKEY for their own devices.)

After finding our own device ID and APIKEY, modify it in our project as follows:

OneNET platform controls LED lights of W5500 development board
 

 

7. After the code is modified, it can be compiled and programmed. Open the serial port assistant to see the relevant process.

OneNET platform controls LED lights of W5500 development board
 

 

After programming the code as shown in the picture above, our W5500 device establishes a TCP connection with the oneNET platform and then establishes an EDP connection to start uploading the status of our W5500 LED lights to the platform. At this time, log in to the platform and find the device management to see that the EDP connection has been established. , as the colored dots in the image below.

OneNET platform controls LED lights of W5500 development board
 

 

At this time, open the data flow management under the device to view the data flow uploaded to the platform as shown below:

OneNET platform controls LED lights of W5500 development board
 

 

After receiving the data, the device application can be created.

8. Create device application

Enter the product of the platform and click on the application management - create an application

OneNET platform controls LED lights of W5500 development board
 

 

After creation, click Edit to enter the application editing interface

OneNET platform controls LED lights of W5500 development board
 

 

The editing page is shown in the figure below, where you can edit the application, and drag the application you want to add into the editing area, such as the switches and dashboards in this experiment.

OneNET platform controls LED lights of W5500 development board
 

 

The application of this experiment has four switches and four dashboards. The switches are mainly responsible for transmitting the switch values ​​we set to our W5500 development board through EDP. The dashboard is responsible for displaying the LED lights uploaded by our development board to the platform. state.

We drag the switch on the left work column and look forward to our edit area:

OneNET platform controls LED lights of W5500 development board
 

 

Click on the right side of the dashboard editing area that we dragged over, and the configuration information will pop up as shown below:

OneNET platform controls LED lights of W5500 development board

 

Select and configure the data of the first dashboard according to the prompts, mainly the device selection of the data flow and the selection of the data flow corresponding to the device. After filling in, configure the remaining three dashboards and pay attention to the corresponding relationship of the data flow. Our experiment is to receive the data of the development board in four data streams under one device.

The configuration of the first dashboard is as follows:

OneNET platform controls LED lights of W5500 development board
 

 

Click the switch in the editing area to open the switch configuration window. The configuration is as follows:

OneNET platform controls LED lights of W5500 development board
 

 

explain:

The data stream part of the device name is the same as the dashboard. It should be noted that four different data streams under one device correspond to four dashboards and switches. The switch value part is the content of the command sent by the platform to the development board. For example, if you install After it is turned on, the platform will send 1O (indicating that the first light is on, 1 is an Arabic numeral, and O is the initial letter of Open) to the development board, and the development board parses the data after receiving it and performs the operation of turning on LED1.

It should be noted that the content of the EDP command in the figure; if you choose {V} as in the figure or write nothing directly, the effect is that the platform directly packs and transmits the value of the switch to the development board, and develops The board can execute the command when it finds the data according to the EDP command transmission rule. If it is not the above situation, such as {LED1}1, the change command means that the first LED light is assigned a value of 1, that is, LED1 is on. Then the platform is to package and transmit {LED1}1 to the development board. At this time, the development board needs to find two key parts, namely LED1 and 1, from the transmitted data. In this process, it is necessary to find "{}" from the data. abandon. Second, in our case above, we only need to find 1 and O. It's like saving a small step.

   After the first switch is configured, configure the remaining three in turn. After all of them are finished, the entire application will be added. Click Save and Preview to perform the actual operation experiment.

Users can directly log in to the oneNET webpage to turn on their own applications to operate the LED lights of the development board, or they can log in to their own accounts through the official mobile APP provided by oneNET to start the application operations.

The experimental inspection process is as follows:

 OneNET platform controls LED lights of W5500 development board

OneNET platform controls LED lights of W5500 development board
 

 

 

Editor's Note:

   Users can download the SDK and EDP protocol files of the code part from the official website. The connection is as follows:

SDK download about EDP in C language

https://github.com/cm-heclouds/edp_c

EDP ​​protocol file download

https://upfiles.heclouds.com/123/ueditor/2017/05/03/35c119697c30e06f1e857263fd7c5c3e.docx

Documents
Comments Write