PEVMAC2C problems

Hi, I’m trying to get a PEVMAC2c voltage monitor to work with no results. I have gotten a PECMAC current monitor to work. So not sure if I’m having a Hardware Problem or Soft ware. Thanks

Could you share the code you are using to read voltage?
Thanks

I just saw on another post to try this one. I understand it may need modified for voltage monitor. I have it working on a current monitor and it is working fine. Thanks for your help

// Distributed with a free-will license.
2 // Use it any way you want, profit or free, provided it fits in the licenses of its associated works.
3 // PECMAC125A
4 // This code is designed to work with the PECMAC125A_DLCT03C20 I2C Mini Module available from ControlEverything.com.
5 // https://www.controleverything.com/content/Current?sku=PECMAC125A_DLCT03C20#tabs-0-product_tabset-2
6

7 #include <spark_wiring_i2c.h>
8 #include <application.h>
9

10 // PECMAC125A I2C address is 0x2A(42)
11 #define Addr 0x2A
12

13 unsigned int data[36];
14 int typeOfSensor = 0;
15 int maxCurrent = 0;
16 int noOfChannel = 0;
17 double current = 0.0;
18 void setup()
19 {
20 // Set variable
21 Particle.variable(“i2cdevice”, “PECMAC125A”);
22 Particle.variable(“typeOfSensor”, typeOfSensor);
23 Particle.variable(“maxCurrent”, maxCurrent);
24 Particle.variable(“noOfChannel”, noOfChannel);
25 Particle.variable(“Current”, current);
26

27 // Initialise I2C communication as MASTER
28 Wire.begin();
29 // Initialise Serial Communication, set baud rate = 9600
30 Serial.begin(9600);
31

32 // Start I2C transmission
33 Wire.beginTransmission(Addr);
34 // Command header byte-1
35 Wire.write(0x92);
36 // Command header byte-2
37 Wire.write(0x6A);
38 // Command 2 is used to read no of sensor type, Max current, No. of channel
39 Wire.write(0x02);
40 // Reserved
41 Wire.write(0x00);
42 // Reserved
43 Wire.write(0x00);
44 // Reserved
45 Wire.write(0x00);
46 // Reserved
47 Wire.write(0x00);
48 // CheckSum
49 Wire.write(0xFE);
50 // Stop I2C transmission
51 Wire.endTransmission();
52

53 // Request 6 bytes of data
54 Wire.requestFrom(Addr, 6);
55

56 // Read 6 bytes of data
57 if (Wire.available() == 6)
58 {
59 data[0] = Wire.read();
60 data[1] = Wire.read();
61 data[2] = Wire.read();
62 data[3] = Wire.read();
63 data[4] = Wire.read();
64 data[5] = Wire.read();
65 }
66 typeOfSensor = data[0];
67 maxCurrent = data[1];
68 noOfChannel = data[2];
69

70 // Output data to dashboard
71 Particle.publish("Type Of Sensor : ", String(typeOfSensor));
72 delay(1000);
73 Particle.publish("Max Current : ", String(maxCurrent));
74 delay(1000);
75 Particle.publish("No. Of Channel : ", String(noOfChannel));
76 delay(1000);
77 }
78

79 void loop()
80 {
81 for (int j = 1; j < noOfChannel + 1; j++)
82 {
83 // Start I2C Transmission
84 Wire.beginTransmission(Addr);
85 // Command header byte-1
86 Wire.write(0x92);
87 // Command header byte-2
88 Wire.write(0x6A);
89 // Command 1
90 Wire.write(0x01);
91 // Start Channel No.
92 Wire.write(j);
93 // End Channel No.
94 Wire.write(j);
95 // Reserved
96 Wire.write(0x00);
97 // Reserved
98 Wire.write(0x00);
99 // CheckSum
100 Wire.write((0x92 + 0x6A + 0x01 + j + j + 0x00 + 0x00) & 0xFF);
101 // Stop I2C Transmission
102 Wire.endTransmission();
103 delay(500);
104

105 // Request 3 bytes of data
106 Wire.requestFrom(Addr, 3);
107

108 // Read 3 bytes of data
109 // msb1, msb, lsb
110 int msb1 = Wire.read();
111 int msb = Wire.read();
112 int lsb = Wire.read();
113 current = (msb1 * 65536) + (msb * 256) + lsb;
114

115 // Convert the data to ampere
116 current = current / 1000;
117

118 // Output data to dashboard
119 Particle.publish("Channel : ", String(j));
120 delay(1000);
121 Particle.publish("Current Value : ", String(current));
122 delay(1000);
123 }
124 }

I just saw on another post to try this one. I understand it may need modified for voltage monitor. I have it working on a current monitor and it is working fine. Thanks for your help

// Distributed with a free-will license.
2 // Use it any way you want, profit or free, provided it fits in the licenses of its associated works.
3 // PECMAC125A
4 // This code is designed to work with the PECMAC125A_DLCT03C20 I2C Mini Module available from ControlEverything.com.
5 // https://www.controleverything.com/content/Current?sku=PECMAC125A_DLCT03C20#tabs-0-product_tabset-2
6

7 #include <spark_wiring_i2c.h>
8 #include <application.h>
9

10 // PECMAC125A I2C address is 0x2A(42)
11 #define Addr 0x2A
12

13 unsigned int data[36];
14 int typeOfSensor = 0;
15 int maxCurrent = 0;
16 int noOfChannel = 0;
17 double current = 0.0;
18 void setup()
19 {
20 // Set variable
21 Particle.variable(“i2cdevice”, “PECMAC125A”);
22 Particle.variable(“typeOfSensor”, typeOfSensor);
23 Particle.variable(“maxCurrent”, maxCurrent);
24 Particle.variable(“noOfChannel”, noOfChannel);
25 Particle.variable(“Current”, current);
26

27 // Initialise I2C communication as MASTER
28 Wire.begin();
29 // Initialise Serial Communication, set baud rate = 9600
30 Serial.begin(9600);
31

32 // Start I2C transmission
33 Wire.beginTransmission(Addr);
34 // Command header byte-1
35 Wire.write(0x92);
36 // Command header byte-2
37 Wire.write(0x6A);
38 // Command 2 is used to read no of sensor type, Max current, No. of channel
39 Wire.write(0x02);
40 // Reserved
41 Wire.write(0x00);
42 // Reserved
43 Wire.write(0x00);
44 // Reserved
45 Wire.write(0x00);
46 // Reserved
47 Wire.write(0x00);
48 // CheckSum
49 Wire.write(0xFE);
50 // Stop I2C transmission
51 Wire.endTransmission();
52

53 // Request 6 bytes of data
54 Wire.requestFrom(Addr, 6);
55

56 // Read 6 bytes of data
57 if (Wire.available() == 6)
58 {
59 data[0] = Wire.read();
60 data[1] = Wire.read();
61 data[2] = Wire.read();
62 data[3] = Wire.read();
63 data[4] = Wire.read();
64 data[5] = Wire.read();
65 }
66 typeOfSensor = data[0];
67 maxCurrent = data[1];
68 noOfChannel = data[2];
69

70 // Output data to dashboard
71 Particle.publish("Type Of Sensor : ", String(typeOfSensor));
72 delay(1000);
73 Particle.publish("Max Current : ", String(maxCurrent));
74 delay(1000);
75 Particle.publish("No. Of Channel : ", String(noOfChannel));
76 delay(1000);
77 }
78

79 void loop()
80 {
81 for (int j = 1; j < noOfChannel + 1; j++)
82 {
83 // Start I2C Transmission
84 Wire.beginTransmission(Addr);
85 // Command header byte-1
86 Wire.write(0x92);
87 // Command header byte-2
88 Wire.write(0x6A);
89 // Command 1
90 Wire.write(0x01);
91 // Start Channel No.
92 Wire.write(j);
93 // End Channel No.
94 Wire.write(j);
95 // Reserved
96 Wire.write(0x00);
97 // Reserved
98 Wire.write(0x00);
99 // CheckSum
100 Wire.write((0x92 + 0x6A + 0x01 + j + j + 0x00 + 0x00) & 0xFF);
101 // Stop I2C Transmission
102 Wire.endTransmission();
103 delay(500);
104

105 // Request 3 bytes of data
106 Wire.requestFrom(Addr, 3);
107

108 // Read 3 bytes of data
109 // msb1, msb, lsb
110 int msb1 = Wire.read();
111 int msb = Wire.read();
112 int lsb = Wire.read();
113 current = (msb1 * 65536) + (msb * 256) + lsb;
114

115 // Convert the data to ampere
116 current = current / 1000;
117

118 // Output data to dashboard
119 Particle.publish("Channel : ", String(j));
120 delay(1000);
121 Particle.publish("Current Value : ", String(current));
122 delay(1000);
123 }
124 }

this code can be used to read voltage