olehs / PZEM004T

Arduino communication library for Peacefair PZEM-004T Energy monitor
MIT License
225 stars 114 forks source link

Read speed #3

Closed hchahine closed 8 years ago

hchahine commented 8 years ago

Pretty sure this isn't an issue with this library but an idiosyncrasy related to the device. But I'm curious if others can confirm they get the same thing.

I'm trying to read Energy, Power, Voltage and Current every second. I've found it's not possible to do this. It's not possible to send more than a command or two per second. The device just delays the response for the second or third command so the net throughput is about 4 commands every 2.5-3 seconds.

For example, In my testing any single command/reply pair takes only about 15-20ms if issued on it's own (i.e. more than a second apart). If a second command is issued direcly after the reply of the first, the second command/reply pair might take 800ms or so.

olehs commented 8 years ago

Yes, this is specific for this device. You can read no more than 2 parameters in one second. There is readTimeout parameter in the library which is 1000ms by default. With this device I wouldn't recommend to set readTimeout lower that 1s, because it won't give you desired result.