PZEM-004T V3.0 Energy Monitor Module Arduino (A to Y) see Edit below.
6 هزار بار بازدید -
2 سال پیش
-
Connection, Change Address, Single and
Connection, Change Address, Single and Multiple Devices
PS (Edit):
1) Multiple Pzems on Single Serial are limited to 4 or 5. Due to power limitation on each pin. However someone has tried to remove LEDs on pzem to decrease power consumption and increase number of Pzems. Another Solution is to use multiple Serial Ports (Hardware or Software).
2) I changed Pzem Address , connecting individualy. Also reported by a user, address change sketech give problems if multiple Pzems are connected
Multiple Pzems Code:
Step 1:
. Change PZems Addresses in sequence like 0x10, 0x11, 0x12 etc
. Use "Change Address" Code from Examples
. Each Pzem Need to have Separate Address
The Code:
#include PZEM004Tv30.h // PZEM004Tv30.h Enclose in Angle Brackets Else it will not work
#define PZEM_SERIAL Serial2
#define NUM_PZEMS 4
PZEM004Tv30 pzems[NUM_PZEMS];
float pzemVolt[NUM_PZEMS -1];
float pzemWatts[NUM_PZEMS -1];
void setup() {
//Declaring Pzem Serial Port & Address
for(int i = 0; i == NUM_PZEMS -1; i++) {
//Starting Address 0x10 , Assumption Address of All Pzem are in Sequence like 0x10, 0x11 0x12 etc
pzems[i] = PZEM004Tv30(PZEM_SERIAL, 16, 17, 0x10 + i);
}
}
void loop() {
//Read Individual
pzemVolt[0] = pzems[0].voltage();
if (isnan(pzemVolt[0])){ pzemVolt[0] = 0; }
pzemWatts[0] = pzems[0].power();
if (isnan(pzemWatts[0])){ pzemWatts[0] = 0; }
//Read Multiple
for(int i = 1; i == NUM_PZEMS - 1; i++) {
pzemVolt[i] = pzems[i].voltage();
if (isnan(pzemVolt[i])) {pzemVolt[i] = 0; }
pzemWatts[i] = pzems[i].power();
if (isnan(pzemWatts[i])) {pzemWatts[i] = 0; }
}
delay(3000);
}
//Code Ends
00:00 - Intro
00:35 - Library
01:57 - Wiring
03:30 - TiP: RS485
06:00 - Change Address
14:15 - AC Current Necessary
16:00 - Read Power Data
18:50 - Multiple Devices
PS (Edit):
1) Multiple Pzems on Single Serial are limited to 4 or 5. Due to power limitation on each pin. However someone has tried to remove LEDs on pzem to decrease power consumption and increase number of Pzems. Another Solution is to use multiple Serial Ports (Hardware or Software).
2) I changed Pzem Address , connecting individualy. Also reported by a user, address change sketech give problems if multiple Pzems are connected
Multiple Pzems Code:
Step 1:
. Change PZems Addresses in sequence like 0x10, 0x11, 0x12 etc
. Use "Change Address" Code from Examples
. Each Pzem Need to have Separate Address
The Code:
#include PZEM004Tv30.h // PZEM004Tv30.h Enclose in Angle Brackets Else it will not work
#define PZEM_SERIAL Serial2
#define NUM_PZEMS 4
PZEM004Tv30 pzems[NUM_PZEMS];
float pzemVolt[NUM_PZEMS -1];
float pzemWatts[NUM_PZEMS -1];
void setup() {
//Declaring Pzem Serial Port & Address
for(int i = 0; i == NUM_PZEMS -1; i++) {
//Starting Address 0x10 , Assumption Address of All Pzem are in Sequence like 0x10, 0x11 0x12 etc
pzems[i] = PZEM004Tv30(PZEM_SERIAL, 16, 17, 0x10 + i);
}
}
void loop() {
//Read Individual
pzemVolt[0] = pzems[0].voltage();
if (isnan(pzemVolt[0])){ pzemVolt[0] = 0; }
pzemWatts[0] = pzems[0].power();
if (isnan(pzemWatts[0])){ pzemWatts[0] = 0; }
//Read Multiple
for(int i = 1; i == NUM_PZEMS - 1; i++) {
pzemVolt[i] = pzems[i].voltage();
if (isnan(pzemVolt[i])) {pzemVolt[i] = 0; }
pzemWatts[i] = pzems[i].power();
if (isnan(pzemWatts[i])) {pzemWatts[i] = 0; }
}
delay(3000);
}
//Code Ends
00:00 - Intro
00:35 - Library
01:57 - Wiring
03:30 - TiP: RS485
06:00 - Change Address
14:15 - AC Current Necessary
16:00 - Read Power Data
18:50 - Multiple Devices
2 سال پیش
در تاریخ 1401/03/08 منتشر شده
است.
6,090
بـار بازدید شده