Skip to content

Instantly share code, notes, and snippets.

@pasindu-sandima
Created December 10, 2021 09:42
Show Gist options
  • Save pasindu-sandima/206e8282fc91e3a10b1cac433385b6f1 to your computer and use it in GitHub Desktop.
Save pasindu-sandima/206e8282fc91e3a10b1cac433385b6f1 to your computer and use it in GitHub Desktop.
#ifndef ADE9153AAPI_h
#define ADE9153AAPI_h
#include "Arduino.h"
#include "ADE9153A.h"
/**************************************************************************
Definitions
**************************************************************************/
/* Configuration Registers */
#define ADE9153A_AI_PGAGAIN 0x000A /*Signal on IAN, current channel gain=16x*/
#define ADE9153A_CONFIG0 0x00000000 /*Datapath settings at default*/
#define ADE9153A_CONFIG1 0x0300 /*Chip settings at default*/
#define ADE9153A_CONFIG2 0x0C00 /*High-pass filter corner, fc=0.625Hz*/
#define ADE9153A_CONFIG3 0x0000 /*Peak and overcurrent settings, CONFIG3 bit0 Set to enable Overcurrent detection*/
#define ADE9153A_ACCMODE 0x0000 /*Energy accumulation modes, Bit 4, 0 for 50Hz, 1 for 60Hz*/
#define ADE9153A_VLEVEL 0x0022EA28 /*Assuming Vnom=1/2 of fullscale*/
#define ADE9153A_ZX_CFG 0x0000 /*ZX low-pass filter select*/
#define ADE9153A_MASK 0x00000100 /*Enable EGYRDY interrupt*/
#define ADE9153A_ACT_NL_LVL 0x000033C8
#define ADE9153A_REACT_NL_LVL 0x000033C8
#define ADE9153A_APP_NL_LVL 0x000033C8
/* Constant Definitions */
#define ADE9153A_RUN_ON 0x0001 /*DSP On*/
#define ADE9153A_COMPMODE 0x0005 /*Initialize for proper operation*/
#define ADE9153A_VDIV_RSMALL 0x03E8 /*Small resistor on board is 1kOhm=0x3E8*/
/* Energy Accumulation Settings */
#define ADE9153A_EP_CFG 0x0009 /*Energy accumulation configuration*/
#define ADE9153A_EGY_TIME 0x0F9F /*Accumulate energy for 4000 samples*/
/* Temperature Sensor Settings */
#define ADE9153A_TEMP_CFG 0x000C /*Temperature sensor configuration*/
/* Ideal Calibration Values for ADE9153A Shield Based on Sensor Values */
#define CAL_IRMS_CC 1.197414 // (uA/code)
#define CAL_VRMS_CC 13.37014 // (uV/code)
#define CAL_POWER_CC 1601.034 // (uW/code) Applicable for Active, reactive and apparent power
#define CAL_ENERGY_CC 0.910811 // (uWhr/xTHR_HI code)Applicable for Active, reactive and apparent energy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment