@@ -52,7 +52,7 @@ the processor should be as stable as possible.
52
52
That improves the stability of the midpoint and minimizes the noise.
53
53
54
54
55
- #### Resolution
55
+ ### Resolution
56
56
57
57
| Sensor | mVperA | LSB 10bit | LSB 12bit | LSB 16bit |
58
58
| :---------| :--------:| :-----------:| :-----------:| :-----------:|
@@ -71,7 +71,7 @@ could be obtained with such an ADC. It triggered the experimental supporting
71
71
of external ADC's with this library.
72
72
73
73
74
- #### Calibration and accuracy
74
+ ### Calibration and accuracy
75
75
76
76
The library has no means to calibrate the output or use an offset.
77
77
However sort of calibrating can relatively easy be done by using
@@ -81,7 +81,7 @@ MultiMap approaches a non-linear mapping by multiple linear mappings.
81
81
See https://github.com/RobTillaart/MultiMap .
82
82
83
83
84
- #### Tests
84
+ ### Tests
85
85
86
86
The library is at least confirmed to work with the following boards:
87
87
@@ -124,7 +124,7 @@ If you have tested a compatible sensor, please share your experiences.
124
124
(can be done by opening an issue to update documentation)
125
125
126
126
127
- #### Resolution ACS758
127
+ ### Resolution ACS758
128
128
129
129
Not tested, but looks compatible - same formula as above
130
130
@@ -147,7 +147,7 @@ Not tested, but looks compatible - same formula as above
147
147
```
148
148
149
149
150
- #### Base
150
+ ### Base
151
151
152
152
- ** ACS712(uint8_t analogPin, float volts = 5.0, uint16_t maxADC = 1023, float mVperAmpere = 100)** constructor.
153
153
It defaults a 20 A type sensor, which is defined by the default value of mVperAmpere. See table below.
@@ -177,7 +177,7 @@ A negative value indicates the current flows in the opposite direction.
177
177
- 0.3.9 calls yield() every 2nd iteration to improve behaviour under RTOS.
178
178
179
179
180
- #### mA_AC_sampling performance trick.
180
+ ### mA_AC_sampling performance trick.
181
181
182
182
A trick to sample faster is to set the frequency to 2 times the actual frequency so to 100 or 120 Hz.
183
183
This results in sampling only half a period and the same current will be measured.
@@ -194,7 +194,7 @@ Use with care!
194
194
See - https://github.com/RobTillaart/ACS712/issues/38
195
195
196
196
197
- #### Midpoint
197
+ ### Midpoint
198
198
199
199
The midpoint is the (raw) zero-reference for all current measurements.
200
200
It is defined in steps of the ADC and is typical around half the ** maxADC** value defined
@@ -244,7 +244,7 @@ So **autoMidPoint()** can help to detect voltage deviations for the ACS712.
244
244
The library does not support this yet.
245
245
246
246
247
- #### Form factor
247
+ ### Form factor
248
248
249
249
The form factor is also known as the ** crest factor** .
250
250
It is only used for signals measured with ** mA_AC()** .
@@ -277,7 +277,7 @@ float formFactor = 2.0 * mA_AC_sampling() / ACS.mA_peak2peak();
277
277
See - ACS712_20_determine_form_factor.ino
278
278
279
279
280
- #### Noise
280
+ ### Noise
281
281
282
282
Default = 21 mV (datasheet)
283
283
@@ -299,7 +299,7 @@ software noise detection and suppression is needed.
299
299
- ** void suppressNoise(bool flag)** experimental noise suppression.
300
300
301
301
302
- #### mV per Ampere
302
+ ### mV per Ampere
303
303
304
304
Used for both for AC and DC measurements.
305
305
Its value is defined in the constructor and depends on type sensor used.
@@ -311,7 +311,7 @@ These functions allow to adjust this setting run-time.
311
311
Typical values see "Resolution" section above, and the "voltage divider" section below.
312
312
313
313
314
- #### Frequency detection
314
+ ### Frequency detection
315
315
316
316
Experimental functionality for AC signal only!
317
317
@@ -332,7 +332,7 @@ Testing with my UNO I got a factor 0.9986.
332
332
Current version is experimental and not performance optimized.
333
333
334
334
335
- #### setADC (experimental 0.3.4)
335
+ ### setADC (experimental 0.3.4)
336
336
337
337
- ** void setADC(uint16_t (\* )(uint8_t), float volts, uint16_t maxADC)** sets the ADC function and the parameters of the used ADC.
338
338
The library uses the internal ** analogRead()** as default.
@@ -395,6 +395,7 @@ These ADC's are perfect both **mA-DC()** and **mA-AC()**.
395
395
## Voltage divider
396
396
397
397
As per issue #15 in which an ACS712 was connected via a voltage divider to the ADC of an ESP32.
398
+ Idem issue #43 with an ACS712 (5A) to a bare ESP8266 (1V ADC!).
398
399
399
400
Schema
400
401
```
@@ -411,18 +412,44 @@ By adjusting the mV per Ampere with **setmVperAmp(float mva)** the readings can
411
412
for this "voltage divider effect".
412
413
413
414
414
- #### Examples:
415
+ ### Examples:
416
+
417
+
418
+ For a 5 A type sensor, 185 mV/A would be the normal value.
419
+ After using a voltage divider one need to adjust the mVperAmp.
420
+
421
+ | R1 (ACS) | R2 (GND) | voltage factor | mVperAmp corrected | notes |
422
+ | ---------:| ----------:| --------------------------------:| :-----------------------:| :--------|
423
+ | 10200 | 4745 | 4745 / (10200 + 4745) = 0.3175 | 185 \* 0.3175 = 31.75 |
424
+ | 4745 | 10200 | 10200 / (10200 + 4745) = 0.6825 | 185 \* 0.6825 = 68.25 |
425
+ | 10200 | 9800 | 9800 / (10200 + 9800) = 0.4900 | 185 \* 0.4900 = 49.00 |
426
+ | 1000 | 2200 | 2200 / (1000 + 2200) = 0.6875 | 185 \* 0.6875 = 127.19 | 5V -> 3V3 ADC
427
+ | 300 | 75 | 75 / (300 + 75) = 0.2000 | 185 \* 0.2000 = 37.00 | 5V -> 1V ADC
428
+
415
429
416
430
For a 20 A type sensor, 100 mV/A would be the normal value.
417
431
After using a voltage divider one need to adjust the mVperAmp.
418
432
419
- | R1 (ACS) | R2 (GND) | voltage factor | mVperAmp corrected |
420
- | :--------:| :---------:| :-------------------------------:| :-----------------------:|
421
- | 10200 | 4745 | 4745 / (10200 + 4745) = 0.3175 | 100 \* 0.3175 = 31.75 |
422
- | 4745 | 10200 | 10200 / (10200 + 4745) = 0.6825 | 100 \* 0.6825 = 68.25 |
423
- | 10200 | 9800 | 9800 / (10200 + 9800) = 0.4900 | 100 \* 0.4900 = 49.00 |
433
+ | R1 (ACS) | R2 (GND) | voltage factor | mVperAmp corrected | notes |
434
+ | ---------:| ----------:| --------------------------------:| :-----------------------:| :--------|
435
+ | 10200 | 4745 | 4745 / (10200 + 4745) = 0.3175 | 100 \* 0.3175 = 31.75 |
436
+ | 4745 | 10200 | 10200 / (10200 + 4745) = 0.6825 | 100 \* 0.6825 = 68.25 |
437
+ | 10200 | 9800 | 9800 / (10200 + 9800) = 0.4900 | 100 \* 0.4900 = 49.00 |
438
+ | 1000 | 2200 | 2200 / (1000 + 2200) = 0.6875 | 100 \* 0.6875 = 68.75 | 5V -> 3V3 ADC
439
+ | 300 | 75 | 75 / (300 + 75) = 0.2000 | 100 \* 0.2000 = 20.00 | 5V -> 1V ADC
424
440
425
441
442
+ For a 30 A type sensor, 66 mV/A would be the normal value.
443
+ After using a voltage divider one need to adjust the mVperAmp.
444
+
445
+ | R1 (ACS) | R2 (GND) | voltage factor | mVperAmp corrected | notes |
446
+ | ---------:| ----------:| --------------------------------:| :-----------------------:| :--------|
447
+ | 10200 | 4745 | 4745 / (10200 + 4745) = 0.3175 | 66 \* 0.3175 = 31.75 |
448
+ | 4745 | 10200 | 10200 / (10200 + 4745) = 0.6825 | 66 \* 0.6825 = 68.25 |
449
+ | 10200 | 9800 | 9800 / (10200 + 9800) = 0.4900 | 66 \* 0.4900 = 49.00 |
450
+ | 1000 | 2200 | 2200 / (1000 + 2200) = 0.6875 | 66 \* 0.6875 = 45.38 | 5V -> 3V3 ADC
451
+ | 300 | 75 | 75 / (300 + 75) = 0.2000 | 66 \* 0.2000 = 13.20 | 5V -> 1V ADC
452
+
426
453
** Note:** setting the midPoint correctly is also needed when using a voltage divider.
427
454
428
455
@@ -472,11 +499,14 @@ There is no RTOS example. If you have and willing to share you are welcome.
472
499
473
500
For people who want to use this library for ESPhome, there exists a wrapper
474
501
class for this ACS712 library.
502
+
475
503
- https://github.com/marianomd/acs712-esphome
476
504
477
505
As I do not have ESPhome know how, please share your experiences.
478
506
This can be done by an issue.
479
507
508
+ - https://github.com/RobTillaart/ACS712/issues/51
509
+
480
510
481
511
## Operation
482
512
0 commit comments