I am using Arduino UNO, ESP8266 and PZEM-004T to measure electricity parameters and send to server via Wifi. The communication protocols are use as below:
UNO will read the parameters from PZEM-004T via UART, then send to ESP8266 via I2C.
When I use only UART or only I2C, everything works well. But when both are implemented in UNO, there will be a conflict, data read from PZEM-004T is correct but data received by ESP8266 is not correct.
I don't know how to overcome this issue. I have tried to modify the library to skip UART reading when I2C is ongoing (I2C_Flag = true). However, I could only read Voltage, Current, Power, and could not for Energy.
Hello all,
I am using Arduino UNO, ESP8266 and PZEM-004T to measure electricity parameters and send to server via Wifi. The communication protocols are use as below:
PZEM-004T <=== UART(pin 10, pin 11) ===> UNO <=== I2C (pin A4, A5) ===> ESP8266 (Master)
UNO will read the parameters from PZEM-004T via UART, then send to ESP8266 via I2C.
When I use only UART or only I2C, everything works well. But when both are implemented in UNO, there will be a conflict, data read from PZEM-004T is correct but data received by ESP8266 is not correct.
I don't know how to overcome this issue. I have tried to modify the library to skip UART reading when I2C is ongoing (I2C_Flag = true). However, I could only read Voltage, Current, Power, and could not for Energy.
PZEM004T.h
PZEM004T.cpp
Please let me know if you have any solutions for this! Thanks a lot!