New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
P251_PZEM004Tv30_Multiple #145
Conversation
You completely deleted the Readme.md file. |
Hmm that's not what I meant. Do you need help with Git? |
OK, I put back the original readme.md file in my repositery and pull again. |
Well it looked like you deleted all files when I made my comment. |
It is based on an external library but I modify .cpp/.h to be compatible with espeasyserial and add possibility to change PZEM address dynamically. I'm gonna see how I can clarify my position with the official PZEM library (fork the library ?). |
If you look at other libraries we use, they are copied into the libs folder of the repo and some are modified. (for example pubsubclient) |
_P251_PZEM004Tv3.ino
Outdated
{ | ||
addHtml(F("Tx Pin and Rx Pin have no effect on the configuration as this PZEM is not the main configured.")); | ||
{ | ||
Device[deviceCount].Type = DEVICE_TYPE_DUMMY; //Erase GPIO choice if not first PZEM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know the device type is also used to determine the number of output values?
And the Device
vector contains the plugin definitions, not the task definitions.
This will have an effect on all instances of the same plugin on an ESP node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me, "type" only defines the number of datapin (Vtype for # of output):
#define DEVICE_TYPE_SINGLE 1 // connected through 1 datapin
#define DEVICE_TYPE_DUAL 2 // connected through 2 datapins
#define DEVICE_TYPE_TRIPLE 3 // connected through 3 datapins
Am I wrong ?
Thus how can I remove the data pin selection on other instance of the same pluggin (any example on an existing pluggin)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, you're right it is about the pins, not the values.
But still, values in that vector are for all instances of the same plugin, not per task.
If you need to spilt it, you can set it to some "no pins" value, but then you must add the pin configuration yourself in the PLUGIN_LOAD (and PLUGIN_SAVE) based on other settings of the task config.
Or you can make 2 versions of the plugin, which do share a common C++ object to communicate with the hardware.
I think you should have a single central object shared among several task instances when communicating over a shared bus.
This is also an issue for the Dallas sensors.
The Eastron plugin does just allow multiple instances as long as you set all to use the same pins. There is a shared object which does the actual communication.
But there you may want multiple task instances to collect different values, since those output way more values than the 4 we can handle on a single task.
Changes look OK. If you are done with it, I can merge it. I quickly browsed through the code and I kinda like this concept: ESPEasyPluginPlayground/_P251_PZEM004Tv3.ino Lines 204 to 216 in f93f953
But it has a drawback. If the first instance is removed (e.g. you re-order the tasks), you have to reboot in order to apply settings. @uzi18 what do you think of this idea of letting the first instance handle the init of a central handler? |
@TD-er simple how to be sure if (P251_PZEM_FIRST == event->TaskIndex) is first one? by the way I need something like first/last/count tasks for specific device for 1wire, not sure if it is already implemented |
Is not yet implemented. But that discussion can be continued on the Dallas issue I guess :) |
I didn't have time to give some comments to my changes that you already review my release. Thank for your reactivity. |
Not very optimised to use different serial interface to communicate with several PZEM when only single serial is sufficient. Don't you think ?
Prior this test, I allocate: |
You only set it at the init of this plugin with the lowest index. I think we should add a central mechanism for that, so you don't have to fix it here. |
@djelau There is solution, just use struct with pointer to P251_PZEM_sensor, rx pin and tx pin number, first task number.
to set it for every task, but you still need to set : @TD-er |
Couldn't agree more! |
used this plugin for 6 month with esp32 mega build. But since ESPEasySerial 2.0.4 its incompatible. |
I will make a fix for it, as it is quite a simple fix. |
Can you test with this PR? I've not yet added it to a build config, but I guess you could build it yourself? Here the custom builds I made to test whether it would compile. |
Hmmm just noticed the plugin did not set the Type to be |
yeah, with the my custom build I used HW1 with gpio pins 13 and 15. |
Yep, the P251 version did not really use the ESPEasySerial wrappers as intended. With David Gilmore on Youtube, headset on and nerd mode active, one may forget the time :) |
:) same timezone here. But one more hour of sleep this night. And thanks for your help & work! Good night |
Well, as it is becoming winter time, you will have an extra hour, so if you wait a few minutes I may have a new test build for you |
A new test build On ESP32 it should show something like this: (taken from some ESP32 node, not running this plugin, just showing serial config how it should look like) |
Hmm the GPIO-15 warning should not be shown on ESP32, but still that pin has some limitations. |
I'm now looking at this plugin a bit more. Why is the config split here to only allow configuration of the serial settings from the first task running this plugin, combined with warnings about using a new serial port for multiple instances? Can anyone explain this a bit more, as of why this approach was chosen? |
unfortunately I'm not the developer of this plugin and cant provide some first hand information. There is a developer manual from the manufacturer: On the other hand I'm facing some stability issues on esp32 with the latest mega release (the previous releases aswell). Is there a standard way of how to approach debuging? |
As this PR + plugin now has been moved into the main repository (see: letscontrolit/ESPEasy#3337 ) To avoid confusion, I will close this PR. |
Current PZEM004T plugin is not compatible with PZEM004Tv30 (modbus communication). It is also not compatible with commmunication with several PZEM004T on the same serial link.
Proposal is a new Plugin for new PZEM004Tv30: Voltage/current/power/energy/frequency/cos phi probe using serial Modbus communication protocol.
Features: