-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
147 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
examples/ACS712_20_DC_external_ADC/ACS712_20_DC_external_ADC.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// | ||
// FILE: ACS712_20_DC_external_ADC.ino | ||
// AUTHOR: Rob Tillaart | ||
// PURPOSE: demo to measure mA DC with external ADC | ||
// URL: https://github.com/RobTillaart/ACS712 | ||
|
||
// use with Arduino Serial Plotter | ||
|
||
#include "ACS712.h" | ||
|
||
|
||
// Arduino UNO has 5.0 volt with a max ADC value of 1023 steps | ||
// ACS712 5A uses 185 mV per A | ||
// ACS712 20A uses 100 mV per A | ||
// ACS712 30A uses 66 mV per A | ||
|
||
|
||
ACS712 ACS(A0, 5.0, 1023, 100); | ||
// ESP 32 example (might requires resistors to step down the logic voltage) | ||
// ACS712 ACS(25, 3.3, 4095, 185); | ||
|
||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
while (!Serial); | ||
Serial.println(__FILE__); | ||
Serial.print("ACS712_LIB_VERSION: "); | ||
Serial.println(ACS712_LIB_VERSION); | ||
|
||
ACS.setADC(testADC, 10, 1023); | ||
|
||
// ACS.autoMidPoint(); | ||
// Serial.println(ACS.getMidPoint()); | ||
} | ||
|
||
|
||
void loop() | ||
{ | ||
int mA = ACS.mA_DC(); | ||
Serial.println(mA); | ||
delay(1000); | ||
} | ||
|
||
// wrapper needed for external analogRead() | ||
// as casting behavior is undefined between different function signatures. | ||
uint16_t testADC(uint8_t p) | ||
{ | ||
// simulation | ||
return 600 + p; | ||
// replace with an external ADC call. | ||
// return ADS.readADC(p); | ||
// return analogRead(p + 1); // use another internal ADC | ||
} | ||
|
||
|
||
// -- END OF FILE -- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name=ACS712 | ||
version=0.3.3 | ||
version=0.3.4 | ||
author=Rob Tillaart <[email protected]>, Pete Thompson <[email protected]> | ||
maintainer=Rob Tillaart <[email protected]> | ||
sentence=ACS712 library for Arduino. | ||
|