Closed nguyenhuudamy closed 2 years ago
What about something like this? .h
PZEM004Tv30(HardwareSerial* port, int rx_pin, int tx_pin, uint8_t addr=PZEM_DEFAULT_ADDR);
.cpp
PZEM004Tv30::PZEM004Tv30(HardwareSerial* port, int rx_pin, int tx_pin, uint8_t addr) { port->begin(PZEM_BAUD_RATE, SERIAL_8N1, rx_pin, tx_pin); //Baud rate, parity mode, RX, TX this->_serial = port; this->_isSoft = false; init(addr); }
Thanks @mandulaj, looks great at a glance - I will check it out this evening, test with my ESP32 and report 👍
I managed to get hold of an ESP32 and it seems to work fine... So I am ready to merge right away.
Hi @nguyenhuudamy Thanks for the PR. However I don't like the idea of changing an established API. It would for sure break my projects not to mention anyone who already uses this library... Perhaps we can overload the function or wrap it in a #if #else to fix it just for the esp32 platform while retaining the Arduino compatible API.