Advanced
30 min

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

Gateway to Click Cloud: Where ideas take shape!

Go to Cloud (G2C) Click with Fusion for Tiva v8

Published Nov 09, 2023

Click board™

Go to Cloud (G2C) Click

Dev. board

Fusion for Tiva v8

Compiler

NECTO Studio

MCU

TM4C129ENCPDT

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

Fusion for TIVA v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports a wide range of microcontrollers, such as different 32-bit ARM® Cortex®-M based MCUs from Texas Instruments, regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer over a WiFi network. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. Thanks to innovative manufacturing technology, Fusion for TIVA v8 provides a fluid and immersive working experience, allowing access

anywhere and under any circumstances at any time. Each part of the Fusion for TIVA v8 development board contains the components necessary for the most efficient operation of the same board. An advanced integrated CODEGRIP programmer/debugger module offers many valuable programming/debugging options, including support for JTAG, SWD, and SWO Trace (Single Wire Output)), and seamless integration with the Mikroe software environment. Besides, it also includes a clean and regulated power supply module for the development board. It can use a wide range of external power sources, including a battery, an external 12V power supply, and a power source via the USB Type-C (USB-C) connector.

Communication options such as USB-UART, USB HOST/DEVICE, CAN (on the MCU card, if supported), and Ethernet is also included. In addition, it also has the well-established mikroBUS™ standard, a standardized socket for the MCU card (SiBRAIN standard), and two display options for the TFT board line of products and character-based LCD. Fusion for TIVA v8 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

Fusion for Tiva v8 horizontal image

Microcontroller Overview

MCU Card / MCU

default

Type

8th Generation

Architecture

ARM Cortex-M4

MCU Memory (KB)

1024

Silicon Vendor

Texas Instruments

Pin count

128

RAM (Bytes)

262144

Used MCU Pins

mikroBUS™ mapper

General-Purpose I/O
PD0
AN
Reset
PK3
RST
UART CTS
PH0
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
General-Purpose I/O
PL4
PWM
UART RTS
PQ4
INT
UART TX
PK1
TX
UART RX
PK0
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

Fusion for PIC v8 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Fusion for Tiva v8 as your development board.

Fusion for PIC v8 front image hardware assembly
Buck 22 Click front image hardware assembly
SiBRAIN for PIC32MZ1024EFK144 front image hardware assembly
v8 SiBRAIN MB 1 - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
NECTO Compiler Selection Step Image hardware assembly
NECTO Output Selection Step Image hardware assembly
Necto image step 6 hardware assembly
Necto image step 7 hardware assembly
Necto image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto PreFlash Image 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 
 * \brief G2C Click example
 * 
 * # Description
 * This example reads and processes data from G2C clicks.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes driver and power module.
 * 
 * ## Application Task  
 * Reads the received data and parses it.
 * 
 * ## Additional Function
 * - g2c_process ( ) - The general process of collecting presponce 
 *                                   that sends a module.
 * 
 * ## Note
 * - WiFi credentials for Planet Debug utilization: username: MikroE Public
 *                                                  password: mikroe.guest
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

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

#define PROCESS_COUNTER 10
#define PROCESS_RX_BUFFER_SIZE 500
#define PROCESS_PARSER_BUFFER_SIZE 500

// ------------------------------------------------------------------ VARIABLES

static g2c_t g2c;
static log_t logger;

// AT commands
#define ATE               "ATE1"
#define AT                "AT"
#define AT_CEN            "AT+CEN=1"
#define AT_NWCR           "AT+NWCR"
#define AT_NWC            "AT+NWC=1"
#define AT_BRCR           "AT+BRCR"
#define AT_BRC            "AT+BRC=1"
#define AT_DSET           "AT+DSET"
#define AT_PUB            "AT+PUB"

// Sensor/Actuator reference
#define ACTUATOR_SW_REF   "G2C_TEST_AB"
#define ACTUATOR_STR_REF  "G2C_TEST_AS"
#define ACTUATOR_CNT_REF  "G2C_TEST_AC"
#define SENSOR_REF        "G2C_TEST_S"

// Operator settings
#define NETWORK_USERNAME  "network_username"
#define NETWORK_PASSWORD  "network_password"

// Broker(device) settings
#define DEVICE_KEY        "device_key"
#define DEVICE_PASSWORD   "device_password"

static char data_buf[ 20 ] = "12.2";
static char current_parser_buf[ PROCESS_PARSER_BUFFER_SIZE ];
static uint8_t send_data_cnt = 0; 

// ------------------------------------------------------- ADDITIONAL FUNCTIONS

static void g2c_process ( void )
{
    int32_t rsp_size;
    uint16_t rsp_cnt = 0;
    
    char uart_rx_buffer[ PROCESS_RX_BUFFER_SIZE ] = { 0 };
    uint8_t check_buf_cnt;
    uint8_t process_cnt = PROCESS_COUNTER;
    
    // Clear parser buffer
    memset( current_parser_buf, 0 , PROCESS_PARSER_BUFFER_SIZE ); 
    
    while( process_cnt != 0 )
    {
        rsp_size = g2c_generic_read( &g2c, &uart_rx_buffer, PROCESS_RX_BUFFER_SIZE );

        if ( rsp_size > 0 )
        {  
            // Validation of the received data
            for ( check_buf_cnt = 0; check_buf_cnt < rsp_size; check_buf_cnt++ )
            {
                if ( uart_rx_buffer[ check_buf_cnt ] == 0 ) 
                {
                    uart_rx_buffer[ check_buf_cnt ] = 13;
                }
            }
            log_printf( &logger, "%s", uart_rx_buffer );

            // Storages data in parser buffer
            rsp_cnt += rsp_size;
            if ( rsp_cnt < PROCESS_PARSER_BUFFER_SIZE )
            {
                strncat( current_parser_buf, uart_rx_buffer, rsp_size );
            }
            
            // Clear RX buffer
            memset( uart_rx_buffer, 0, PROCESS_RX_BUFFER_SIZE );
        } 
        else 
        {
            process_cnt--;
            
            // Process delay 
            Delay_100ms( );
        }
    }
}

static void actuator_demo( char *rsp )
{
    uint8_t sw_state;
    int16_t cnt_state;
    char str_data_buf[ 50 ];
    
    uint8_t err = G2C_PARSER_NO_ERROR;
    
    // Actuator switch example
    err = g2c_actuator_sw_parser( rsp, ACTUATOR_SW_REF, &sw_state );
    if ( err == G2C_PARSER_NO_ERROR )
    {
        log_printf( &logger, ">> ACTUATOR SW STATE: %d\r\n", sw_state );
    }

    // Actuator counter example
    err = g2c_actuator_cnt_parser(  rsp, ACTUATOR_CNT_REF, &cnt_state );
    if ( err == G2C_PARSER_NO_ERROR )
    {
        log_printf( &logger, ">> ACTUATOR CNT NUM: %d\r\n", cnt_state );
    }
    
    // Actuator string example
    err = g2c_actuator_str_parser(  rsp, ACTUATOR_STR_REF, str_data_buf );
    if ( err == G2C_PARSER_NO_ERROR )
    {
        log_printf( &logger, ">> ACTUATOR TEXT DATA: %s\r\n", str_data_buf );
    }
}
// ------------------------------------------------------ APPLICATION FUNCTIONS

void application_init ( void )
{
    log_cfg_t log_cfg;
    g2c_cfg_t cfg;

    /** 
     * 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( &cfg );
    G2C_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    g2c_init( &g2c, &cfg );

    // Power module.

    g2c_module_power( &g2c, true, 0 );
    g2c_reset( &g2c );
    
    // Send command.

    log_printf( &logger, ">> ATE \r\n" );
    g2c_send_command( &g2c, ATE );
    Delay_ms( 3000 );
    g2c_process( );

    log_printf( &logger, ">> AT \r\n" );
    g2c_send_command( &g2c, AT );
    Delay_ms( 3000 );
    g2c_process( );

    log_printf( &logger, ">> AT_CEN \r\n" );
    g2c_send_command( &g2c, AT_CEN );
    g2c_process( );

    log_printf( &logger, ">> NETWORK \r\n" );
    g2c_send_operator_cfg( &g2c, NETWORK_USERNAME, NETWORK_PASSWORD );
    g2c_process( );

    log_printf( &logger, ">> AT NWC \r\n" );
    g2c_send_command( &g2c, AT_NWC );
    g2c_process( );

    log_printf( &logger, ">> DEVICE \r\n" );
    g2c_send_broker_cfg( &g2c, DEVICE_KEY, DEVICE_PASSWORD );
    g2c_process( );

    log_printf( &logger, ">> AT BRC \r\n" );
    g2c_send_command( &g2c, AT_BRC ); 
    g2c_process( );

    Delay_ms( 3000 );
}

void application_task ( void )
{
    g2c_process( );
    actuator_demo( current_parser_buf );
    
    if ( send_data_cnt == 5 )
    {
       log_printf( &logger, ">> ACTUATOR REF \r\n" );  
       g2c_send_data_ref( &g2c, ACTUATOR_STR_REF, data_buf );
       g2c_process( );

       log_printf( &logger, ">> AT PUB \r\n" );
       g2c_send_command( &g2c, AT_PUB );
       g2c_process( );
       send_data_cnt = 0;
    }
    send_data_cnt++;
}

void main ( void )
{
    application_init( );

    for ( ; ; )
    {
        application_task( );
    }
}

// ------------------------------------------------------------------------ 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.