OpenEVSE / openevse_esp32_firmware

OpenEVSE V4 WiFi gateway using ESP32
153 stars 107 forks source link

[RFC] adding a voltmeter #825

Open kolyshkin opened 2 months ago

kolyshkin commented 2 months ago

_This is a continuation/summary of discussion in https://github.com/lincomatic/open_evse/issues/175_

Current OpenEVSE hardware (as of April 2024) lacks a voltmeter, and the current meter is not too precise. As a result, power calculations use some predefined voltage (like 240) and imprecise current.

After some research, it seems that adding a dedicated power meter that will interface with ESP32 directly (i.e. no ATMEGA involvement) would be the best solution.

For example, Peacefair PZEM-004t (v3.0) measures both AC voltage and current (up to 100A) and is able to talk via a serial bus. There are mixed reports of whether it can work with ESP32's 3.3v signalling, but most sources say it can (if being powered by 3.3v).

Another possibility is to use Peacefair PZEM-016 which seems to be a newer version of PZEM-004t v3.0 (as far as I can tell, the only difference is built-in power supply that is powered from the high voltage side).

ESP32 has 3 serial ports. Current OpenEVSE hardware (OpenEVSE TFT v1) has two serial ports available on the board:

For now, I am going to try using Serial2 (aka debug port). Unfortunately it is used even when the DEBUG is not defined, so the first step would be to make debug work without actually occupying a real serial port.

The next step would be to modify the code to support a dedicated power meter instead of relying on information from ATMEGA board.

Any ideas, comments, questions etc. are very welcome!

Dicion commented 2 weeks ago

Looks like the PZEM-004t is RS232 on the serial side, and PZEM-016 is RS485.

It would be REALLY easy if someone made an i2c version of something like this. Can just bus it on the QWIC connector along with the RFID reader.

It might be worth looking into using something like this: https://www.dfrobot.com/product-2001.html

Especially since you're having difficulty accessing the serial ports already.

Dicion commented 2 weeks ago

Assuming you're using the TFT board, could you modify platformio.ini to move the debug port to the unsoldered one as a test to free it up?

From

[env:openevse_wifi_tft_v1] board = denky32 build_flags = ${common.build_flags_openevse_tft} -D DEBUG_PORT=Serial2 -D RAPI_PORT=Serial

To

[env:openevse_wifi_tft_v1] board = denky32 build_flags = ${common.build_flags_openevse_tft} -D DEBUG_PORT=Serial1 -D RAPI_PORT=Serial

Which would possibly free up Serial2 for your use. Or maybe you could just undefine it as well. Not sure how it would handle that though. Other platforms don't have a debug port defined, so I'd hope that undefining it works.