We want to use WiFi-enabled ESP2866 (WeMos D1 R1 board) to control some relays, and in addition, to provide us (re-send) output of VE.Direct via same WiFi connection we control relays. Everything is powered with Victron MPPT 75/15, using lead-acid battery and solar panel, i.e. sort of “off grid” power / device box.
Strangely, I can read VE.Direct output with ESP2866 correctly only if:
Using EspSoftwareSerial::UART (SoftwareSerial), but only with invert parameter set to true. Sadly, software serial does not seem stable enough, that is I lose some bytes (probably due to WiFi cpu usage, etc?).
Using HW SerialPort (D0 as RX), BUT with huge hack by using TWO UART->TTL MAX3232-based converters [see picture below], because otherwise I get garbage bytes into SerialPort.
Strangely, if I use same (single) UART-TTL converter to connect with PC (using random USB<->RS232 cable in addition), and connect VE.Direct with that UART-TTL headers, I can red VE.Direct output just fine.
Do I miss something? Maybe VE.Direct is inverted for a reason and I MUST use special cable? But why then it works with MAX3232 converted connected to PC…? I’m completely lost…
Here’s the hack I can use to avoid garbage bytes when using HW SerialPort of ESP2866:
VE.Direct cable uses ADuM1201ARZ isolator chip, and it’s Vdd2 gets power when I connect VE/USB DTR pins, as if DTR is used as power source.
I’ve tried to connect VE.Direct’s DTR with WeMos board’s +3.3V or +5.0V but it does not work, i.e. RX of WeMos ESS2866 does not read anything, not even gibberish.
Maybe DTR needs to send something to be activated or smth…?
I have the feeling you are needlessly complicating things…
On your WeMos D1 R1 board, how is the serial port signaling? I have the feeling that it’s on a TTL level, right?
Victron VE.Direct port is communicating on a TLL level (3.3V or 5V, depending on hardware revision). And it’s galvanicaly isolated.
So, in that case, you don’t need to put any adapters between the VE.Direct port/connector and your WeMos module.
Just connect the TX of the VE.Direct port with the RX pin of the WeMos module. And of course the GND signal.
It should work and you should receive the VE.Direct frames/info without any problem, if you set the port speed correctly.
It works, alright…
As the communication is unidirectional, from 5V to 3V3, put a 10K resistor between the devices and that’s all.
You can adapt the value to your needs, but not less than 1K.
If it was from 3V3 to 5V, then it was a different problem, but from 5V to 3V3, a resistor is all you need.
Or, if you really want to be precise, make a level shifter with 2 resistors. Like the one below.
But why your board (WeMos) doesn’t have the GND connected to the Victron GND ???
GND is the reference for any signal !..
And Victron GND and 5V on VE.Direct are isolated from the rest of the Victron universe so it’s safe.
The 5V is probably high enough to cross the threshold for your RS232 interface to receive a high / low, but remember that TTL signals are inverted, so a TTL low is 1 and a TTL high is 0. That’ll explain the garbage.
So it confirms “invertion” of sorts. Using double TTL->UART converters somehow un-inverts.
Maybe I could setup MAX232 chip manually to convert levels and invert?
The Victron isolated GND is different from the battery’s GND…
All your GNDs and your “construction” must be on the WeMos side, with WeMos side as the main source of GND.
You must leave the battery’s GND alone, the sole point of GND on Victron side must be the VE.Direct GND, otherwise there is no isolation.
Also, try to not take power from VE.Direct port, supply your converter from WeMos board.