File tree 3 files changed +16
-4
lines changed
3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -24,15 +24,22 @@ void setup() {
24
24
25
25
void loop () {
26
26
/* Repeatedly fetch some values from the ATM90E26 */
27
- Serial.print (" Status:" );
28
- Serial.println (GetSysStatus ());
27
+ Serial.print (" Sys Status:" );
28
+ Serial.println (GetSysStatus (),HEX);
29
+ delay (10 );
30
+ Serial.print (" Meter Status:" );
31
+ Serial.println (GetMeterStatus (),HEX);
32
+ delay (10 );
29
33
Serial.print (" Voltage:" );
30
34
Serial.println (GetLineVoltage ());
35
+ delay (10 );
31
36
Serial.print (" Current:" );
32
37
Serial.println (GetLineCurrent ());
38
+ delay (10 );
33
39
Serial.print (" Active power:" );
34
40
Serial.println (GetActivePower ());
41
+ delay (10 );
35
42
Serial.print (" p.f.:" );
36
43
Serial.println (GetPowerFactor ());
37
- delay (500 );
44
+ delay (1000 );
38
45
}
Original file line number Diff line number Diff line change @@ -84,5 +84,6 @@ double GetImportEnergy();
84
84
double GetExportEnergy ();
85
85
void InitEnergyIC ();
86
86
unsigned short GetSysStatus ();
87
+ unsigned short GetMeterStatus ();
87
88
88
89
#endif
Original file line number Diff line number Diff line change 20
20
unsigned char * data=(unsigned char *)&val;
21
21
unsigned short output;
22
22
// SPI interface rate is 200 to 160k bps. It Will need to be slowed down for EnergyIC
23
- SPISettings settings (2000000 , MSBFIRST, SPI_MODE2 );
23
+ SPISettings settings (200000 , MSBFIRST, SPI_MODE3 );
24
24
25
25
// switch MSB and LSB of value
26
26
output=(val>>8 )|(val<<8 );
@@ -71,6 +71,10 @@ double GetLineVoltage(){
71
71
return (double )voltage/100 ;
72
72
}
73
73
74
+ unsigned short GetMeterStatus (){
75
+ return CommEnergyIC (1 ,EnStatus,0xFFFF );
76
+ }
77
+
74
78
double GetLineCurrent (){
75
79
unsigned short current=CommEnergyIC (1 ,Irms,0xFFFF );
76
80
return (double )current/1000 ;
You can’t perform that action at this time.
0 commit comments