TOP Contributors

  1. MIKROE (2784 codes)
  2. Alcides Ramos (405 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (133 codes)
  5. Bugz Bensce (97 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (141334 times)
  2. FAT32 Library (74179 times)
  3. Network Ethernet Library (58760 times)
  4. USB Device Library (48850 times)
  5. Network WiFi Library (44559 times)
  6. FT800 Library (44145 times)
  7. GSM click (30881 times)
  8. mikroSDK (29722 times)
  9. PID Library (27368 times)
  10. microSD click (27291 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
mikroSDK Library

G2C Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.7

mikroSDK Library: 2.0.0.0

Category: GSM/LTE

Downloaded: 435 times

Not followed.

License: MIT license  

Go to Cloud (G2C) Click is a gateway Click board™ which provides a simple and reliable connection to the Click Cloud platform, a cloud-based rapid prototyping environment, hosted by MikroElektronika. Go to Cloud (G2C) Click offers an unprecedented simplicity for adding Click Cloud connectivity to any embedded application, by utilizing the simple UART interface: it can be configured and managed using a minimal set of well-documented AT commands.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "G2C Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "G2C Click" changes.

Do you want to report abuse regarding "G2C Click".

  • mikroSDK Library 1.0.0.0
  • Comments (0)

mikroSDK Library Blog


G2C Click

Go to Cloud (G2C) Click is a gateway Click board™ which provides a simple and reliable connection to the Click Cloud platform, a cloud-based rapid prototyping environment, hosted by MikroElektronika. Go to Cloud (G2C) Click offers an unprecedented simplicity for adding Click Cloud connectivity to any embedded application, by utilizing the simple UART interface: it can be configured and managed using a minimal set of well-documented AT commands.

g2c_click.png

Click Product page


Click library

  • Author : Stefan Filipovic
  • Date : May 2023.
  • Type : UART type

Software Support

We provide a library for the G2C Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

This library contains API for G2C Click driver.

Standard key functions :

  • g2c_cfg_setup Config Object Initialization function.

    void g2c_cfg_setup ( g2c_cfg_t *cfg );
  • g2c_init Initialization function.

    err_t g2c_init ( g2c_t *ctx, g2c_cfg_t *cfg );

Example key functions :

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

    void g2c_reset_device ( g2c_t *ctx );
  • g2c_set_net_creds This function sets the WiFi network credentials.

    void g2c_set_net_creds ( g2c_t *ctx, uint8_t *sim_apn, uint8_t *username, uint8_t *password );
  • g2c_set_broker_creds This function sets the broker credentials (device key and password).

    void g2c_set_broker_creds ( g2c_t *ctx, uint8_t *dev_key, uint8_t *password );

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.


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;
}

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).
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;
        }
    }
}

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.

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.G2C

Additional notes and informations

Depending on the development board you are using, you may need USB UART Click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.


ALSO FROM THIS AUTHOR

GNSS RTK 3 EA Click

0

GNSS RTK 3 Click is a compact add-on board that enhances the precision of position data derived from satellite-based positioning systems. This board features the LC29HEA, a dual-band, multi-castellation GNSS module from Quectel. This module supports the concurrent reception of all five global GNSS constellations: GPS, BDS, Galileo, GZSS, and GLONASS. It can receive and track many visible satellites in multi-bands, significantly mitigating the multipath effect in deep urban canyons and improving positioning accuracy.

[Learn More]

Temp-Hum 12 click

5

Temp-Hum 12 click is a smart environmental temperature and humidity sensor Click board, packed with features which allow easy and simple integration into any design that requires accurate and reliable humidity and temperature measurements.

[Learn More]

Joystick 3 Click

0

Joystick 3 Click is a compact add-on board that can fulfill your directional analog input needs. This board features 2765, a high-quality mini 2-axis analog output thumbstick from Adafruit Industries. This small joystick is a 'self-centering' analog-type with a black rocker cap similar to the PSP joysticks. It comprises two 10kΩ potentiometers, one for up/down and another for left/right direction. Knowing that this joystick represents an analog type, it connects with mikroBUS™ through the SPI interface through the MCP3204 12-bit A/D converter.

[Learn More]