TOP Contributors

  1. MIKROE (2784 codes)
  2. Alcides Ramos (387 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (120 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 (140167 times)
  2. FAT32 Library (72621 times)
  3. Network Ethernet Library (57641 times)
  4. USB Device Library (47954 times)
  5. Network WiFi Library (43553 times)
  6. FT800 Library (42942 times)
  7. GSM click (30140 times)
  8. mikroSDK (28669 times)
  9. PID Library (27055 times)
  10. microSD click (26552 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

BATT-MON 2 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.9

mikroSDK Library: 2.0.0.0

Category: Battery Charger

Downloaded: 121 times

Not followed.

License: MIT license  

BATT-MON 2 Click is a compact add-on board representing a battery monitoring solution. This board features the MAX17262, an ultra-low power I2C-configurable fuel-gauge IC which implements the ModelGauge™ m5 algorithm from Analog Devices. The MAX17262 monitors a single-cell battery pack (best performance for batteries with 100mAhr to 6Ahr capacity), providing precision measurements of current, voltage, and temperature, and supporting internal current sensing for up to 3.1A pulse current. The battery pack's temperature is measured using an internal temperature sensor or external thermistor.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "BATT-MON 2 Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "BATT-MON 2 Click" changes.

Do you want to report abuse regarding "BATT-MON 2 Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


BATT-MON 2 Click

BATT-MON 2 Click is a compact add-on board representing a battery monitoring solution. This board features the MAX17262, an ultra-low power I2C-configurable fuel-gauge IC which implements the ModelGauge™ m5 algorithm from Analog Devices. The MAX17262 monitors a single-cell battery pack (best performance for batteries with 100mAhr to 6Ahr capacity), providing precision measurements of current, voltage, and temperature, and supporting internal current sensing for up to 3.1A pulse current. The battery pack's temperature is measured using an internal temperature sensor or external thermistor.

battmon2_click.png

Click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Jan 2022.
  • Type : I2C type

Software Support

We provide a library for the BATT-MON 2 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 BATT-MON 2 Click driver.

Standard key functions :

  • battmon2_cfg_setup Config Object Initialization function.

    void battmon2_cfg_setup ( battmon2_cfg_t *cfg );
  • battmon2_init Initialization function.

    err_t battmon2_init ( battmon2_t *ctx, battmon2_cfg_t *cfg );

Example key functions :

  • battmon2_get_battery_voltage This function reads the battery voltage in mV.

    err_t battmon2_get_battery_voltage ( battmon2_t *ctx, float *voltage );
  • battmon2_get_battery_current This function reads the battery current in mA.

    err_t battmon2_get_battery_current ( battmon2_t *ctx, float *current );
  • battmon2_get_battery_percentage This function reads the battery remaining SOC percentage.

    err_t battmon2_get_battery_percentage ( battmon2_t *ctx, float *percentage );

Example Description

This example demonstrates the use of BATT-MON 2 Click board by monitoring the measurements of battery voltage, current, capacity, percentage, time-to-empty or time-to-full, as well as the chip internal temperature.

The demo application is composed of two sections :

Application Init

Initializes the driver and checks the communication by reading and verifying the device ID.


void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    battmon2_cfg_t battmon2_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.
    battmon2_cfg_setup( &battmon2_cfg );
    BATTMON2_MAP_MIKROBUS( battmon2_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == battmon2_init( &battmon2, &battmon2_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( BATTMON2_ERROR == battmon2_check_communication ( &battmon2 ) )
    {
        log_error( &logger, " Check communication." );
        for ( ; ; );
    }

    log_info( &logger, " Application Task " );
}

Application Task

Reads and displays on the USB UART the measurements of battery voltage, current, capacity, percentage, time-to-empty or time-to-full, as well as the chip internal temperature approximately once per second.

void application_task ( void )
{
    float voltage, capacity, percentage, current, die_temp;
    if ( BATTMON2_OK == battmon2_get_battery_voltage ( &battmon2, &voltage ) )
    {
        log_printf ( &logger, " Voltage: %.1f mV \r\n", voltage );
    }
    if ( BATTMON2_OK == battmon2_get_battery_current ( &battmon2, &current ) )
    {
        log_printf ( &logger, " Current: %.1f mA \r\n", current );
    }
    if ( BATTMON2_OK == battmon2_get_battery_capacity ( &battmon2, &capacity ) )
    {
        log_printf ( &logger, " Capacity: %.1f mAh \r\n", capacity );
    }
    if ( BATTMON2_OK == battmon2_get_battery_percentage ( &battmon2, &percentage ) )
    {
        log_printf ( &logger, " Percentage: %.1f %% \r\n", percentage );
    }
    if ( current > 0 )
    {
        uint32_t time_to_full;
        if ( BATTMON2_OK == battmon2_get_battery_ttf ( &battmon2, &time_to_full ) )
        {
            log_printf ( &logger, " Time to full: %uh %umin %usec \r\n", ( uint16_t ) ( time_to_full / 3600 ), 
                                                                         ( uint16_t ) ( time_to_full % 3600 ) / 60,
                                                                         ( uint16_t ) ( time_to_full % 60 ) );
        }
    }
    else if ( current < 0 )
    {
        uint32_t time_to_empty;
        if ( BATTMON2_OK == battmon2_get_battery_tte ( &battmon2, &time_to_empty ) )
        {
            log_printf ( &logger, " Time to empty: %uh %umin %usec \r\n", ( uint16_t ) ( time_to_empty / 3600 ), 
                                                                          ( uint16_t ) ( time_to_empty % 3600 ) / 60,
                                                                          ( uint16_t ) ( time_to_empty % 60 ) );
        }
    }
    if ( BATTMON2_OK == battmon2_get_die_temperature ( &battmon2, &die_temp ) )
    {
        log_printf ( &logger, " Internal temperature: %.2f C \r\n\n", die_temp );
    }
    Delay_ms ( 1000 );
}

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

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

Barometer 2 click

5

Barometer 2 Click is a digital barometer on a Click board. Barometer 2 is equipped with the LPS35HW, an absolute piezoresistive pressure sensor with ceramic, water resistant package, manufactured using a proprietary technology.

[Learn More]

IoT ExpressLink 3 Click

0

IoT ExpressLink 3 Click is a compact add-on board that allows users to connect easily to IoT ExpressLink services and securely interact with cloud applications and other devices. This board features the NORA-W256WS, a standalone multi-radio module from u-blox. The module supports Wi-Fi radio at 802.11b/g/n standard and 2.4GHz of ISM band. It also supports the Bluetooth Low Energy 5. The embedded AWS IoT ExpressLink-compliant software includes secured pre-flashed certificates in the module.

[Learn More]

GSM 5 Click

0

GSM 5 Click is a compact add-on board representing a compact GSM cellular network communication solution. This board features the SARA-G450, a GSM/GPRS quad-band cellular module certified and approved by the main regulatory bodies and operators from u-blox. It features class 12 GSM/GPRS connectivity in the popular u-blox SARA form factor and comes with a comprehensive feature set, including an extensive set of internet protocols designed to provide fully integrated access to u-blox GNSS positioning with embedded A-GPS (AssistNow Online and AssistNow Offline) functionality. Besides a data rate up to 85.6 kbps and an advanced jamming detection feature, this board also offers a high-quality integrated audio interface allowing voice communication.

[Learn More]