TOP Contributors

  1. MIKROE (2762 codes)
  2. Alcides Ramos (374 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (90 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 (139263 times)
  2. FAT32 Library (71752 times)
  3. Network Ethernet Library (57128 times)
  4. USB Device Library (47431 times)
  5. Network WiFi Library (43092 times)
  6. FT800 Library (42407 times)
  7. GSM click (29835 times)
  8. mikroSDK (28080 times)
  9. PID Library (26886 times)
  10. microSD click (26198 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

Power Monitor 2 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.2

mikroSDK Library: 2.0.0.0

Category: Power Switch

Downloaded: 22 times

Not followed.

License: MIT license  

Power Monitoring 2 Click is a compact add-on board for precise power monitoring of connected load devices. This board features two INA219 12-bit I2C-output digital power monitors from Texas Instruments. This Click board™ monitors current and voltage on two separate power rails - 3.3V and 5V - of an onboard mikroBUS™ socket, providing real-time digital readings of the power consumption of added Click boards™. It supports high-speed I2C communication with configurable I2C addresses and operates at 3.3V and 5V logic levels, which makes it ideal for applications in power management, system diagnostics, and energy optimization in embedded systems.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Power Monitor 2 Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Power Monitor 2 Click" changes.

Do you want to report abuse regarding "Power Monitor 2 Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


Power Monitor 2 Click

Power Monitoring 2 Click is a compact add-on board for precise power monitoring of connected load devices. This board features two INA219 12-bit I2C-output digital power monitors from Texas Instruments. This Click board™ monitors current and voltage on two separate power rails - 3.3V and 5V - of an onboard mikroBUS™ socket, providing real-time digital readings of the power consumption of added Click boards™. It supports high-speed I2C communication with configurable I2C addresses and operates at 3.3V and 5V logic levels, which makes it ideal for applications in power management, system diagnostics, and energy optimization in embedded systems.

powermonitor2_click.png

Click Product page


Click library

  • Author : Stefan Filipovic
  • Date : Apr 2024.
  • Type : I2C type

Software Support

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

Standard key functions :

  • powermonitor2_cfg_setup Config Object Initialization function.

    void powermonitor2_cfg_setup ( powermonitor2_cfg_t *cfg );
  • powermonitor2_init Initialization function.

    err_t powermonitor2_init ( powermonitor2_t *ctx, powermonitor2_cfg_t *cfg );
  • powermonitor2_default_cfg Click Default Configuration function.

    err_t powermonitor2_default_cfg ( powermonitor2_t *ctx );

Example key functions :

  • powermonitor2_set_address This function sets the device slave address.

    err_t powermonitor2_set_address ( powermonitor2_t *ctx, uint8_t slave_address );
  • powermonitor2_read_data This function reads the shunt voltage, bus voltage, current, and power data measurements.

    err_t powermonitor2_read_data ( powermonitor2_t *ctx, powermonitor2_data_t *data_out );
  • powermonitor2_read_data_avg This function reads the shunt voltage, bus voltage, current, and power data measurements averaged from num_conv samples.

    err_t powermonitor2_read_data_avg ( powermonitor2_t *ctx, uint16_t num_conv, powermonitor2_data_t *data_out );

Example Description

This example demonstrates the use of Power Monitor 2 Click by reading and displaying the power consumption at 3V3 and 5V of the connected Click board.

The demo application is composed of two sections :

Application Init

Initializes the driver and performs the Click default configuration.


void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    powermonitor2_cfg_t powermonitor2_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.
    powermonitor2_cfg_setup( &powermonitor2_cfg );
    POWERMONITOR2_MAP_MIKROBUS( powermonitor2_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == powermonitor2_init( &powermonitor2, &powermonitor2_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( POWERMONITOR2_ERROR == powermonitor2_default_cfg ( &powermonitor2 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

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

Application Task

Reads the voltage, current, and power measurements from U2 and U3 sensors averaged from 20 samples and displays the results on the USB UART.

void application_task ( void )
{
    powermonitor2_data_t pm_3v3, pm_5v;

    powermonitor2_set_address ( &powermonitor2, powermonitor2.address_3v3 );
    if ( POWERMONITOR2_OK == powermonitor2_read_data_avg ( &powermonitor2, POWERMONITOR2_DEFAULT_NUM_CONV, &pm_3v3 ) )
    {
        log_printf( &logger, " --- 3V3 Power Monitor ---\r\n" );
        log_printf( &logger, " Voltage: %.3f V\r\n", pm_3v3.bus_v );
        log_printf( &logger, " Current: %.3f A\r\n", pm_3v3.current );
        log_printf( &logger, " Power: %.2f W\r\n", pm_3v3.power );
        log_printf( &logger, " -------------------------\r\n" );
    }

    powermonitor2_set_address ( &powermonitor2, powermonitor2.address_5v );
    if ( POWERMONITOR2_OK == powermonitor2_read_data_avg ( &powermonitor2, POWERMONITOR2_DEFAULT_NUM_CONV, &pm_5v ) )
    {
        log_printf( &logger, " ---- 5V Power Monitor ---\r\n" );
        log_printf( &logger, " Voltage: %.3f V\r\n", pm_5v.bus_v );
        log_printf( &logger, " Current: %.3f A\r\n", pm_5v.current );
        log_printf( &logger, " Power: %.2f W\r\n", pm_5v.power );
        log_printf( &logger, " -------------------------\r\n" );
    }

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

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

RS Transceiver Click

0

RS Transceiver is a compact add-on board that offers an interface between the TTL level UART and RS-232/RS-422/RS-485 communication buses. This board features the XR34350, an RS-232/RS-422/RS-485 serial transceiver with internal termination and wide output swing from MaxLinear. Integrated cable termination and four configuration modes allow all three protocols to be used interchangeably over a single cable over the DE-9 connector. All transmitter outputs and receiver inputs feature robust ESD protection and HBM up to ±15kV.

[Learn More]

Brushless 7 Click

0

Brushless 7 Click is, as its name said, a motor driver based expansion board for controlling BLCD motors with any microcontroller.

[Learn More]

Bluetooth Switch

1

This example demonstrates wireless Bluetooth switch control, using clicker2 for STM32, Bluetooth click board and Android smart phone.

[Learn More]