mandulaj / PZEM-004T-v30

Arduino library for the Updated PZEM-004T v3.0 Power and Energy meter
MIT License
256 stars 108 forks source link

Use programmable slave addresses #38

Closed SmilingDromedar closed 3 years ago

SmilingDromedar commented 3 years ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like To monitor my solar panels, I need 5 PZEM as slaves. With the old library from [@olehs] it war possible. Why I can set the slaveAdress, if I can't use it?

Describe alternatives you've considered I can use 5 Arduinos with SD-Card for ever Panel. Or I use the old PZEM004T. With this I have implemented three phase monitoring. Additional context Add any other context or screenshots about the feature request here.

SmilingDromedar commented 3 years ago

The problem is solved after 2h studying the library source. If the slaveAddress is set, no slaveAddress may be set for the function ( PZEM004Tv30 pzem(6, 5) ). In this case every available slave is addressed (default Address 0xF8). Then the address is set ( pzem.setAddress(addr) ). When querying the data, a function with the address is opened for each PZEM module. ( PZEM004Tv30 pzem01(6, 5, addr1), PZEM004Tv30 pzem02(6, 5, addr2), PZEM004Tv30 pzem03(6, 5, addr3); ). Retrieving the data: ( float voltage1 = pzem01.voltage(); float voltage2 = pzem02.voltage(); float voltage3 = pzem03.voltage(); )

PZEMv30-Test-02.txt