Intermediate
20 min

Break free from geographical boundaries with UG95 and ATmega32

From the heart of Europe to the landscapes of Australia

3G-EA Click (for EU and Australia) with EasyAVR v7

Published Nov 01, 2023

Click board™

3G-EA Click (for EU and Australia)

Dev.Board

EasyAVR v7

Compiler

NECTO Studio

MCU

ATmega32

Experience the power of global communication through our dual-band cellular solution, qualified for European and Australian UMTS frequency bands. From Europe to Australia, we keep you connected no matter where your journey takes you.

A

A

Hardware Overview

How does it work?

3G-EA Click is based on the UG95-E, an ultra-small UMTS/HSPA module with high-speed wireless connectivity from Quectel. This module is the main component of the Click board™, consisting of several internal blocks or sections, such as an antenna switching section, RF transceiver section, memory, power management, and most importantly - the cellular baseband processor. This section contains the logic necessary for managing the other sections and provides the interface to the host MCU. The Micro SIM card holder on the back of the click board™ is used to install a microSIM card. This device cannot be used without a valid SIM card, which allows connection to the cellular network. Both 1.8V and 3V SIM card types are supported. The Quectel UG95 offers the PCM interface used for digital audio. The MAX9860, a 16-bit mono audio voice CODEC IC from Analog Devices, provides the 3G-EA Click with voice communication. The MAX9860 IC uses

the PCM and I2C interfaces to communicate with the Quectel UG95 module. This IC provides a clean and audible analog interface for connecting the headset, with one audio output channel and one microphone input channel. The headset can be connected via the onboard 3.5mm audio jack. 3G-EA Click is also equipped with a micro-USB connector. It allows the module to be powered and configured by a personal computer (PC). Quectel offers a software suite that can be used with the 3G-EA click board. 3G-EA Click uses a standard 2-Wire UART interface to communicate with the host MCU with commonly used UART RX and TX. UART interface supports baud rates of 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, and 921600bps, with the default setting to automatic baud rate detection, between 4800 and 115200. The UART interface can be used for data transmission, AT communication, or firmware upgrades. The 3G-EA Click offers full

hardware flow control over the UART RTS and CTS pins. As the UG95 is internally supplied by 1.8V, the 3G-EA Click uses the TXB0106, a 6-bit bidirectional level shifting and voltage translator from Texas Instruments. In addition, the 3G-EA Click has a ringing RI indicator and the PWK as a power key, which is used during the power-up sequence. The STA is a status pin used to signal the status of the device, in addition to the STAT LED. The other LED is TXD, which indicates the network status. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the I/O SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used as a reference for further development.

3G-EA Click (for EU and Australia) hardware overview image

Features overview

Development board

EasyAVR v7 is the seventh generation of AVR development boards specially designed for the needs of rapid development of embedded applications. It supports a wide range of 16-bit AVR microcontrollers from Microchip and has a broad set of unique functions, such as a powerful onboard mikroProg programmer and In-Circuit debugger over USB. The development board is well organized and designed so that the end-user has all the necessary elements in one place, such as switches, buttons, indicators, connectors, and others. With four different connectors for each port, EasyAVR v7 allows you to connect accessory boards, sensors, and custom electronics more

efficiently than ever. Each part of the EasyAVR v7 development board contains the components necessary for the most efficient operation of the same board. An integrated mikroProg, a fast USB 2.0 programmer with mikroICD hardware In-Circuit Debugger, offers many valuable programming/debugging options and seamless integration with the Mikroe software environment. Besides it also includes a clean and regulated power supply block for the development board. It can use a wide range of external power sources, including an external 12V power supply, 7-12V AC or 9-15V DC via DC connector/screw terminals, and a power source via the USB Type-B (USB-B)

connector. Communication options such as USB-UART and RS-232 are also included, alongside the well-established mikroBUS™ standard, three display options (7-segment, graphical, and character-based LCD), and several different DIP sockets which cover a wide range of 16-bit AVR MCUs. EasyAVR v7 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.

EasyAVR v7 horizontal image

Microcontroller Overview

MCU Card / MCU

default

Architecture

AVR

MCU Memory (KB)

32

Silicon Vendor

Microchip

Pin count

40

RAM (Bytes)

2048

You complete me!

Accessories

Rubber Antenna GSM/GPRS Right Angle is the perfect companion for all GSM Click boards™ in our extensive lineup. This specialized antenna is designed to optimize your wireless connectivity with impressive features. With a wide frequency range spanning 824-894/1710-1990MHz or 890-960/1710-1890MHz, it can handle various frequency bands, ensuring a seamless and reliable connection. The antenna boasts an impedance of 50 Ohms and a gain of 2dB, enhancing signal reception and transmission. Its 70/180MHz bandwidth provides flexibility for diverse applications. The vertical polarization further enhances its performance. With a maximum input power capacity of 50W, this antenna ensures robust communication even under demanding conditions. Measuring a compact 50mm in length and featuring an SMA male connector, the Rubber Antenna GSM/GPRS Right Angle is a versatile and compact solution for your wireless communication needs.

3G-EA Click accessories image

Used MCU Pins

mikroBUS™ mapper

Status Indicator
PA7
AN
Module Power-Up
PA6
RST
UART RTS
PA5
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
UART RI
PD4
PWM
UART CTS
PD2
INT
UART TX
PD1
TX
UART RX
PD0
RX
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Schematic

3G-EA Click (for EU and Australia) Schematic schematic

Step by step

Project assembly

EasyAVR v7 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the EasyAVR v7 as your development board.

EasyAVR v7 front image hardware assembly
GNSS2 Click front image hardware assembly
MCU DIP 40 hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
EasyAVR v7 Access DIP 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 DIP image step 7 hardware assembly
EasyPIC PRO v7a Display Selection Necto Step 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

After pressing the "FLASH" button on the left-side panel, it is necessary to open the UART terminal to display the achieved results. By clicking on the Tools icon in the right-hand panel, multiple different functions are displayed, among which is the UART Terminal. Click on the offered "UART Terminal" icon.

UART Application Output Step 1

Once the UART terminal is opened, the window takes on a new form. At the top of the tab are two buttons, one for adjusting the parameters of the UART terminal and the other for connecting the UART terminal. The tab's lower part is reserved for displaying the achieved results. Before connecting, the terminal has a Disconnected status, indicating that the terminal is not yet active. Before connecting, it is necessary to check the set parameters of the UART terminal. Click on the "OPTIONS" button.

UART Application Output Step 2

In the newly opened UART Terminal Options field, we check if the terminal settings are correct, such as the set port and the Baud rate of UART communication. If the data is not displayed properly, it is possible that the Baud rate value is not set correctly and needs to be adjusted to 115200. If all the parameters are set correctly, click on "CONFIGURE".

UART Application Output Step 3

The next step is to click on the "CONNECT" button, after which the terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.

UART Application Output Step 4

Software Support

Library Description

This library contains API for 3G-EA Click driver.

Key functions:

  • c3gea_set_sim_apn - This function sets APN for sim card

  • c3gea_send_sms_text - This function sends text message to a phone number

  • c3gea_send_sms_pdu - This function sends text message to a phone number in PDU mode

Open Source

Code example

This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.

/*!
 * @file main.c
 * @brief 3G-EA Click Example.
 *
 * # Description
 * This example reads and processes data from 3G-EA click.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes the driver and powers up the module, then sets default configuration 
 * for connecting the device to network.
 * 
 * ## Application Task  
 * Waits for device to connect to network and then sends a desired SMS to the selected phone number
 * approximately every 30 seconds.
 * 
 * ## Additional Function
 * - static void c3gea_clear_app_buf ( void )
 * - static void c3gea_error_check( err_t error_flag )
 * - static void c3gea_log_app_buf ( void )
 * - static void c3gea_check_connection( void )
 * - static err_t c3gea_rsp_check ( void )
 * - static err_t c3gea_process ( void )
 * 
 * @note 
 * In order for the example to work, user needs to set the phone number to which he wants 
 * to send an SMS, and also will need to set an APN and SMSC (required for PDU mode only) of entered SIM card.
 * Enter valid data for the following macros: SIM_APN, SIM_SMSC and PHONE_NUMBER_TO_MESSAGE.
 * E.g. 
    SIM_APN "vipmobile"
    SIM_SMSC "+381610401"
    PHONE_NUMBER_TO_MESSAGE "+38169999999"
 *
 * @author Stefan Ilic
 *
 */

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

#define APP_OK                               0
#define APP_ERROR_DRIVER                    -1
#define APP_ERROR_OVERFLOW                  -2
#define APP_ERROR_TIMEOUT                   -3

#define RSP_OK                              "OK"
#define RSP_ERROR                           "ERROR"

#define SIM_APN                             ""  // Set valid SIM APN
#define SIM_SMSC                            ""  // Set valid SMS Service Center Address - only in PDU mode
#define PHONE_NUMBER_TO_MESSAGE             ""  // Set Phone number to message
#define MESSAGE_CONTENT                     "3G-EA click board - demo example."   // Message content 

#define PROCESS_BUFFER_SIZE                 256

#define WAIT_FOR_CONNECTION                 0
#define CONNECTED_TO_NETWORK                1

static c3gea_t c3gea;
static log_t logger;

static char app_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
static int32_t app_buf_len = 0;
static int32_t app_buf_cnt = 0;

static uint8_t app_connection_status        = WAIT_FOR_CONNECTION;

static err_t app_error_flag;

/**
 * @brief 3G-EA clearing application buffer.
 * @details This function clears memory of application buffer and reset it's length and counter.
 * @note None.
 */
static void c3gea_clear_app_buf ( void );

/**
 * @brief 3G-EA 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.
 *         @li @c -2 - Application buffer overflow.
 *
 * See #err_t definition for detailed explanation.
 * @note None.
 */
static err_t c3gea_process ( void );

/**
 * @brief 3G-EA check for errors.
 * @details This function checks for different types of errors and logs them on UART.
 * @note None.
 */
static void c3gea_error_check( err_t error_flag );

/**
 * @brief 3G-EA logs application buffer.
 * @details This function logs data from application buffer.
 * @note None.
 */
static void c3gea_log_app_buf ( void );

/**
 * @brief 3G-EA response check.
 * @details This function checks for response and returns the status of response.
 * 
 * @return application status.
 * See #err_t definition for detailed explanation.
 * @note None.
 */
static err_t c3gea_rsp_check ( void );

/**
 * @brief 3G-EA check connection.
 * @details This function checks connection to the network and 
 *          logs that status to UART.
 * 
 * @note None.
 */
static void c3gea_check_connection( void );

// ------------------------------------------------------ APPLICATION FUNCTIONS


void application_init ( void ) {
    log_cfg_t log_cfg;  /**< Logger config object. */
    c3gea_cfg_t c3gea_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.

    c3gea_cfg_setup( &c3gea_cfg );
    C3GEA_MAP_MIKROBUS( c3gea_cfg, MIKROBUS_1 );
    c3gea_init( &c3gea, &c3gea_cfg );

    c3gea_module_power( &c3gea, C3GEA_MODULE_POWER_ON );
    
    // dummy read
    c3gea_process( );
    c3gea_clear_app_buf( );
    
    // AT
    c3gea_send_cmd( &c3gea, C3GEA_CMD_AT );
    app_error_flag = c3gea_rsp_check( );
    c3gea_error_check( app_error_flag );
    Delay_ms( 500 );
    
    // ATI - product information
    c3gea_send_cmd( &c3gea, C3GEA_CMD_ATI );
    app_error_flag = c3gea_rsp_check(  );
    c3gea_error_check( app_error_flag );
    Delay_ms( 500 );
    
    // CGMR - firmware version
    c3gea_send_cmd( &c3gea, C3GEA_CMD_CGMR );
    app_error_flag = c3gea_rsp_check(  );
    c3gea_error_check( app_error_flag );
    Delay_ms( 500 );
    
    // CMEE - Report Mobile Equipment Error
    c3gea_send_cmd_with_parameter( &c3gea, C3GEA_CMD_CMEE, "2" );
    app_error_flag = c3gea_rsp_check(  );
    c3gea_error_check( app_error_flag );
    Delay_ms( 500 );
    
    // COPS - deregister from network
    c3gea_send_cmd_with_parameter( &c3gea, C3GEA_CMD_COPS, "2" );
    Delay_ms( 4000 );
    app_error_flag = c3gea_rsp_check(  );
    c3gea_error_check( app_error_flag );
    Delay_ms( 500 );
    
    // CGDCONT - set sim apn
    c3gea_set_sim_apn( &c3gea, SIM_APN );
    app_error_flag = c3gea_rsp_check(  );
    c3gea_error_check( app_error_flag );
    Delay_ms( 500 );
    
    // CFUN - full funtionality
    c3gea_send_cmd_with_parameter( &c3gea, C3GEA_CMD_CFUN, "1" );
    app_error_flag = c3gea_rsp_check(  );
    c3gea_error_check( app_error_flag );
    Delay_ms( 500 );
    
    // COPS - automatic mode
    c3gea_send_cmd_with_parameter( &c3gea, C3GEA_CMD_COPS, "0" );
    Delay_ms( 4000 );
    app_error_flag = c3gea_rsp_check(  );
    c3gea_error_check( app_error_flag );
    Delay_ms( 500 );
    
    // CREG - network registration status
    c3gea_send_cmd_with_parameter( &c3gea, C3GEA_CMD_CREG, "1" );
    app_error_flag = c3gea_rsp_check(  );
    c3gea_error_check( app_error_flag );
    Delay_ms( 500 );
    
    app_buf_len = 0;
    app_buf_cnt = 0;
    app_connection_status = WAIT_FOR_CONNECTION;
    log_info( &logger, " Application Task " );
    Delay_ms( 5000 );
}

void application_task ( void ) {
     if ( app_connection_status == WAIT_FOR_CONNECTION ) {
        // CREG - network registration status
        c3gea_send_cmd_check( &c3gea, C3GEA_CMD_CREG );
        app_error_flag = c3gea_rsp_check(  );
        c3gea_error_check( app_error_flag );
        Delay_ms( 500 );
        
        // CSQ - signal quality
        c3gea_send_cmd( &c3gea, C3GEA_CMD_CSQ );
        app_error_flag = c3gea_rsp_check(  );
        c3gea_error_check( app_error_flag );
        Delay_ms( 3000 );
    } else {
        log_info( &logger, "CONNECTED TO NETWORK" );
        
        // SMS message format - PDU mode
        c3gea_send_cmd_with_parameter( &c3gea, C3GEA_CMD_CMGF, "0" );
        app_error_flag = c3gea_rsp_check(  );
        c3gea_error_check( app_error_flag );
        Delay_ms( 3000 );
        
        for( ; ; ) {   
            log_printf( &logger, "> Sending message to phone number...\r\n" );
            c3gea_send_sms_pdu ( &c3gea, SIM_SMSC, PHONE_NUMBER_TO_MESSAGE, MESSAGE_CONTENT );
            app_error_flag = c3gea_rsp_check(  );
            c3gea_error_check( app_error_flag );
            Delay_ms( 10000 );
            Delay_ms( 10000 );
            Delay_ms( 10000 );
        }
    }
}

void main ( void ) {
    application_init( );

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

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

static err_t c3gea_process ( void ) {
    err_t return_flag = APP_ERROR_DRIVER;
    int32_t rx_size;
    char rx_buff[ PROCESS_BUFFER_SIZE ] = { 0 };
    
    rx_size = c3gea_generic_read( &c3gea, rx_buff, PROCESS_BUFFER_SIZE );

    if ( rx_size > 0 ) { 
        int32_t buf_cnt = 0;
        return_flag = APP_OK;

        if ( app_buf_len + rx_size >= PROCESS_BUFFER_SIZE ) {
            c3gea_clear_app_buf(  );
            return_flag = APP_ERROR_OVERFLOW;
        } else {
            buf_cnt = app_buf_len;
            app_buf_len += rx_size;
        }

        for ( int32_t rx_cnt = 0; rx_cnt < rx_size; rx_cnt++ ) {
            if ( rx_buff[ rx_cnt ] != 0 ) {
                app_buf[ ( buf_cnt + rx_cnt ) ] = rx_buff[ rx_cnt ];
            } else {
                app_buf_len--;
                buf_cnt--;
            }
        }
    } 

    return return_flag;
}

static err_t c3gea_rsp_check ( void ) {
    uint16_t timeout_cnt = 0;
    uint32_t timeout = 100000;
    
    err_t error_flag = c3gea_process(  );
    
    if ( ( error_flag != 0 ) && ( error_flag != -1 ) ) {
        return error_flag;
    }
    
    while ( ( strstr( app_buf, RSP_OK ) == 0 ) && ( strstr( app_buf, RSP_ERROR ) == 0 ) ) {
        error_flag = c3gea_process(  );
        if ( ( error_flag != 0 ) && ( error_flag != -1 ) ) {
            return error_flag;
        }
        
        timeout_cnt++;
        if ( timeout_cnt > timeout ) {
            while ( ( strstr( app_buf, RSP_OK ) == 0 ) && ( strstr( app_buf, RSP_ERROR ) == 0 ) ) {
                c3gea_send_cmd( &c3gea, C3GEA_CMD_AT );
                c3gea_process(  );
                Delay_ms( 100 );
            }
            c3gea_clear_app_buf(  );
            return APP_ERROR_TIMEOUT;
        }
        
        Delay_ms( 1 );
    }
    
    c3gea_check_connection();
    
    c3gea_log_app_buf();
    
    return APP_OK;
}

static void c3gea_error_check( err_t error_flag ) {
    if ( ( error_flag != 0 ) && ( error_flag != -1 ) ) {
        switch ( error_flag ) {
            case -2:
                log_error( &logger, " Overflow!" );
                break;
            case -3:
                log_error( &logger, " Timeout!" );
                break;
            default:
                break;
        }
    }
}

static void c3gea_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 ] );
    }
    log_printf( &logger, "\r\n-----------------------------------\r\n" );
    
    c3gea_clear_app_buf(  );
}

static void c3gea_check_connection( void ) {
    #define CONNECTED "+CREG: 1,1"
    
    if ( strstr( app_buf, CONNECTED ) != 0 ) {
        app_connection_status = CONNECTED_TO_NETWORK;
    }
}

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

Additional Support

Resources