-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample02_DualChannelCurrent.ino
More file actions
72 lines (55 loc) · 2.14 KB
/
Copy pathExample02_DualChannelCurrent.ino
File metadata and controls
72 lines (55 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
Example 02 - Dual Channel Current
Reads the RMS current from both Channel A and Channel B and prints them side by side.
Channel A is the primary CT clamp input on the Qwiic connector. Channel B is available
via the optional pinout headers on the board.
begin() configures default gain on both channels for you, so this sketch just reads
the current in amps from each channel.
SparkFun Electronics
Date: 2025
SparkFun code, firmware, and software is released under the MIT License.
Please see LICENSE.md for further details.
Hardware Connections:
IoT RedBoard --> ADE7953
QWIIC --> QWIIC
(Optional) Current source --> Channel B header pins
Open the Serial Monitor at 115200 baud.
Feel like supporting our work? Buy a board from SparkFun!
https://www.sparkfun.com/sparkfun-qwiic-current-sensor.html
*/
#include <SparkFun_ADE7953.h>
SfeADE7953ArdI2C mySensor;
void setup()
{
Serial.begin(115200);
Serial.println("SparkFun ADE7953 Example 2 - Dual Channel Current");
Wire.begin();
while (mySensor.begin() == false)
{
Serial.println("ADE7953 not connected, check your wiring!");
delay(1000);
}
Serial.println("ADE7953 connected!");
// Tell the library which clamp is attached so the amps conversion is correct. Each channel can
// be configured independently. Here Channel A uses a 2000:1 clamp, while Channel B measures
// directly (turns ratio 1:1, no current transformer).
//
// To use the same clamp on both channels, call mySensor.setCurrentClamp(ADE7953_CLAMP_ECS1030).
mySensor.setCurrentClampA(ADE7953_CLAMP_ECS1030); // Channel A: SparkFun ECS1030-L72 (2000:1)
mySensor.setCurrentTransformerRatioB(1.0f); // Channel B: direct measurement (1:1)
Serial.println();
Serial.println("Channel A (A)\tChannel B (A)");
Serial.println("-------------\t-------------");
}
void loop()
{
// Read the RMS current from both channels in amps.
float ampsA = 0.0;
float ampsB = 0.0;
mySensor.getCurrentA(ampsA);
mySensor.getCurrentB(ampsB);
Serial.print(ampsA, 4);
Serial.print("\t\t");
Serial.println(ampsB, 4);
delay(500);
}