Advanced
30 min

Achieve a smooth and dependable connection to the Click Cloud with ESP-WROOM-02 and STM32L073RZ

Gateway to Click Cloud: Where ideas take shape!

Go to Cloud (G2C) Click with Nucleo-64 with STM32L073RZ MCU

Published Feb 26, 2024

Click board™

Go to Cloud (G2C) Click

Dev. board

Nucleo-64 with STM32L073RZ MCU

Compiler

NECTO Studio

MCU

STM32L073RZ

Experience innovation at its finest with our gateway solution, connecting you securely to Click Cloud, the ideal playground for turning your ideas into reality.

A

A

Hardware Overview

How does it work?

Go to Cloud (G2C) Click is a Click board™ which allows connection to the feature-rich Click Cloud platform, over the WiFi network. Go to Cloud (G2C) click is envisioned so that users can easily add cloud connectivity and develop their own cloud-based applications, using only a set of simple AT commands, without having to delve into the complexity of web, hardware, and communications related development. Thanks to this simplified approach, everyone can benefit using the Click Cloud solution with Go to Cloud (G2C) click, since this Click board™ has all the necessary protocol and communication settings already implemented within its firmware. This saves a lot of time that would be otherwise wasted on the firmware development, and to adapting it to work with some third-party solution. Not to mention that such an effort would also require embedded and web programming proficiency, along with several other engineering skills. G2C click, on the other hand, works in unity with Click Cloud solution, right out of the box. Go to Cloud (G2C)

click performs several tasks on its side, which are required to connect to the Click Cloud platform. To establish the connection, an access to a WiFi network with Internet connectivity is required. For a reliable WiFi network connection, the Click board™ utilizes the ESP WROOM-02 WiFi module, a well-established integrated WiFi solution. The Click board™ uses a powerful MCU to manage the connection parameters, initialize the ESP-WROOM-02 WiFi module, and establish the connection with the Click Cloud platform. This allows to set up the connection in just a few simple steps, issuing a set of short AT commands, such as the SSID, password, device_ID, and so on. The complete documentation with in-depth explanation of each AT command and its response can be found in the AT Command Manual. Besides the AT commands that are used to set up basic connection parameters, there are also AT commands that allow storing of the connection parameters, including the connection password, network SSID, device_ID, and

other relevant connection data. These parameters can be stored in the non-volatile memory of the Go to Cloud (G2C) click. It is possible to restore them by a single macro command, resulting in a very simplified connection procedure. The functionality of the Go to Cloud (G2C) click will be constantly improved in the future. Therefore, Go to Cloud (G2C) click supports an upgrade of its firmware over the onboard USB connector. The firmware update process is very simple, using the familiar "HID Bootloader" software tool from MikroElektronika. Go to Cloud (G2C) click is equipped with four LED indicators. They are used to indicate the presence of a power supply, the WiFi network connection, the USB connection, and the connection with the Click Cloud solution. These LEDs provide visual feedback about the status of the Go to Cloud (G2C) click. This Click board™ requires both 3.3V and 5V power rails for proper operation.

Go to Cloud (G2C) Click hardware overview image

Features overview

Development board

Nucleo-64 with STM32L073RZ MCU offers a cost-effective and adaptable platform for developers to explore new ideas and prototype their designs. This board harnesses the versatility of the STM32 microcontroller, enabling users to select the optimal balance of performance and power consumption for their projects. It accommodates the STM32 microcontroller in the LQFP64 package and includes essential components such as a user LED, which doubles as an ARDUINO® signal, alongside user and reset push-buttons, and a 32.768kHz crystal oscillator for precise timing operations. Designed with expansion and flexibility in mind, the Nucleo-64 board features an ARDUINO® Uno V3 expansion connector and ST morpho extension pin

headers, granting complete access to the STM32's I/Os for comprehensive project integration. Power supply options are adaptable, supporting ST-LINK USB VBUS or external power sources, ensuring adaptability in various development environments. The board also has an on-board ST-LINK debugger/programmer with USB re-enumeration capability, simplifying the programming and debugging process. Moreover, the board is designed to simplify advanced development with its external SMPS for efficient Vcore logic supply, support for USB Device full speed or USB SNK/UFP full speed, and built-in cryptographic features, enhancing both the power efficiency and security of projects. Additional connectivity is

provided through dedicated connectors for external SMPS experimentation, a USB connector for the ST-LINK, and a MIPI® debug connector, expanding the possibilities for hardware interfacing and experimentation. Developers will find extensive support through comprehensive free software libraries and examples, courtesy of the STM32Cube MCU Package. This, combined with compatibility with a wide array of Integrated Development Environments (IDEs), including IAR Embedded Workbench®, MDK-ARM, and STM32CubeIDE, ensures a smooth and efficient development experience, allowing users to fully leverage the capabilities of the Nucleo-64 board in their projects.

Nucleo 64 with STM32L073RZ MCU double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

ARM Cortex-M0

MCU Memory (KB)

192

Silicon Vendor

STMicroelectronics

Pin count

64

RAM (Bytes)

20480

You complete me!

Accessories

Click Shield for Nucleo-64 comes equipped with two proprietary mikroBUS™ sockets, allowing all the Click board™ devices to be interfaced with the STM32 Nucleo-64 board with no effort. This way, Mikroe allows its users to add any functionality from our ever-growing range of Click boards™, such as WiFi, GSM, GPS, Bluetooth, ZigBee, environmental sensors, LEDs, speech recognition, motor control, movement sensors, and many more. More than 1537 Click boards™, which can be stacked and integrated, are at your disposal. The STM32 Nucleo-64 boards are based on the microcontrollers in 64-pin packages, a 32-bit MCU with an ARM Cortex M4 processor operating at 84MHz, 512Kb Flash, and 96KB SRAM, divided into two regions where the top section represents the ST-Link/V2 debugger and programmer while the bottom section of the board is an actual development board. These boards are controlled and powered conveniently through a USB connection to program and efficiently debug the Nucleo-64 board out of the box, with an additional USB cable connected to the USB mini port on the board. Most of the STM32 microcontroller pins are brought to the IO pins on the left and right edge of the board, which are then connected to two existing mikroBUS™ sockets. This Click Shield also has several switches that perform functions such as selecting the logic levels of analog signals on mikroBUS™ sockets and selecting logic voltage levels of the mikroBUS™ sockets themselves. Besides, the user is offered the possibility of using any Click board™ with the help of existing bidirectional level-shifting voltage translators, regardless of whether the Click board™ operates at a 3.3V or 5V logic voltage level. Once you connect the STM32 Nucleo-64 board with our Click Shield for Nucleo-64, you can access hundreds of Click boards™, working with 3.3V or 5V logic voltage levels.

Click Shield for Nucleo-64 accessories 1 image

Used MCU Pins

mikroBUS™ mapper

General-Purpose I/O
PC0
AN
Reset
PC12
RST
UART CTS
PB12
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
General-Purpose I/O
PC8
PWM
UART RTS
PC14
INT
UART TX
PA2
TX
UART RX
PA3
RX
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

Go to Cloud (G2C) Click Schematic schematic

Step by step

Project assembly

Click Shield for Nucleo-64 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Nucleo-64 with STM32L073RZ MCU as your development board.

Click Shield for Nucleo-64 front image hardware assembly
Nucleo 64 with STM32F401RE MCU front image hardware assembly
EEPROM 13 Click front image hardware assembly
Prog-cut hardware assembly
Nucleo-64 with STM32XXX MCU MB 1 Mini B Conn - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
Clicker 4 for STM32F4 HA MCU Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

Application Output

1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support

Library Description

This library contains API for Go to Cloud (G2C) Click driver.

Key functions:

  • g2c_reset_device - This function resets the device by toggling the RST pin.

  • g2c_set_net_creds - This function sets the WiFi network credentials.

  • g2c_set_broker_creds - This function sets the broker credentials (device key and password).

Open Source

Code example

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.

/*!
 * @file main.c
 * @brief G2C Click Example.
 *
 * # Description
 * This example shows the device capability of connecting to the cloud and
 * updating the sensor data on the cloud and receiving data from actuators.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver, restarts the device, and after that tests
 * the communication by sending "AT" command.
 *
 * ## Application Task
 * Application task is split in few stages:
 *  - G2C_CONNECT_TO_NETWORK:
 * Sends commands to configure device to connect to the specified network.
 *
 *  - G2C_CONNECT_TO_CLOUD:
 * Sends commands to configure device to connect to the specified device on the cloud.
 *
 *  - G2C_EXAMPLE:
 * This function executes example which updates sensor data on the cloud and displays
 * all data received from the module (ex. the actuator switch state change received
 * from the cloud).
 *
 * ## Additional Function
 * - static void g2c_clear_app_buf ( void )
 * - static err_t g2c_process ( void )
 * - static void g2c_error_check( err_t error_flag )
 * - static void g2c_log_app_buf ( void )
 * - static err_t g2c_rsp_check ( uint8_t *rsp )
 * - static err_t g2c_connect_to_network( void )
 * - static err_t g2c_connect_to_cloud( void )
 * - static err_t g2c_example( void )
 *
 * @note
 * In order for the example to work, user needs to set the WiFi credentials and the cloud device parameters.
 * Enter valid values for the following macros: 
 * WIFI_SSID, WIFI_PASS, DEVICE_KEY, DEVICE_PASSWORD, DEVICE_SENSOR_REF.
 * Example:
 * WIFI_SSID            "MikroE Public"
 * WIFI_PASS            "mikroe.guest"
 * DEVICE_KEY           "xxxxxxxxxxxxxxxx"
 * DEVICE_PASSWORD      "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
 * DEVICE_SENSOR_REF    "TEMP_SEN_R"
 * 
 * DEVICE_KEY and DEVICE_PASSWORD strings should match the device credentials which
 * were generated during the Click Cloud device creation step.
 * DEVICE_SENSOR_REF is expected to be a reference to a temperature sensor with a data
 * range from -20 to +80 degrees Celsius.
 * For more information about the registration on the Click Cloud and creating the device
 * refer to the following user guide:
 * https://download.mikroe.com/documents/click-cloud/guide-to-click-cloud.pdf
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "g2c.h"
#include "conversions.h"

// Network config parameters
#define WIFI_SSID                           "MikroE Public"  // Set valid WiFi SSID
#define WIFI_PASS                           "mikroe.guest"   // Set valid WiFi Password

// Cloud device config parameters
#define DEVICE_KEY                          ""  // Cloud device key
#define DEVICE_PASSWORD                     ""  // Cloud device password
#define DEVICE_SENSOR_REF                   ""  // Cloud device sensor reference

// Application buffer size
#define APP_BUFFER_SIZE                     300
#define PROCESS_BUFFER_SIZE                 300

/**
 * @brief Example states.
 * @details Predefined enum values for application example state.
 */
typedef enum
{
    G2C_CONNECT_TO_NETWORK = 1,
    G2C_CONNECT_TO_CLOUD,
    G2C_EXAMPLE

} g2c_example_state_t;

static g2c_t g2c;
static log_t logger;

/**
 * @brief Application example variables.
 * @details Variables used in application example.
 */
static uint8_t app_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
static int32_t app_buf_len = 0;
static err_t error_flag;
static g2c_example_state_t example_state;

/**
 * @brief G2C clearing application buffer.
 * @details This function clears memory of application buffer and reset its length.
 * @note None.
 */
static void g2c_clear_app_buf ( void );

/**
 * @brief G2C data reading function.
 * @details This function reads data from device and concatenates data to application buffer. 
 * @return @li @c  0 - Read some data.
 *         @li @c -1 - Nothing is read.
 * See #err_t definition for detailed explanation.
 * @note None.
 */
static err_t g2c_process ( void );

/**
 * @brief Check for errors.
 * @details This function checks for different types of
 * errors and logs them on UART or logs the response if no errors occured.
 * @param[in] error_flag  Error flag to check.
 */
static void g2c_error_check ( err_t error_flag );

/**
 * @brief Logs application buffer.
 * @details This function logs data from application buffer.
 */
static void g2c_log_app_buf ( void );

/**
 * @brief Response check.
 * @details This function checks for response and returns the status of response.
 * @param[in] rsp  Expected response.
 * @return @li @c  0 - OK response.
 *         @li @c -2 - Timeout error.
 *         @li @c -3 - Command error.
 *         @li @c -4 - Unknown error.
 * See #err_t definition for detailed explanation.
 */
static err_t g2c_rsp_check ( uint8_t *rsp );

/**
 * @brief Configure device to connect to the network.
 * @details Sends commands to configure device to connect to the specified network.
 * @return @li @c  0 - OK response.
 *         @li @c -2 - Timeout error.
 *         @li @c -3 - Command error.
 *         @li @c -4 - Unknown error.
 * See #err_t definition for detailed explanation.
 */
static err_t g2c_connect_to_network ( void );

/**
 * @brief Configure device to connect to the cloud.
 * @details Sends commands to configure device to connect to the specified device on the cloud.
 * @return @li @c  0 - OK response.
 *         @li @c -2 - Timeout error.
 *         @li @c -3 - Command error.
 *         @li @c -4 - Unknown error.
 * See #err_t definition for detailed explanation.
 */
static err_t g2c_connect_to_cloud ( void );

/**
 * @brief Execute example.
 * @details This function executes example which updates sensor data on the cloud and displays
 * all data received from the module (ex. the actuator state change received from the cloud).
 * @return @li @c  0 - OK response.
 *         @li @c -2 - Timeout error.
 *         @li @c -3 - Command error.
 *         @li @c -4 - Unknown error.
 * See #err_t definition for detailed explanation.
 */
static err_t g2c_example ( void );

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    g2c_cfg_t g2c_cfg;  /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.
    g2c_cfg_setup( &g2c_cfg );
    G2C_MAP_MIKROBUS( g2c_cfg, MIKROBUS_1 );
    if ( UART_ERROR == g2c_init( &g2c, &g2c_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    // Clear RX buffer
    g2c_process( );   
    g2c_clear_app_buf( );
    Delay_ms ( 100 );
    
    // Reset device
    g2c_reset_device ( &g2c );
    
    // Check communication
    log_printf( &logger, "Test communication\r\n" );
    Delay_ms ( 100 );
    g2c_send_cmd( &g2c, G2C_CMD_AT );
    error_flag = g2c_rsp_check( G2C_RSP_OK );
    g2c_error_check( error_flag );
    
    // Enable command echo
    log_printf( &logger, "Enable echo\r\n" );
    Delay_ms ( 100 );
    g2c_send_cmd( &g2c, G2C_CMD_ATE1 );
    error_flag = g2c_rsp_check( G2C_RSP_OK );
    g2c_error_check( error_flag );
    
    log_info( &logger, " Application Task " );
    example_state = G2C_CONNECT_TO_NETWORK;
}

void application_task ( void ) 
{
    switch ( example_state )
    {
        case G2C_CONNECT_TO_NETWORK:
        {
            if ( G2C_OK == g2c_connect_to_network( ) )
            {
                example_state = G2C_CONNECT_TO_CLOUD;
            }
            break;
        }
        case G2C_CONNECT_TO_CLOUD:
        {
            if ( G2C_OK == g2c_connect_to_cloud( ) )
            {
                example_state = G2C_EXAMPLE;
            }
            break;
        }
        case G2C_EXAMPLE:
        {
            g2c_example( );
            break;
        }
        default:
        {
            log_error( &logger, " Example state." );
            break;
        }
    }
}

int main ( void ) 
{
    /* Do not remove this line or clock might not be set correctly. */
    #ifdef PREINIT_SUPPORTED
    preinit();
    #endif
    
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}

static void g2c_clear_app_buf ( void ) 
{
    memset( app_buf, 0, app_buf_len );
    app_buf_len = 0;
}

static err_t g2c_process ( void ) 
{
    uint8_t rx_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
    int32_t rx_size = 0;
    rx_size = g2c_generic_read( &g2c, rx_buf, PROCESS_BUFFER_SIZE );
    if ( rx_size > 0 ) 
    {
        int32_t buf_cnt = app_buf_len;
        if ( ( ( app_buf_len + rx_size ) > PROCESS_BUFFER_SIZE ) && ( app_buf_len > 0 ) ) 
        {
            buf_cnt = PROCESS_BUFFER_SIZE - ( ( app_buf_len + rx_size ) - PROCESS_BUFFER_SIZE );
            memmove ( app_buf, &app_buf[ PROCESS_BUFFER_SIZE - buf_cnt ], buf_cnt );
        }
        for ( int32_t rx_cnt = 0; rx_cnt < rx_size; rx_cnt++ ) 
        {
            if ( rx_buf[ rx_cnt ] ) 
            {
                app_buf[ buf_cnt++ ] = rx_buf[ rx_cnt ];
                if ( app_buf_len < PROCESS_BUFFER_SIZE )
                {
                    app_buf_len++;
                }
            }
        }
        return G2C_OK;
    }
    return G2C_ERROR;
}

static err_t g2c_rsp_check ( uint8_t *rsp )
{
    uint32_t timeout_cnt = 0;
    uint32_t timeout = 120000;
    g2c_clear_app_buf( );
    g2c_process( );
    while ( ( 0 == strstr( app_buf, rsp ) ) &&
            ( 0 == strstr( app_buf, G2C_RSP_ERROR ) ) )
    {
        g2c_process( );
        if ( timeout_cnt++ > timeout )
        {
            g2c_clear_app_buf( );
            return G2C_ERROR_TIMEOUT;
        }
        Delay_ms ( 1 );
    }
    Delay_ms ( 100 );
    g2c_process( );
    if ( strstr( app_buf, rsp ) )
    {
        return G2C_OK;
    }
    else if ( strstr( app_buf, G2C_RSP_ERROR ) )
    {
        return G2C_ERROR_CMD;
    }
    else
    {
        return G2C_ERROR_UNKNOWN;
    }
}

static void g2c_error_check ( err_t error_flag )
{
    switch ( error_flag )
    {
        case G2C_OK:
        {
            g2c_log_app_buf( );
            break;
        }
        case G2C_ERROR:
        {
            log_error( &logger, " Overflow!" );
            break;
        }
        case G2C_ERROR_TIMEOUT:
        {
            log_error( &logger, " Timeout!" );
            break;
        }
        case G2C_ERROR_CMD:
        {
            log_error( &logger, " CMD!" );
            break;
        }
        case G2C_ERROR_UNKNOWN:
        default:
        {
            log_error( &logger, " Unknown!" );
            break;
        }
    }
    Delay_ms ( 500 );
}

static void g2c_log_app_buf ( void )
{
    for ( int32_t buf_cnt = 0; buf_cnt < app_buf_len; buf_cnt++ )
    {
        log_printf( &logger, "%c", app_buf[ buf_cnt ] );
    }
}

static err_t g2c_connect_to_network ( void )
{
    err_t func_error = G2C_OK;
    Delay_ms ( 500 );
    
    // Enable connector module
    #define ENABLE_CONNECTOR_MODULE "1"
    g2c_send_cmd_with_par( &g2c, G2C_CMD_CEN, ENABLE_CONNECTOR_MODULE );
    error_flag = g2c_rsp_check( G2C_RSP_OK );
    func_error |= error_flag;
    g2c_error_check( error_flag );
    
    // Enable DHCP
    #define ENABLE_DHCP "1"
    g2c_send_cmd_with_par( &g2c, G2C_CMD_NWP, ENABLE_DHCP );
    error_flag = g2c_rsp_check( G2C_RSP_OK );
    func_error |= error_flag;
    g2c_error_check( error_flag );
    
    // Set network credentials
    g2c_set_net_creds( &g2c, WIFI_SSID, WIFI_PASS );
    error_flag = g2c_rsp_check( G2C_RSP_OK );
    func_error |= error_flag;
    g2c_error_check( error_flag );
    
    // Connect to network
    #define CONNECT_TO_NETWORK "1"
    g2c_send_cmd_with_par( &g2c, G2C_CMD_NWC, CONNECT_TO_NETWORK );
    error_flag = g2c_rsp_check( G2C_RSP_OK );
    func_error |= error_flag;
    g2c_error_check( error_flag );
    
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    return func_error;
}

static err_t g2c_connect_to_cloud ( void )
{
    err_t func_error = G2C_OK;
    Delay_ms ( 500 );
    
    g2c_set_broker_creds( &g2c, DEVICE_KEY, DEVICE_PASSWORD );
    error_flag = g2c_rsp_check( G2C_RSP_OK );
    func_error |= error_flag;
    g2c_error_check( error_flag );
    
    // Connect to broker
    #define CONNECT_TO_BROKER "1"
    g2c_send_cmd_with_par( &g2c, G2C_CMD_BRC, CONNECT_TO_BROKER );
    error_flag = g2c_rsp_check( G2C_RSP_OK );
    func_error |= error_flag;
    g2c_error_check( error_flag );
    
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    return func_error;
}

static err_t g2c_example ( void )
{
    err_t func_error = G2C_OK;
    
    #define ACTUATOR_WAIT_TIME_MS   10000 // This setting also affects the sensor data update rate
    #define TEMPERATURE_MIN        -20
    #define TEMPERATURE_MAX         80
    #define TEMPERATURE_STEP        5
    static int8_t temperature = TEMPERATURE_MIN;
    uint8_t cmd_buf[ 100 ] = { 0 };
    uint8_t temperature_buf[ 10 ] = { 0 };
    uint8_t cmd_separator[ 2 ] = { ',', 0 };
    uint8_t quote_mark[ 2 ] = { '\"', 0 };
    
    int8_to_str( temperature, temperature_buf );
    l_trim( temperature_buf );
    r_trim( temperature_buf );

    // Store data to the internal memory.
    strcpy( cmd_buf, quote_mark );
    strcat( cmd_buf, DEVICE_SENSOR_REF );
    strcat( cmd_buf, quote_mark );
    strcat( cmd_buf, cmd_separator );
    strcat( cmd_buf, quote_mark );
    strcat( cmd_buf, temperature_buf );
    strcat( cmd_buf, quote_mark );
    g2c_send_cmd_with_par( &g2c, G2C_CMD_DSET, cmd_buf );
    error_flag = g2c_rsp_check( G2C_RSP_OK );
    func_error |= error_flag;
    g2c_error_check( error_flag );
    Delay_ms ( 500 );
    
    // Publish data to the cloud
    g2c_send_cmd( &g2c, G2C_CMD_PUB );
    error_flag = g2c_rsp_check( G2C_RSP_OK );
    func_error |= error_flag;
    g2c_error_check( error_flag );
    g2c_clear_app_buf( );
    
    temperature += TEMPERATURE_STEP;
    if ( temperature > TEMPERATURE_MAX )
    {
        temperature = TEMPERATURE_MIN;
    }
    
    // Check for the actuator response
    for ( uint32_t act_wait_cnt = 0; act_wait_cnt < ACTUATOR_WAIT_TIME_MS; act_wait_cnt++ )
    {
        g2c_process ( );
        if ( app_buf_len )
        {
            g2c_log_app_buf ( );
            g2c_clear_app_buf ( );
        }
        Delay_1ms ( );
    }
    
    return func_error;
}

// ------------------------------------------------------------------------ END

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.