olehs / PZEM004T

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

commit b7c55247e84e77d1f5da757f6094254a59d74d78 breaks the library for ESP's #14

Closed pieman64 closed 7 years ago

pieman64 commented 7 years ago

@olehs the commit you made on the 30th of April for PZEM004.cpp of:

line 136 if(_isSoft) line 137 ((SoftwareSerial *)serial)->listen();

stops compilation of your library on ESP's.

What does the commit do and can we simply revert back to the earlier cpp?

The compiler error for ESP's with the 2 lines included is:

C:\Users\Public\NewArduinoSketchesAndLibraries\libraries\PZEM004T-master\PZEM004T.cpp: In member function 'bool PZEM004T::recieve(uint8_t, uint8_t*)':

C:\Users\Public\NewArduinoSketchesAndLibraries\libraries\PZEM004T-master\PZEM004T.cpp:137:37: error: 'class SoftwareSerial' has no member named 'listen'

         ((SoftwareSerial *)serial)->listen();
olehs commented 7 years ago

You could try using this library or just revert to previous version. This commit allows to use multiple PZEMs at once with one Arduino. Default Arduino's SoftwareSerial supports multiple instances and I don't know why ESP's one doesn't,

olehs commented 7 years ago

BTW, looks like library I specified in my previous comment is just the default library of ESP for Arduino. Maybe you just need to update your ESP8266 libraries?

pieman64 commented 7 years ago

@olehs I will check through your comments. Do you not use the PZEM with an ESP?

olehs commented 7 years ago

No, I use it with Arduino Mega and Ethernet shield. I actually prefer wired solutions )

pieman64 commented 7 years ago

I thought as much because I don't think I have any outdated core libraries. Could you perhaps modify the commit just to cover Arduino board types?

vortigont commented 7 years ago

@pieman64 I do not see this error. I was able to build with the last commit and EspSoftwareSerial under platformio and under Arduino IDE with espressif SDK 2.0 @olehs It would be great to add library.json to your project, so it could be easily tracked.

olehs commented 7 years ago

@vortigont Did you install EspSoftwareSerial manually or it was installed as a part of ESP SDK (using board manager)?

vortigont commented 7 years ago

@olehs I used version from git Just checked, indeed arduino bundled version for ESP8266 platform throws compile error.

olehs commented 7 years ago

The author of ESP8266 SDK agreed to update his library https://github.com/esp8266/Arduino/issues/3239

outrullers commented 7 years ago

Thank you! I have got the same compile error with ESP8266, and this helped me a lot!

P.S. @olehs I deleted my misplaced issue

pieman64 commented 7 years ago

@olehs I'm using the master branch of the Arduino core for ESP and I can confirm all is now fine.