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 (139064 times)
  2. FAT32 Library (71594 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

PWR Meter click

Rating:

5

Author: MIKROE

Last Updated: 2018-09-27

Package Version: 1.0.0.0

mikroSDK Library: 1.0.0.0

Category: Measurements

Downloaded: 5006 times

Not followed.

License: MIT license  

PWR Meter click is a power measurement Click board, capable of measuring voltage and current through the load, connected to either AC or DC power source.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "PWR Meter click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "PWR Meter click" changes.

Do you want to report abuse regarding "PWR Meter click".

  • mikroSDK Library 2.0.0.0
  • Comments (0)
DOWNLOAD LINK RELATED COMPILER CONTAINS
mikroBasic PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc

mikroSDK Library Blog

PWR Meter click

PWR Meter click

Native view of the PWR Meter click board.

View full image
PWR Meter click

PWR Meter click

Front and back view of the PWR Meter click board.

View full image

Library Description

Library performs the communication with the device via uart interface by sending commands and checking response from the device to the host. Commands perform writting to the registers, reading from the registers (data can be 8bit, 16bit, or 32bit), calibration, writting to the EEPROM and reading from the EEPROM. By using functions for reading user can read measurements that include voltage RMS, current RMS, power data (active, reactive, apparent) and many other things. For more details check documentation.

Key functions:

  • T_PWRMETER_RETVAL pwrmeter_readRegBytes( uint16_t regAddr, uint8_t nBytes, uint8_t *dataOut ) - Function reads data bytes from registers.
  • T_PWRMETER_RETVAL pwrmeter_writeRegWORD( uint16_t registerAddr, uint16_t dataIn ) - Function writes 16-bit data to the register.
  • T_PWRMETER_RETVAL pwrmeter_sendCommand( uint8_t commandByte ) - Function sends and performs a determined command.

Example description

The application is composed of three sections :

  • System Initialization - Initializes peripherals and pins.
  • Application Initialization - Initializes UART interface, puts output of regulator in active state and configures gain channel and uart baud rate.
  • Application Task - (code snippet) - Reads voltage, current and power measurements from data registers, converts this values to determined units and all results on uart terminal. Repeats operation every second.
void applicationTask()
{
 responseByte = pwrmeter_readRegWORD( _PWRMETER_VOLT_RMS_REG, &voltageRMS );
 checkResponse();
 responseByte = pwrmeter_readRegDWORD( _PWRMETER_CURR_RMS_REG, ¤tRMS );
 checkResponse();
 responseByte = pwrmeter_readRegDWORD( _PWRMETER_ACTIVE_PWR_REG, &activePower );
 checkResponse();
 responseByte = pwrmeter_readRegDWORD( _PWRMETER_REACTIVE_PWR_REG, &reactivePower );
 checkResponse();
 responseByte = pwrmeter_readRegDWORD( _PWRMETER_APPARENT_PWR_REG, &apparentPower );
 checkResponse();
 responseByte = pwrmeter_readRegSigned( _PWRMETER_PWR_FACTOR_REG, _PWRMETER_16BIT_DATA, &powerFactor );
 checkResponse();

 measData[ 0 ] = (float)voltageRMS / 100;
 measData[ 1 ] = (float)currentRMS / 1000;
 measData[ 2 ] = (float)activePower / 100000;
 measData[ 3 ] = (float)reactivePower / 100000;
 measData[ 4 ] = (float)apparentPower / 100000;
 measData[ 5 ] = (float)powerFactor / 32767;

 responseByte = pwrmeter_getStatus( &statusByte );
 checkResponse();

 if ((statusByte & _PWRMETER_DCMODE_MASK) != 0)
 {
 mikrobus_logWrite( "DC mode", _LOG_LINE );
 }
 else
 {
 mikrobus_logWrite( "AC mode", _LOG_LINE );
 }

 FloatToStr( measData[ 0 ], text );
 floatConv();
 mikrobus_logWrite( "RMS voltage: ", _LOG_TEXT );
 if (((statusByte & _PWRMETER_DCMODE_MASK) != 0) && ((statusByte & _PWRMETER_DCVOLT_SIGN_MASK) == 0))
 {
 mikrobus_logWrite( "-", _LOG_TEXT );
 }
 mikrobus_logWrite( text, _LOG_TEXT );
 mikrobus_logWrite( "[V]", _LOG_LINE );

 FloatToStr( measData[ 1 ], text );
 floatConv();
 mikrobus_logWrite( "RMS current: ", _LOG_TEXT );
 if (((statusByte & _PWRMETER_DCMODE_MASK) != 0) && ((statusByte & _PWRMETER_DCCURR_SIGN_MASK) == 0))
 {
 mikrobus_logWrite( "-", _LOG_TEXT );
 }
 mikrobus_logWrite( text, _LOG_TEXT );
 mikrobus_logWrite( "[mA]", _LOG_LINE );

 FloatToStr( measData[ 2 ], text );
 floatConv();
 mikrobus_logWrite( "Active power: ", _LOG_TEXT );
 if ((statusByte & _PWRMETER_PA_SIGN_MASK) == 0)
 {
 mikrobus_logWrite( "-", _LOG_TEXT );
 }
 mikrobus_logWrite( text, _LOG_TEXT );
 mikrobus_logWrite( "[W]", _LOG_LINE );

 FloatToStr( measData[ 3 ], text );
 floatConv();
 mikrobus_logWrite( "Reactive power: ", _LOG_TEXT );
 if ((statusByte & _PWRMETER_PR_SIGN_MASK) == 0)
 {
 mikrobus_logWrite( "-", _LOG_TEXT );
 }
 mikrobus_logWrite( text, _LOG_TEXT );
 mikrobus_logWrite( "[VAr]", _LOG_LINE );

 FloatToStr( measData[ 4 ], text );
 floatConv();
 mikrobus_logWrite( "Apparent power: ", _LOG_TEXT );
 mikrobus_logWrite( text, _LOG_TEXT );
 mikrobus_logWrite( "[VA]", _LOG_LINE );

 FloatToStr( measData[ 5 ], text );
 floatConv();
 mikrobus_logWrite( "Power factor: ", _LOG_TEXT );
 mikrobus_logWrite( text, _LOG_LINE );
 mikrobus_logWrite( "", _LOG_LINE );

 Delay_ms( 1000 );
}

Additional Functions :

  • void checkResponse() - Checks response from the device to the host and logs message if error occurred.
  • void floatConv() - Makes the float values be rounded to two decimal places.


Other mikroE Libraries used in the example:

  • Conversions
  • UART

Additional notes and information

Depending on the development board you are using, you may need USB UART clickUSB UART 2 click or RS232 click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.

ALSO FROM THIS AUTHOR

DC Motor 3 click

1

DC Motor 3 click is a mikroBUS add-on board with a Toshiba TB6549FG full-bridge driver for direct current motors. The IC is capable of outputting currents of up to 3.5 A with 30V, making it suitable for high-power motors. The click communicates with the target MCU through the mikroBUS PWM pin. Designed to use a 3.3 power supply only.

[Learn More]

Peltier Click

0

The Peltier Click is a Click board™ which utilizes the SPV1050, an ultralow power energy harvester and battery charger from STMicroelectronics. The Peltier Click can charge lithium battery using thermoelectric energy harvesting device (TEG).

[Learn More]

MIC24045 click

6

MIC24045 click carries MIC24045 I2C-programmable, high-efficiency, wide input range, 5A synchronous step-down regulator from Microchip. The click is designed to run on either 3.3V or 5V power supply. It communicates with the target microcontroller over I2C interface.

[Learn More]