Skip to content

v1.0.4 #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
Library for the Allegro MicroSystems ACS37800 power monitor IC
By: Paul Clark
SparkFun Electronics
Date: December 4th, 2021
License: please see LICENSE.md for details

Feel like supporting our work? Buy a board from SparkFun!
https://www.sparkfun.com/products/17873
*/

#include "SparkFun_ACS37800_Arduino_Library.h" // Click here to get the library: http://librarymanager/All#SparkFun_ACS37800
#include <Wire.h>

ACS37800 mySensor; //Create an object of the ACS37800 class

void setup()
{
Serial.begin(115200);
Serial.println(F("ACS37800 Example"));

Wire.begin();

//mySensor.enableDebugging(); // Uncomment this line to print useful debug messages to Serial

//Initialize sensor using default I2C address
if (mySensor.begin() == false)
{
Serial.print(F("ACS37800 not detected. Check connections and I2C address. Freezing..."));
while (1)
; // Do nothing more
}

// From the ACS37800 datasheet:
// CONFIGURING THE DEVICE FOR AC APPLICATIONS : DYNAMIC CALCULATION OF N
// Set bypass_n_en = 0 (default). This setting enables the device to
// dynamically calculate N based off the voltage zero crossings.
mySensor.setBypassNenable(false, false); // Disable bypass_n in shadow memory and eeprom

// We need to connect the LO pin to the 'low' side of the AC source.
// So we need to set the divider resistance to 4M Ohms (instead of 2M).
mySensor.setDividerRes(4000000);
}

void loop()
{
float volts = 0.0;
float amps = 0.0;

mySensor.readRMS(&volts, &amps); // Read the RMS voltage and current
Serial.print(F("Volts: "));
Serial.print(volts, 2);
Serial.print(F(" Amps: "));
Serial.println(amps, 2);

delay(250);
}
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SparkFun ACS37800 Power Monitor Arduino Library
version=1.0.3
version=1.0.4
author=SparkFun Electronics
maintainer=SparkFun Electronics
sentence=Library for the Allegro MicroSystems ACS37800 power monitor IC
Expand Down
2 changes: 1 addition & 1 deletion src/SparkFun_ACS37800_Arduino_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ ACS37800ERR ACS37800::readRMS(float *vRMS, float *iRMS)
_debugPort->print(F("readRMS: amps (A, before correction) is "));
_debugPort->println(amps);
}
amps /= 27500.0; //Convert from codes to the fraction of ADC Full Scale (15-bit)
amps /= 55000.0; //Convert from codes to the fraction of ADC Full Scale (16-bit)
amps *= _currentSensingRange; //Convert to Amps
if (_printDebug == true)
{
Expand Down