TOP Contributors

  1. MIKROE (2752 codes)
  2. Alcides Ramos (372 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 (139062 times)
  2. FAT32 Library (71593 times)
  3. Network Ethernet Library (56989 times)
  4. USB Device Library (47330 times)
  5. Network WiFi Library (43006 times)
  6. FT800 Library (42297 times)
  7. GSM click (29777 times)
  8. mikroSDK (27874 times)
  9. PID Library (26858 times)
  10. microSD click (26129 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: 20 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

Hall Current 5 click

5

Hall Current 5 Click is a very accurate electric current measurement Click board based on the ACS733 IC. This IC is a galvanically isolated current sensor, which utilizes the Hall-effect principle.

[Learn More]

LTE IoT 5 Click

0

LTE IoT 5 Click is add-on board with compact and cost-effective secure cloud multi-band module solution designed for IoT applications. This board features the SARA-R510M8S, a cellular module that supports LTE-M/NB-IoT* bands with integrated high performance standard precision M8 GNSS receiver for global position acquisition from u-Blox.

[Learn More]

DIGI POT 2 click

10

DIGI POT 2 click is a mikroBUS add-on board with a single channel digital potentiometer TPL0501 with 256 wiper positions. The IC has 100 kilo Ohms end-to-end resistance, with ±20% tolerance. The board features two pairs of screw terminals for interfacing with the IC DIGI POT 2 click communicates with the target MCU through the mikroBUS SPI.

[Learn More]