ACS37800 library for Arduino
|
Public Member Functions | |
ACS37800 (uint8_t address=0x60, TwoWire *bus=&Wire) | |
void | setBus (TwoWire *bus) |
TwoWire * | getBus () |
void | setAddress (uint8_t address) |
uint8_t | getAddress () |
uint8_t | getLastError () |
void | setBoardPololu (uint8_t rsense_kohm) |
void | setBoardParameters (uint8_t isense_range, uint32_t riso, uint32_t rsense) |
void | enableWriteAccess () |
void | setSampleCount (uint16_t count) |
void | readRMSVoltageAndCurrent () |
void | readActiveAndReactivePower () |
int32_t | readApparentPowerMilliwatts () |
void | readInstVoltageAndCurrent () |
int32_t | readInstPowerMilliwatts () |
int32_t | readRMSVoltageMillivolts () |
int32_t | readRMSCurrentMilliamps () |
int32_t | readActivePowerMilliwatts () |
int32_t | readReactivePowerMilliwatts () |
int32_t | readInstVoltageMillivolts () |
int32_t | readInstCurrentMilliamps () |
void | writeEepromI2CAddress (uint8_t address) |
uint32_t | readReg (uint8_t reg) |
void | writeReg (uint8_t reg, uint32_t value) |
Public Attributes | |
uint16_t | vcodesMult = 1 |
uint16_t | icodesMult = 1 |
uint16_t | pinstantMult = 1 |
uint8_t | vcodesShift = 0 |
uint8_t | icodesShift = 0 |
uint8_t | pinstantShift = 0 |
int32_t | instVoltageMillivolts |
int32_t | instCurrentMilliamps |
int32_t | instPowerMilliwatts |
int32_t | rmsVoltageMillivolts |
int32_t | rmsCurrentMilliamps |
int32_t | activePowerMilliwatts |
int32_t | reactivePowerMilliwatts |
int32_t | apparentPowerMilliwatts |
Definition at line 16 of file ACS37800.h.
|
inline |
Creates a new ACS37800 object.
The address
parameter specifies the 7-bit I2C address to use, and it must match the address that the ACS37800 is configured to use.
Definition at line 23 of file ACS37800.h.
|
inline |
This function writes a special code to the ACS37800 to unlock it, which is a prerequisite for most other register writes. Most users should not need to call this function directly, because it is called by the functions that need it.
Definition at line 135 of file ACS37800.h.
|
inline |
Returns the 7-bit I2C address that this object is configured to use.
Definition at line 55 of file ACS37800.h.
|
inline |
Returns a pointer to the I2C bus that this object is configured to use.
Definition at line 40 of file ACS37800.h.
|
inline |
Returns 0 if the last communication with the device was successful, or a non-zero error code if there was an error.
Definition at line 62 of file ACS37800.h.
|
inline |
Reads the active and reactive power from the sensor, converts both to units of mW, and stores them in the activePowerMilliwatts and reactivePowerMilliwatts members.
Definition at line 180 of file ACS37800.h.
|
inline |
Reads the active power from the sensor and returns its value converted to milliwatts.
If you need the active and reactive power, it is better to use readActiveAndReactivePower().
Definition at line 248 of file ACS37800.h.
|
inline |
Reads the apparent power from the sensor and returns it in mW.
Definition at line 190 of file ACS37800.h.
|
inline |
Reads the instantaneous current measurement from the sensor and returns its value converted to milliamps (mA).
If you need the current and the voltage, it is more efficient to use readInstVoltageAndCurrent() instead.
Definition at line 281 of file ACS37800.h.
|
inline |
Reads the instananeous power measurement (PINSTANT) from the sensor and returns its value converted to milliwatts (mW).
Definition at line 214 of file ACS37800.h.
|
inline |
Reads the instantaneous voltage and current measurements from the sensor (VCODES and ICODES), converts them to mV and mA respectively, and stores them in the instVoltageMillivolts and instCurrentMilliamps members.
Definition at line 203 of file ACS37800.h.
|
inline |
Reads the instantaneous voltage measurement from the sensor, and returns its value converted to millivolts (mV).
If you need the current and the voltage, it is more efficient to use readInstVoltageAndCurrent() instead.
Definition at line 270 of file ACS37800.h.
|
inline |
Reads the reactive (imaginary) power from the sensor and returns its value converted to milliwatts.
If you need the active and reactive power, it is better to use readActiveAndReactivePower().
Definition at line 259 of file ACS37800.h.
|
inline |
Reads a sensor register and returns its value.
Definition at line 305 of file ACS37800.h.
|
inline |
Reads the root mean square (RMS) current measurement from the sensor and returns its value converted to millivolts (mV).
If you need the current and the voltage, it is more efficient to use readRMSVoltageAndCurrent() instead.
Definition at line 237 of file ACS37800.h.
|
inline |
Reads the root mean square (RMS) voltage and current measurements from the sensor, converts them to mV and mA respectively, and stores them in the rmsVoltageMillivolts and rmsCurrentMilliamps members.
Definition at line 168 of file ACS37800.h.
|
inline |
Reads the root mean square (RMS) voltage measurement from the sensor and returns its value converted to millivolts (mV).
If you need the current and the voltage, it is more efficient to use readRMSVoltageAndCurrent() instead.
Definition at line 226 of file ACS37800.h.
|
inline |
Configures this object to use the specified 7-bit I2C address. This must match the address that the ACS37800 is configured to use, which is a function of its EEPROM settings and its DIO_0 and DIO_1 connections.
Definition at line 49 of file ACS37800.h.
|
inline |
Configures this object to use the right calculation paramters for a generic board.
If you're using a Pololu board, use setBoardPololu() instead of this function to save a significant amount of program space.
The isense_range parameter should be the current sensing range of the ACS37800 IC in units of amps, which depends on the specific part number of the chip and is specified in the datasheet. Typical values are 15, 30, and 90.
The riso parameter is the resistance between the ACS37800's VINN pin and the negative voltage sensing terminal of the board, plus the resistance between the ACS37800's VINP pin and the positive voltage sensing terminal of the board, in ohms.
The rsense parameter is the resistance between the ACS37800's voltage sensing pins, VINN and VINP, in ohms.
Definition at line 120 of file ACS37800.h.
|
inline |
Configures this object to use the right calculation parameters for a Pololu ACS37800 isolated power monitor carrier board.
The rsense_kohm
argument should be the Rsense value of your board, in units of kilohms, which depends on the jumper settings of your board. See the "Voltage measurement ranges" section of your board's product page to determine the Rsense value. Valid values are 1, 2, and 4.
Definition at line 74 of file ACS37800.h.
|
inline |
Configures this object to use the specified I2C bus. The default bus is Wire, which is typically the first or only I2C bus on an Arduino. To use Wire1 instead, you can write:
bus | A pointer to a TwoWire object representing the I2C bus to use. |
Definition at line 33 of file ACS37800.h.
|
inline |
Configures the sensor to use the specified number of samples for RMS and power calculations. Samples are taken at 32 kHz. The count should be a number between 0 and 1023. 1, 2, and 3 are treated the same as 4 by the ACS37800. 0 means to take samples from one voltage zero crossing to the next, instead of taking a fixed number of samples. This function only reads and writes from the shadow registers, not EEPROM, so the settings it applies will not be stored permanently.
Definition at line 148 of file ACS37800.h.
|
inline |
Sets the 7-bit I2C device address of the sensor by writing it to EEPROM.
The new address does not take effect until the sensor is power cycled.
After this function successfully returns, the ACS37800 will take about 25 ms to write to EEPROM, and further communication during that time will not succeed (register reads return 0).
Definition at line 294 of file ACS37800.h.
|
inline |
Writes to a sensor register.
Definition at line 327 of file ACS37800.h.
int32_t ACS37800::activePowerMilliwatts |
Definition at line 347 of file ACS37800.h.
int32_t ACS37800::apparentPowerMilliwatts |
Definition at line 349 of file ACS37800.h.
uint16_t ACS37800::icodesMult = 1 |
Definition at line 338 of file ACS37800.h.
uint8_t ACS37800::icodesShift = 0 |
Definition at line 339 of file ACS37800.h.
int32_t ACS37800::instCurrentMilliamps |
Definition at line 342 of file ACS37800.h.
int32_t ACS37800::instPowerMilliwatts |
Definition at line 343 of file ACS37800.h.
int32_t ACS37800::instVoltageMillivolts |
Definition at line 341 of file ACS37800.h.
uint16_t ACS37800::pinstantMult = 1 |
Definition at line 338 of file ACS37800.h.
uint8_t ACS37800::pinstantShift = 0 |
Definition at line 339 of file ACS37800.h.
int32_t ACS37800::reactivePowerMilliwatts |
Definition at line 348 of file ACS37800.h.
int32_t ACS37800::rmsCurrentMilliamps |
Definition at line 346 of file ACS37800.h.
int32_t ACS37800::rmsVoltageMillivolts |
Definition at line 345 of file ACS37800.h.
uint16_t ACS37800::vcodesMult = 1 |
Definition at line 338 of file ACS37800.h.
uint8_t ACS37800::vcodesShift = 0 |
Definition at line 339 of file ACS37800.h.