Accelerate sensor-to-cloud connectivity with a quick-start platform

Sensors are the eyes and ears of the Internet of Things (IoT), providing the information needed for analytics and big data applications to help users make informed decisions. Although there are many ways to connect multiple wireless sensors to perform this analysis, connecting to the cloud is still challenging. This is especially true in terms of space, power and cost, as well as the ability to configure and manage all sensors while ensuring strong security.

To shorten the development cycle, some development kits combine sensor node development and cloud connectivity. Developers don't need to make architectural decisions about how to integrate cloud services into the end-user experience (including what the system will do and which actions trigger specific features of the device), and these "out-of-the-box" suites are relatively fast. Start and run a design with sensor functionality.

This article introduces STMicroelectronics' STM32 Nucleo development board and X-NUCLEO expansion board, which integrates the components needed to implement the specialized features of the selected application. The Flash Nucleo Sensor Node will also show how to use the FP-CLD-BLUEMIX1 extension package to signal the Nucleo sensor node and connect the Nucleo board to the IBM Watson IoT cloud platform in a few simple steps. 1

Nucleo platform and software

The STM32 Nucleo development board provides engineers with a flexible way to experiment with new concepts and prototypes using the STMicroelectronics STM32 microcontroller. This development board has an expansion header that is common to all Nucleo boards, making it easy to add expansion modules.

The Nucleo development board integrates the ST-LINK / V2-1 debugger/programmer, thus supporting Arduino as part of its open ecosystem approach and does not require a separate probe. The development board comes with the STM32 software library and various package software examples.

Including Arduino, there are many different shields available. Development boards using STMicroelectronics' Morpho hubs are available for shield expansion for all application types, including RF, industrial and home automation shield applications. In addition, shields for Bluetooth LE, Wi-Fi and audiovisual applications are available.

Library support covers standard libraries for STM32 and support for ARM® free online mbed. ARM® mbed is an IoT device platform that provides an operating system, tools, and developer ecosystem that enables designers to evaluate and get started with the Nucleo board.

To help form the connection from the sensor to the cloud, STMicroelectronics also offers the FP-CLD-BLUEMIX1, an IoT node extension package for STM32Cube that runs on the STM32 microcontroller, available on the STMicroelectronics website. 2 The main goal of the STM32Cube is to make the process of developing applications easier. To this end, the extension package includes the STM32CubeMX and STM32Cube embedded software libraries (Figure 1).

Accelerate sensor-to-cloud connectivity with a quick-start platform

Figure 1: FP-CLD-BLUEMIX1 provides complete middleware to build Wi-Fi-based applications and link the STM32 Nucleo development board to cloud-based services. (Source: STMicroelectronics)

STM32CubeMX generates the initialization C code for the STM32 MCU from the graphical user interface. The STM32MX also generates an IDE-ready project that provides a power calculator and allows the STM32Cube embedded software library to be imported directly from st.com.

Each STM32 product line has an STM32Cube embedded software package. The embedded software library includes hardware abstraction layer (HAL) and low-level (LL) application programming interfaces (APIs) for STM32 peripherals, as well as a set of middleware (RTOS, USB, TCP/IP) based on STMicroelectronics development or open source components. , graphics, etc.). The initialization code, middleware components, HAL and LL APIs are compatible with all STM32 compilers.

For its part, the FP-CLD-BLUEMIX1 software package extends the STM32Cube by providing a board support package (BSP) for Wi-Fi, NFC and sensor expansion boards. Its role is to connect to the IBM Bluemix cloud to transmit sensor data and receive commands from cloud applications. This package essentially helps to quickly launch end-to-end IoT development so you can focus on differentiated designs.

Connecting sensor

A software interface is provided for accessing the Nucleo board's temperature and humidity sensors (HTS221), pressure sensors (LPS25HB), motion sensors (LIS3MDL and LSM6DS0), and writing and reading RFID/NFC tags. The X-NUCLEO-IKS01A1 contains all of these sensors (Figure 2).

Accelerate sensor-to-cloud connectivity with a quick-start platform

Figure 2: The X-NUCLEO-IKS01A1 is a motion MEMS and environmental sensor evaluation board system. (Source: STMicroelectronics)

The IKS01A1 is compatible with the Arduino UNO R3 connector layout and is designed around STMicroelectronics' LSM6DS0 3-axis accelerometer + 3-axis gyroscope, LIS3MDL 3-axis magnetometer, HTS221 humidity and temperature sensor, and LPS25HB pressure sensor.

The IKS01A1 also includes a middleware package that implements the MQ Telemetry Transport (MQTT) protocol to facilitate interaction between the STM32 Nucleo board and the IBM Bluemix Cloud service. The software includes examples for viewing sensor data and controlling devices with IBM Bluemix.

In addition to the middleware stack, a sample application for testing the connection to the IBM Watson IoT platform is provided. It is used to prototype a end-to-end IoT application. Once the STM32 Nucleo microsystem is registered with the IBM Bluemix cloud service, the microsystem can be used to transmit real-time sensor data. With NFC Dynamic Labels, users can also automatically open trial web pages provided by IBM and visualize data generated by all sensors on the STM32 Nucleo board.

To connect the STM32 Nucleo microsystem to the IBM Bluemix cloud, STMicroelectronics ported the open source implementation of the MQTT application-level network protocol. MQTT is a machine-to-machine (M2M) IoT connection protocol for connecting remote devices with a small amount of code, especially if network bandwidth is limited. The messaging protocol is lightweight, thus saving power, making it particularly suitable for sensor data telemetry and implementation in embedded systems. In FP-CLD-BLUEMIX1, MQTT is integrated as a middleware library into the STM32 package.

A sample application that uses the X-NUCLEO-IKS01A1, X-NUCLEO-IDW01M1, and XNUCLEO-NFC01A1 expansion boards with the NUCLEO-F401RE board is provided in the Feature Pack. This application reads data values ​​from temperature, humidity, pressure, accelerometer, magnetometer, and gyroscope sensors and transmits them to IBM Bluemix via Wi-Fi.

This app is configured by default to run in Quick Launch mode for data visualization purposes only. But it's easy to modify to register and control devices in IBM Bluemix (requires an IBM Bluemix account).

Sign up for an IBM Bluemix account

Once the STM32 Nucleo microsystem is registered with the IBM Bluemix cloud service, the microsystem can be used to prototype an end-to-end IoT application and begin transmitting real-time sensor data.

Sign in or create a Bluemix account (see the full instructions in "Reference 1") to get started. Several properties and parameters must be provided when registering, as follows:

OrganizaTIon ID (ie, "1w8a05").

Device type (ie: "stm32_nucleo").

UM2007 FP-CLD-BLUEMIX1 software descripTIon

DocID028875 Rev 2 13/23

AuthenTIcaTIon Method (only "use-token-auth" supported).

Authentication token (ie, "uUURNRbeQQaX+Fvi&8").

Copy the device properties to the Config_MQTT_IBM function located in the source code file IBM_Bluemix_Config.c. This file is located in the Projects/Multi/Applications/MQTT_IBM/Src folder of the FP-CLD-BLUEMIX1 package.

Then, the ibm_mode variable needs to be set to "REGISTERED" as shown below (code list):

Void Config_MQTT_IBM (MQTT_vars * mqtt_ibm_setup , uint8_t *macadd):

/* Default Configuration for QUICKSTART. REGISTERED mode requires account on Bluemix */

Mqtt_ibm_setup-》ibm_mode = REGISTERED

Then, you need to copy the device properties provided in IBM Bluemix to the Config_MQTT_IBM function in the source code file named IBM_Bluemix_Config.c. This file is located in the Projects/Multi/Applications/MQTT_IBM/Src folder.

The program execution will show up in the middle:

/* REGISTERED DEVICE */

/* Need to be customized */

The fourth to eighth lines will be displayed as follows:

Strcpy ((char*)mqtt_ibm_setup-"username,"use-token-auth); //customize

Strcpy ((char*)mqtt_ibm_setup-"password," uUURNRbeQQax+Fvit&8");

Strcpy ((char*)mqtt_ibm_setup-"hostname,"1w8a05.messaging.internetofthings.ibmcloud.com);

Strcpy ((char*)mqtt_ibm_setup-"device_type, "stm32_nucleo");

Strcpy ((char*)mqtt_ibm_setup-"org_id, "1w8a05");

Code list: IBM device registration and attribute insertion requirements. Upon registration, the STM32 Nucleo Microsystem will be able to send and receive information to and from the IBM Watson IoT application. (Source: STMicroelectronics)

The FP-CLD-BLUEMIX1 package sample application includes a default configuration to view sensor data on IBM Quickstart Page 3 based on the device's MAC address. The URL page is also written to the NFC tag. Once the STM32 Nucleo board is connected to a Wi-Fi access point, it automatically interacts with IBM Bluemix and begins transmitting sensor data. The MAC address of the Wi-Fi expansion board and the IBM Quickstart URL are printed in the serial terminal interface.

To view real-time sensor data, you can copy and paste the Quickstart URL into your web browser. When using an NFC-enabled mobile device, it is easier to open a web page by bringing the device closer to the NFC tag. In order to visually indicate the connection status, once Nucleo is connected to IBM Bluemix, the green LED2 on the STM32 Nucleo board will become "ON". It flashes each time a sensor data sample is transmitted.

The FP-CLD-BLUEMIX1 package itself has an STM32 layer that includes a simple set of generic multi-instance APIs that interact with upper-level applications, libraries, and stacks. These generic and extended APIs are based on a common framework. This allows any layer they build (such as the middleware layer) to perform its functions without having specific hardware information for a given MCU. This structure improves the reusability of library code and ensures easy portability to other devices.

The compiled HTML file in the "Documentation" folder of the package provides the user with detailed technical information describing the API functions and parameters.

The main APIs used by the IBM sample are:

· void Config_MQTT_IBM(MQTT_vars * mqtt_ibm_setup , uint8_t * macadd); Configure the MQTT parameters for the IBM cloud connection, specifying the MAC address of the Wi-Fi expansion board.

Int spwf_socket_create(Network* net, uint8_t * hostname, uint32_t port_number, uint8_t * protocol); Open a socket specifying the host name, port number, and protocol type (TCP or TLS). Returns the success or failure result and the socket ID in the network structure.

· void MQTTClient(Client* c, Network* network, unsigned intcommand_timeout_ms, unsigned char* buf, size_tbuf_size, unsigned char* readbuf, size_treadbuf_size); configure the client structure and specify input parameters.

Int MQTTConnect(Client* c, MQTTPacket_connectData* options); connects to the IBM MQTT broker, specifying parameters in the client and MQTTPacket_connect data structures. Returns the success or failure result.

Int MQTTSubscribe(Client* c, const char* topicFilter, enumQoSqos, messageHandlermessageHandler); subscribes to the MQTT topic defined in the data structure client. Returns the success or failure result.

to sum up

The growing need to analyze data and the need to simplify access to data for organizations highlights the importance of wireless sensors and their associated MCUs to connect to the cloud.

This article explores a specific implementation option and how the recently released hardware development kit and related software make it easy to connect sensors to the cloud. Users can not only monitor the current state and specific parameters of the object, but also use cloud services for predictive analysis.

Reference material

1. Explore the IBM Watson Internet of Things

2. FP-CLD-BLUEMIX1 STM32 ODE Feature Pack for IoT Nodes

3. IBM Watson IoT Quick Start

Contributor: Digi-Key's North American Editors

LC Optical Fiber Adapter

Lc Optical Fiber Adapter,Lc Quad Adapter,Lc Duplex Figure Sc Adapter,Lc Duplex High-High Type Adapter

ShenZhen JunJin Technology Co.,Ltd , https://www.jjtcl.com