introduction
In “About WoT (Web of Things) Technology” I gave an overview of the WoT. This time, I would like to discuss specific implementations of the WoT. First, let’s start with an overview of the WoT and examples of its application.
WoT Overview
WoT (Web of Things) will be a standardized architecture and protocol for interconnecting various devices on the Internet and enabling communication and interaction between devices. WoT is intended to extend the Internet of Things (IoT), simplify interactions with devices, and increase interoperability.
The main features and benefits of the WoT include
- Standardized interfaces: The WoT provides a common metadata format, the Thing Description (TD), for describing device functions, attributes, methods, events, etc. The TD enables the definition of common interfaces between different devices. TD enables the definition of a common interface between different devices.
- Interoperability: WoT can handle devices and services provided by different vendors in a unified manner; the TD specifies device functions and characteristics, thereby improving interoperability between different platforms and protocols.
- Seamless device-to-device communication: WoT simplifies communication between devices; devices implementing WoT can communicate directly with other devices and applications using standard protocols such as HTTP, CoAP, and MQTT.
- Cloud integration: WoT also facilitates integration with cloud-based services and applications, allowing data exchange with applications in the cloud.
Security and Privacy: The WoT is also designed with security and privacy in mind. These include built-in security features such as authentication, privilege management, and data encryption to enable secure communication with devices.
Examples of WoT applications
The WoT has extensive applications in a variety of areas, including
- Smart Home: The WoT can be used to integrate and control smart home devices. For example, devices such as lighting, temperature control, security systems, and energy management can be connected via WoT to provide a unified interface.
- Smart cities: the WoT can be used to integrate smart city infrastructure and services. Specific examples include devices and services such as public transportation systems, parking management, garbage collection, and lighting control that are connected via WoT to collect data and operate efficiently.
- Industrial Control: The WoT can be used to integrate industrial control systems for monitoring and control. Examples include monitoring manufacturing processes, controlling machinery, and collecting sensor data.
- Agriculture: WoT can be used to integrate agricultural processes and equipment to manage crops and improve efficiency. Examples include devices such as soil sensors, watering systems, and greenhouse controls that are connected via WoT to optimize agricultural production.
- Healthcare: The WoT can be used to integrate healthcare devices and systems to support medical and healthcare management. Examples include connecting monitoring devices, medical equipment, personal wearables, etc. via the WoT to enable real-time data collection and remote healthcare.
Combining WoT and Artificial Intelligence Technology
By combining WoT and artificial intelligence (AI) technologies, more advanced smart systems and intelligent devices can be realized. Specific examples of this combination are described below.
- Smart Home Self-Learning: By incorporating AI technology into smart home devices connected using WoT, devices can learn about their environment and user behavior to provide optimal settings and comfort. This would specifically be like a lighting and temperature control system that learns the user’s preferences and habits and automatically provides the optimal environment.
- Smart city data analysis: large amounts of data collected from WoT-connected smart city devices can be analyzed using AI technology to optimize traffic flow, optimize energy consumption, improve urban planning, etc. AI algorithms can extract patterns and trends in data to support more efficient decision-making and forecasting.
- Industrial Control Optimization: The combination of WoT devices and AI technology enables the optimization of industrial control systems and predictive maintenance. Real-time monitoring of sensor data and analysis by AI algorithms will enable anomaly detection, fault prediction, and optimization of production efficiency.
- Personalization of healthcare: Combining WoT devices and AI technology will enable personalization of individual health management and medical services. AI algorithms will be able to analyze data obtained from personal wearable devices and medical sensors to monitor and predict health conditions and propose individualized treatment plans.
Thus, the combination of WoT and AI technologies will be a powerful means of creating smarter and more intelligent systems and devices, and the interoperability between these devices, combined with the data analysis and decision-making capabilities of AI, will enable greater levels of automation and optimization.
The next section describes the steps to implement these WoTs.
WoT Implementation Procedure
The WoT will be a standardized protocol and architecture for connecting and interacting with various devices on the Internet. The steps to implement them are described below.
- Device Preparation: Select the devices that will implement the WoT. This can be a sensor, actuator, microcontroller, or other embedded system. Verify that the device supports WoT and meets the necessary software and hardware requirements.
- Select a WoT protocol: In order to implement WoT, a standardized protocol for WoT must be selected. Typically, a metadata format in JSON-LD format called WoT Thing Description (TD) is used. In addition, various protocols such as HTTP, CoAP, and MQTT can be used for WoT implementation.
- Creation of Thing Description (TD): A Thing Description (TD) is created to describe the device’s functions, attributes, methods, events, etc. The TD is metadata that describes the device’s functions and is an important element for exposing the device to the WoT framework. The TD is metadata that describes the functionality of the device and is an important element for publishing the device to the WoT framework.
- Build or use a WoT server: Build a WoT server to control WoT devices or use an existing WoT server; the WoT server provides the interface to which devices are connected and interact with WoT applications.
- Develop a WoT application: develop a client application to interact with the WoT device. Applications can use TD to search for and access device functionality.
- Connect and interact with the device: Connect the WoT device to the WoT server and expose the device’s TD; the WoT application uses the TD to access the device’s functionality and interact with the device.
Libraries and platforms that can be used for WoT
There are various libraries and platforms available to implement WoT. Some of the more common options are described below.
- Thing Description(TD): The Thing Description, the core specification of WoT, describes metadata such as functions, interfaces, and properties of devices and services. Libraries and tools for creating and analyzing these Thing Descriptions are provided by W3C and other organizations.
- Node-WoT: Node-WoT will be a JavaScript library for building WoT applications, running on Node.js and providing methods and APIs for implementing and manipulating WoT functions.
- Eclipse Thingweb: Eclipse Thingweb is one of the WoT platforms that provides frameworks and tools for developing WoT applications. It supports parsing and generating Thing Descriptions, building WoT servers, and more.
- Wakaama : Wakaama is an open source library provided by the Eclipse Foundation that will be used to develop Constrained Application Protocol (CoAP) based Web of Things (WoT) applications.
- Thingsboard: Thingsboard is an open source IoT platform that will provide tools and functionality to implement and manage WoT functionality. These include device connectivity, data collection and visualization, and a rules engine.
- FIWARE: FIWARE will be an open source platform that will support the development of IoT and smart city applications, etc. With FIWARE, tools and components are available to integrate and manage WoT devices and services.
- Webthing GateWay: Web Thing Gateway is a platform for integrating and controlling WoT devices and services. It is an open source project developed by Mozilla and will allow users to manage and operate WoT devices via a web browser.
- pywot : The webthing module, in partnership with Mozilla’s Things Gateway, will be a Python 3 module implementing the Web of Things (WoT) API, allowing Python modules to talk to systems communicating via the WoT protocol. The pywot module will be a webthing wrapped in a more Pythonic interface.
Finally, we will discuss specific concrete implementation examples.
Example python implementation of WoT
As an example of a Python implementation of WoT, we describe how to create a simple WoT device through the following steps.
- Installation of required libraries: In order to implement a WoT device in Python, the following pywot libraries must be installed.
- Creating a WoT device: Create a Python script to define a WoT device. The following is a simple example.
from pywot import WoT, Thing
# Definition of WoT Devices
thing = Thing()
thing.add_property("temperature", 25.0)
# Export WoT Devices
wot = WoT()
wot.add_device("my-device", thing)
In the above example, we have created a WoT device with the property “temperature”.
- Start the WoT Server: Start the WoT server to serve the WoT device. The following is a simple example.
# Starting the WoT Server
wot.start()
This will activate the WoT server and provide the WoT device created.
- Access to WoT devices: use the WoT API to access WoT devices from other clients or applications. The following is a simple example.
from pywot import WoT
# Creating a WoT Client
wot = WoT()
# Access to WoT devices
my_device = wot.get_thing("my-device")
print(my_device.properties["temperature"].get())
In the above example, a WoT client is created to access a WoT device named “my-device” and retrieve the value of the “temperature” property.
This example shows only simple property addition and value retrieval, but more complex operations and other WoT functions (methods, events, etc.) could be added.
Example of WoT implementation using C and Wakaama
Next, an example of a WoT implementation using C and Wakaama is shown. In this example, Wakaama is used to create a simple temperature sensor device and provide temperature values via the CoAP protocol.
First, download and build the Wakaama source code.
- Download the source code for Wakaama. They are available from the GitHub repository at https://github.com/eclipse/wakaama.
- Extract the downloaded source code and build. The build method is described in Wakaama’s README file.
Once the build is complete, the following C code is used to implement the temperature sensor device. In this example, temperature values are randomly generated and responded to the client via the CoAP protocol.
#include
#include
#include
#include "wakaama/liblwm2m.h"
#include "wakaama/network.h"
#define SERVER_URI "coap://localhost:5683"
#define ENDPOINT_NAME "temperature-sensor"
// Object ID and resource ID
#define TEMP_OBJECT_ID 3303
#define TEMP_SENSOR_ID 5700
// Set device information
static uint16_t deviceId = 1234;
static char* manufacturer = "Example Inc.";
static char* modelNumber = "1.0";
static char* serialNumber = "001";
static char* firmwareVersion = "1.0";
static uint8_t powerSource = 1;
// Obtain sensor temperature values
float getTemperature()
{
// Randomly generated temporary temperature values (from 0°C to 40°C)
float temperature = (rand() % 401) / 10.0;
return temperature;
}
// Set the resource value of the object
static void setTemperature(lwm2m_data_t *data)
{
float temperature = getTemperature();
lwm2m_data_encode_float(temperature, data);
}
// Object callback function
static uint8_t objectCallback(uint16_t instanceId,
int *numDataP,
lwm2m_data_t **dataArrayP,
lwm2m_object_t *objectP)
{
uint8_t result = COAP_205_CONTENT;
if (*numDataP == 0)
{
*dataArrayP = lwm2m_data_new(1);
if (*dataArrayP == NULL)
return COAP_500_INTERNAL_SERVER_ERROR;
*numDataP = 1;
(*dataArrayP)[0].id = TEMP_SENSOR_ID;
}
for (int i = 0; i < *numDataP; i++) { switch ((*dataArrayP)[i].id) { case TEMP_SENSOR_ID: setTemperature(&((*dataArrayP)[i])); break; default: result = COAP_404_NOT_FOUND; break; } } return result; } int main(int argc, char* argv[]) { srand(time(NULL)); // サーバーへの接続設定 lwm2m_context_t *lwm2mH = lwm2m_init(NULL); if (lwm2mH == NULL) { fprintf(stderr, "lwm2m_init() failedn"); return -1; } // サーバーのURIを設定 lwm2m_set_bootstrap_server(lwm2mH, 0, SERVER_URI); // デバイスの情報を設定 lwm2m_security_t security; memset(&security, 0, sizeof(lwm2m_security_t)); security.serverUri = strdup(SERVER_URI); security.bootstrapServer = false; security.securityMode = LWM2M_SECURITY_MODE_NONE; security.publicIdentity = NULL; security.secretKey = NULL; security.publicKey = NULL; security.serverId = 123; lwm2m_add_server(lwm2mH, &security); // デバイスオブジェクトを作成 lwm2m_object_t* deviceObj = lwm2m_object_create(); deviceObj->objID = LWM2M_DEVICE_OBJECT_ID;
deviceObj->instanceList = lwm2m_list_new(1);
lwm2m_list_t* instance = lwm2m_list_new(1);
instance->id = 0;
deviceObj->instanceList = instance;
lwm2m_object_instance_t* deviceInstance = lwm2m_object_instance_create(0, deviceObj);
lwm2m_object_instance_add(deviceObj, deviceInstance);
// Set device information
lwm2m_device_set_manufacturer(deviceInstance, manufacturer);
lwm2m_device_set_model_number(deviceInstance, modelNumber);
lwm2m_device_set_serial_number(deviceInstance, serialNumber);
lwm2m_device_set_firmware_version(deviceInstance, firmwareVersion);
lwm2m_device_set_power_source(deviceInstance, powerSource);
lwm2m_device_set_device_id(deviceInstance, deviceId);
// Create sensor object
lwm2m_object_t* tempSensorObj = lwm2m_object_create();
tempSensorObj->objID = TEMP_OBJECT_ID;
tempSensorObj->readFunc = objectCallback;
tempSensorObj->writeFunc = objectCallback;
lwm2m_object_instance_t* tempSensorInstance = lwm2m_object_instance_create(0, tempSensorObj);
lwm2m_object_instance_add(tempSensorObj, tempSensorInstance);
// Add object to context
lwm2m_add_object(lwm2mH, deviceObj);
lwm2m_add_object(lwm2mH, tempSensorObj);
// main loop
while (1)
{
lwm2m_step(lwm2mH, 1000);
}
// post-processing
lwm2m_close(lwm2mH);
return 0;
}
The above C code implements a temperature sensor device using Wakaama. getTemperature function randomly generates a temperature value and setTemperature function sets the resource value of the sensor object, objectCallback function is the callback function for the resource operation of the object.
When this code is built and executed, a temperature sensor device is provided via the CoAP protocol. Other WoT clients and services use CoAP to access the device and retrieve temperature values.
Reference Information and Reference Books
For information on WoT, see “About WoT (Web of Things) Technology. For information on IoT in general, see “Sensor Data & IOT Technologies“; for information on stream data processing, see “Machine Learning and System Architecture for Data Streams.
For reference books, see
“Managing the Web of Things: Linking the Real World to the Web“
“Building the Web of Things: With examples in Node.js and Raspberry Pi“
コメント