In this posting, we will introduce the client library of Thing + Cloud service that runs on WIZnet’s W7500x MCU. Thing + is a domestic company, DawWorks’ IoT Cloud platform service. It is based on easy and fast IoT service construction and supports various open source hardware (OSHW) such as Arduino and Beaglebone green.
SSL / TLS security support is required by default to work with the Thing + Cloud service. However, recently DaliWorks has provided a non-SSL port with Arduino thing + library for testing purposes for Arduino developers, so we have created a library that enables testing of Thing + Cloud in W7500x MCU.
The project code is based on the version 1.0.6 of Thing + Arduino library. We changed the existing library made in C ++ version to C and changed and ported various Arduino libraries to other available libraries.
For the subscription of Thing + service and registration of Gateway Device, please refer to ‘ User’s Guide of Arduino ‘ at the following link.
Note: The code introduced in this article is written in C language based on Keil vision 5 and is designed to run on WIZnet’s W4500x based ARM Cortex-M0 based Ethernet MCU. However, because it is very simple and has little dependency on MCU if you use WIZnet’s Hardware TCP / IP core, you can easily port it.
- Produced to be nearly identical to existing Arduino Thing + library
- Portable C ++ code to C code, flexible to existing C-based development environment
- Eclipse Paho MQTT client is used as MQTT client library, and commercial SSL / TLS security is added to create commercial IoT device that works with Thing + service
Configuring an Existing Arduino Library
Change each part of existing Arduino library to available library and modify the behavior
- MQTT Client: PubSubClient library -> Eclipse Paho library
- JSON Parser: ArduinoJSON library -> cJSON library
- Other Ethernet and Time related libraries utilize W7500x Driver and WIZnet ioLibrary
Library configuration for W7500x and comparison with existing library
- Source code can be found in GitHub Repository (thingplus branch)
- Included in WIZnet S2E device WIZ750SR project code
- Includes simple serial debug message for troubleshooting development
void thingplus_begin(uint8_t *mac, uint8_t *apikey)
Description : Initialize the Thing+ library Parameter - mac : mac address - apikey : apikey generated by Thing+ You can get apikey from Thing+ Portal
Description : Connect Thing+ via MQTT Before call this API, W7500x Device MUST CONNECT INTERNET.
Description : Disconnecting Thing+
Description : Doing MQTT related works. W7500x Device MUST CALL THIS API PERIODICALLY
Description : Send gateway status to Thing+ Parameter - on : True if gateway is on, false if gateway is off - validSec : Valid time. Unit is second. You must resend the status before timeout. If timeouted, the status is considered as error
Description : Send sensor status to Thing+ Parameter - id : Sensor id. - on : True if sensor is on, false if sensor is off - validSec : Valid time. Unit is second. You must resend the status before timeout. If timeouted, the status is considered as error
Description : Send sensor sting value to Thing+ Parameter - id : Sensor id. - value : Sensor value
Description : Send sensor interger value to Thing+ Parameter - id : Sensor id. - value : Sensor value
Description : Send sensor float value to Thing+ Parameter - id : Sensor id. - value : Sensor value
uint8_t thingplus_actuatorCallbackSet(uint8_t* (cb)(const uint8_t id, const uint8_t* cmd, cJSON *options))
Description : Register actuator callback function. Parameter - cb : Callback function pointer
Arduino Ver. VS WIZnet W7500x Ver.
- Both the Arduino library and the implemented W7500x library work in almost the same main routine structure
- If SSL / TLS support library is made later, the prototype structure in Arduino can be implemented in the same
Thing+ Dashboard Example