Skip to content
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

Add ESP32 Support #20

Closed
Navok85 opened this issue Feb 25, 2020 · 8 comments · Fixed by #31
Closed

Add ESP32 Support #20

Navok85 opened this issue Feb 25, 2020 · 8 comments · Fixed by #31
Assignees

Comments

@Navok85
Copy link

Navok85 commented Feb 25, 2020

Please add ESP32 support.

I changed line #25 in PZEM004Tv30.h file to:

#if (not defined(PZEM004_NO_SWSERIAL)) && (defined(__AVR__) || defined(ESP8266)) || defined(ESP32)
which makes it works with hardwareserial e.g. serial2

But softwareserial still makes problems and didn't work with the EspSoftwareSerial.

@clowrey
Copy link

clowrey commented Mar 4, 2020

I don't have anything to add as far as fixing the issues - but I can say I have duplicated the same basic effect.

It works with Serial2, does not work with the EspSoftwareSerial library found here https://github.com/plerup/espsoftwareserial

This might be tricky to debug - not sure exactly where to start, my board the TTGO ESP32 TFT with LCD screen had no available extra serial as the Serial2 port is used by the built in LCD screen. I switched to a different board with the hardware serial pins 16,17 available and it works with the hardware serial example.

@mudassar791
Copy link

can you upload ready made example with esp32 & esp8266 in next release?

@mandulaj mandulaj added this to the Release of v1.1 milestone Jan 23, 2021
@mandulaj mandulaj self-assigned this Jan 23, 2021
vortigont added a commit to vortigont/PZEM-004T-v30 that referenced this issue Apr 15, 2021
+ example

Closes mandulaj#20

Signed-off-by: Emil Muratov <gpm@hotplug.ru>
vortigont added a commit to vortigont/PZEM-004T-v30 that referenced this issue Apr 15, 2021
+ example

Closes mandulaj#20

Signed-off-by: Emil Muratov <gpm@hotplug.ru>
vortigont added a commit to vortigont/PZEM-004T-v30 that referenced this issue Apr 16, 2021
+ example

Closes mandulaj#20

Signed-off-by: Emil Muratov <gpm@hotplug.ru>
@mandulaj mandulaj linked a pull request Jul 15, 2021 that will close this issue
@mandulaj
Copy link
Owner

I am aware of the Software Serial bug in ESP32 and I don't have a solution. However I think that since the ESP32 has 3 HW serial ports which can be configured to use any GPIO pin, there isn't really any need for a Software Serial solution.

If there is a requirement to use the Software Serial, I might consider looking into it in the future. But for now, I think its better to just not support it on the ESP32 platform.

@loopyengineeringco
Copy link

loopyengineeringco commented Jul 16, 2021

Yes, you no longer need to use SoftwareSerial on the ESP32, even to address multiple pzems thanks to the new updates 🎉
Just remap the HardwareSerial pins to some free unused GPIOs and it works great. Not sure if the library does this remap for you, but you can do it brute force by editing this file:
C:\Users\xxxxxx\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32\HardwareSerial.cpp
Then close & reopen Arduino & recompile
Just remember you did this, otherwise you'll have fun in a few year's time when you've long forgotten 🤣

@mandulaj
Copy link
Owner

mandulaj commented Jul 16, 2021

OK, The newest code has now been merged into master. Soon I will update the PlatformIO and Arduino Library manager library. Here is the the new way of defining HW Serial on ESP32s:

// RX=16, TX=17
PZEM004Tv30 pzem(Serial2, 16, 17);

If there isn't anything else, I will close this issue.
For now I am linking #70

@rohanpatil-rc
Copy link

rohanpatil-rc commented Sep 8, 2023

i am having issues (esp32)
the code get compiled and uploaded
but serial monitor reports -error reading
i have tried swaping rx and tx but still not getting any outuput
the pzem ttl only one led blinks
change the baud rate to 9600

i have tried some else code with ardunio
the pzem is working fine showing all results.

@mandulaj
Copy link
Owner

mandulaj commented Sep 8, 2023

@rohanpatil-rc You will have to give me more info in order to help you. Which pins are you using on the ESP32, can you share the code? Is the PZEM powered by AC? Could you share the code or library that does work? Are you sure you are using a PZEM 0004T version 3.0?

@rohanpatil-rc
Copy link

@rohanpatil-rc You will have to give me more info in order to help you. Which pins are you using on the ESP32, can you share the code? Is the PZEM powered by AC? Could you share the code or library that does work? Are you sure you are using a PZEM 0004T version 3.0?

i have delete my post with the code that is was having issues.
it was not the code it was the gnd pin trace of esp32 that was broke
its working now
thanks for your library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants