Last active
September 28, 2017 05:19
-
-
Save andriyadi/906e60c1a6770555445d4ec9258cef90 to your computer and use it in GitHub Desktop.
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
#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