In the setup() function, initialize the ATM90E26 and configure the necessary settings:
cpp
void setup() {
Serial.begin(9600);
SPI.begin();
energyMeter.begin(CS_PIN);
// Configure the ATM90E26 settings
energyMeter.setMode(0b01010000); // 3P4W mode, 2 Rogowski coils, signed reactive power
energyMeter.setMeterConstant(1000); // Set the meter constant (impulses per kWh)
energyMeter.enableInterrupts(true); // Enable interrupts
}
In the loop() function, read the energy measurements from the ATM90E26 and perform any desired actions:
cpp
void loop() {
// Read energy measurements
float voltage = energyMeter.GetLineVoltage();
float current = energyMeter.GetLineCurrent();
float activePower = energyMeter.GetActivePower();
float reactivePower = energyMeter.GetReactivePower();
float apparentPower = energyMeter.GetApparentPower();
float powerFactor = energyMeter.GetPowerFactor();
float frequency = energyMeter.GetFrequency();
// Print the measurements
Serial.print("Voltage: ");
Serial.print(voltage);
Serial.println(" V");
Serial.print("Current: ");
Serial.print(current);
Serial.println(" A");
Serial.print("Active Power: ");
Serial.print(activePower);
Serial.println(" W");
Serial.print("Reactive Power: ");
Serial.print(reactivePower);
Serial.println(" VAR");
Serial.print("Apparent Power: ");
Serial.print(apparentPower);
Serial.println(" VA");
Serial.print("Power Factor: ");
Serial.println(powerFactor);
Serial.print("Frequency: ");
Serial.print(frequency);
Serial.println(" Hz");
delay(1000); // Delay for 1 second before the next measurement
}
This is a basic example of how you can use the ATM90E26 library to read energy measurements from the ATM90E26 IC. Make sure to adjust the chip select pin (CS_PIN) according to your hardware setup.
Note: The specific functions and parameters used in this example may vary depending on the version and functionality of the ATM90E26 library you are using. Refer to the library's documentation for more details on the available functions and their usage.
Remember to connect the ATM90E26 IC to your Arduino board correctly, following the appropriate wiring diagram for your specific setup.