TOP Contributors

  1. MIKROE (2653 codes)
  2. Alcides Ramos (351 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 (136638 times)
  2. FAT32 Library (69845 times)
  3. Network Ethernet Library (55896 times)
  4. USB Device Library (46230 times)
  5. Network WiFi Library (41868 times)
  6. FT800 Library (41091 times)
  7. GSM click (28947 times)
  8. PID Library (26402 times)
  9. mikroSDK (26320 times)
  10. microSD click (25329 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: 4491 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

Dual LIN click

0

The Dual LIN click is a Click board™ based on the TLE7268SKXUMA1, a Dual LIN transceiver from Infineon.

[Learn More]

GSM click

0

GSM click is the easiest way to add GSM/GPRS communication to your device. The click features Telit's GL865-QUAD. GSM click runs either on 3.3V or 5V power supply and communicates with the target microcontroller via UART interface.

[Learn More]

TempHum 14 click

0

Temp & Hum 14 Click is a compact add-on board that contains one of the smallest and most accurate humidity and temperature sensors on the market. This board features the HTU31D, a highly accurate digital relative humidity sensor with temperature output from TE Connectivity. With power consumption down to 3.78μW and accuracy of ±2%RH and ±0.2°C, this Click board™ provides fast response time, precision measurement, low hysteresis, and sustained performance even when exposed to extreme temperature up to 125°C and humidity environments.

[Learn More]