TOP Contributors

  1. MIKROE (2663 codes)
  2. Alcides Ramos (358 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (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 (137089 times)
  2. FAT32 Library (70232 times)
  3. Network Ethernet Library (56104 times)
  4. USB Device Library (46434 times)
  5. Network WiFi Library (42053 times)
  6. FT800 Library (41384 times)
  7. GSM click (29111 times)
  8. mikroSDK (26560 times)
  9. PID Library (26489 times)
  10. microSD click (25486 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: 4532 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

Temp-Hum 8 click

5

Temp&amp;Hum 8 click is based on a sensor from the popular SHT family, designed to measure temperature and humidity. This sensor family has already become an industry standard, providing proven reliability and stability while requiring a minimum number of components, making the development of applications cheaper and faster.

[Learn More]

Expand 3 click

0

Expand 3 Click is a compact add-on board providing general-purpose I/O expansion. This board features the DS2408, an 8-channel programmable I/O expander from Analog Devices. The DS2408 has a factory-lasered 64-bit registration number, enabling multiple Expand 3 Click boards™ to be connected on the same data line, communicating with the host MCU through a standard Dallas Semiconductor 1-Wire interface (15.3kbps or 100kbps). PIO outputs are configured as open-drain and provide a maximum on-resistance of 100Ω.

[Learn More]

eINK 1.54 inch display

5

This bundle comes with the eINK click adapter and e-Paper display 1.54”. Which provides you an easy start of any project where the e-paper display is needed.

[Learn More]