TOP Contributors

  1. MIKROE (2730 codes)
  2. Alcides Ramos (369 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (116 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 (138642 times)
  2. FAT32 Library (71283 times)
  3. Network Ethernet Library (56793 times)
  4. USB Device Library (47127 times)
  5. Network WiFi Library (42856 times)
  6. FT800 Library (42100 times)
  7. GSM click (29663 times)
  8. mikroSDK (27527 times)
  9. PID Library (26788 times)
  10. microSD click (26020 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-09-18

Package Version: 2.1.0.1

mikroSDK Library: 2.0.0.0

Category: Power Switch

Downloaded: 9 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

Pressure 8 click

5

Pressure 8 Click is an accurate and fully calibrated pressure sensor, equipped with the MPR series integrated piezoresistive silicon pressure sensor IC.

[Learn More]

NFC 5 click

0

NFC 5 Click is a compact add-on board designed for advanced NFC applications. This board features the ST25R3918, a multipurpose NFC transceiver from STMicroelectronics. This Click board™ is built to cater to the growing needs of the Internet of Things (IoT) ecosystem, providing robust NFC reader functionalities, passive peer-to-peer communication, and card emulation modes with outstanding analog performance. Its notable features include exceptional read range with minimal power output, advanced noise reduction, and compatibility with ISO14443, ISO15693, and NFC Forum Tag types 1, 2, 4, and 5.

[Learn More]

TempHum 12 click

0

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]