Skip to content

Instantly share code, notes, and snippets.

@andriyadi
Last active September 28, 2017 05:19
Show Gist options
  • Save andriyadi/906e60c1a6770555445d4ec9258cef90 to your computer and use it in GitHub Desktop.
Save andriyadi/906e60c1a6770555445d4ec9258cef90 to your computer and use it in GitHub Desktop.
#include <Arduino.h>
#include <energyic_UART.h>
#define RX_PIN 19
#define TX_PIN 23
HardwareSerial ATMSerial(1);
ATM90E26_UART eic(&ATMSerial);
void setup() {
initArduino();
Serial.begin(115200);
ESP_LOGI("APP", "It begins!");
ATMSerial.begin(9600, SERIAL_8N1, RX_PIN, TX_PIN);
delay(100);
eic.InitEnergyIC();
delay(1000);
}
void loop() {
/*Repeatedly fetch some values from the ATM90E26 */
Serial.print("Sys Status:");
unsigned short s_status = eic.GetSysStatus();
if(s_status == 0xFFFF)
{
Serial.println("Status FAILED");
return;
}
Serial.println(eic.GetSysStatus(),HEX);
delay(10);
Serial.print("Meter Status:");
Serial.println(eic.GetMeterStatus(),HEX);
delay(10);
Serial.print("Freq:");
Serial.println(eic.GetFrequency());
delay(10);
Serial.print("Current:");
Serial.println(eic.GetLineCurrent());
delay(10);
Serial.print("Active power:");
Serial.println(eic.GetActivePower());
delay(10);
Serial.print("p.f.:");
Serial.println(eic.GetPowerFactor());
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment