Victron Energy VEDirect Bluetooth

@KinDR Thanks for the code GitHub - KinDR007/VictronMPPT-ESPHOME: Victron Mppt charger ve.direct to esphome node it works perfectly with my MPPT 75/15.

One question: 5V coming from the Viktron, have you already considered using this for the ESP 8266? Then you can use it without USB for the Power.

The current on the 5V pin is not enough for supplying a ESP 8266 I think.

https://www.victronenergy.com/live/vedirect_protocol:faq

Q5: How much current can I draw from the power pin in the VE.Direct port?

Max 10mA average, with max 20mA/5ms bursts.

Hi,
ve.direct port does not have enough current to power esp !!

Thanks for the summary.

I am interested in implementing this, have read @KinDR posts and note his GitHub link for the smart shunt:

But I do lack some understanding/knowledge, in particular about Step 2.

I have:

  • Home Assistant
  • A Victron Smart Shunt
  • An ESP8266MOD board
  • Some short wires and connector pins
  • ESPHome integration already in use in Home Assistant (I have some smart plugs which use ESPHome).

Step 1.
I can connect the pins OK.
I assume I need to supply power to the ESP8266 board, which I would do via the board’s USB input and a regular AC plug in power supply.

Step 2.
I’ve little idea on how to do this. Any pointers would be appreciated.
I use a Macbook.

Step 3.
I already have the HA ESPHome integration running.
How do I initiate discovery so ESPHome detects the ESP8266 board?

Step 4.
I’m not clear what else is needed. It looks like some yaml code is required in the HA config file. I see some code in KinDR’s github page but I’m unsure which goes where.

Thanks for any help. This is my first time attempting such a thing with an ESP board.

Step 2 - there are several ways to achieve. Maybe this one will be easiest for you:
Create “NEW DEVICE” in ESPHome (in your HA system). Once the YAML file is created you may then copy the parts of it from KinDR007 github example.
Then you install the file - again, there are few ways and maybe the easiest woudl be to use your browser on your computer - you also nee to have ESP8266 connected to the USB of the computer. I hope this works on Mac (I use Windows) - basically computer discover new device connected to USB (ESP8266) and then browser has software to install YAML file to this device. Once done and provided you have enabled WiFi the next updates you may do OTA (Over The Air) just from your HA.

Thanks.

OK, this is where my ignorance comes into play.

How?

If I look at my ESPHome integration in HA there is no such option to create a new device. All I see is a card with a list of devices:

Screen Shot 2023-02-23 at 2.37.51 pm

If I click on one of the device menus it relates to that device only.

But assuming we get past that hurdle…

I plugged the ESP board into the Mac’s USB port. It flashed a blue light on the board very briefly.
But then what?

Is there an IP address I navigate to?

I think it creates its own wifi network, which I can join, but that’s it. It doesn’t guide me to a browser page or anything like that, which is what an ESPHome smart plug does, takes me straight to a config menu to set it up on my local network, and then it is auto discovered by HA.

But I see nothing / don’t know where to look. It doesn’t appear in my Finder in the way a plug in USB memory stick would appear.

Apologies but never used these before and I am not an IT/comms type of guy.

Step 2. “NEW DEVICE” is not where at the integration section but at the Add-on.
Check this info: Getting Started with ESPHome and Home Assistant — ESPHome - I hope it can explain step-by-step.
Also this page may help: https://web.esphome.io/ when flashing from web.
Maybe here is some answer https://peyanski.com/complete-esphome-installation-guide/
In general, once you connect your ESP device to USB port, your computer should detect it and then your browser can use this connection to flash it. Once flashed it will connect to your HA instance and then you could change/update it with no need to connect to computer.
But I am not sure it this also fully works like that on Mac. I am sure you can google this info - there should be plenty info out there…

Thanks, I have managed to open the ESPHome app in HA and tried to follow the linked instructions but I am stuck again with no clue. I had no idea this app existed, nor that this is what was required or meant by the previous instructions.

So much presumed knowledge!

I tried to follow the instructions as best I could but frankly I have no idea if what I did was correct or not.

In the end it created a yaml file in config/esphome and I see this in the ESPHome app menu:

So from there I try to install ESPHome on the device:

but here I am stuck. The documentation completely glosses over this part and just assumes you know what you are doing.

I tried connecting it to the USB port of my Mac and choosing the “Plug into this computer” option, but I get nothing.

I tried plugging it into a USB port on my HA server, but same thing. It only sees my Conbee II stick, so given that’s the only option I select it and it then opens some random terminal window and a whole stream of text appears, and ends with a bunch of text in red with lots of error messages.

I tried the manual download but again that goes nowhere.

I can only guess that the board is just not being seen by my computers.

Thanks for the assistance but would seem I am just fumbling in the dark without a clue.

I think we are getting there… :wink:
I recommend you use “Plug into the computer running ESPHome Dashboard” which is your HA server (are you running it on Raspbbery Pi ?).
There you should be able to see another device on top of your Conbee stick. See a
example below (I just plugged in my ESP8266 to my raspberry) - the ESP appeared as USB2.0-Ser!:


From my memory sometimes you need to refresh the add-on or even restart your HA with ESP8266 plugged into USB port on your server in order for this option to appear.
Once you have it use this one and that should load the newly created device yaml file (compiled) into your ESP8266.
Good Luck!

Hope so!

Tried that, my HA is running on a mini PC inside a Proxmox VM. I swapped over from the RPi about a month back. That was a day spent with some very generous assistance to guide me through as I had little hope of doing it myself. Happy I have made that move as the new set up is way faster and I feel is likely to be much more robust than the RPi’s SD card.

When I look at the hardware options within my Proxmox HA VM, if I click to add a USB device it only shows the Conbee II stick, no other options appear.

I’ll have a go at a reboot of the Proxmox server and HAOS on VM to see if a new device shows up.

Unfortunately even after a reboot of my server and HA, the ESP board is not showing up as an option to select.
:confused:

Progress.

After multiple failed attempts connecting the device to both my HA server PC and my Mac, I eventually tried a different USB cable today and I was able to see the device on my Mac (but not on the HA server). Annoying that it was the cable that was the problem but at least I’m in and can make a bit more progress.

I installed the “Prepared for First Use” basic set up onto the ESP board and I have managed to get it connected to my WiFi, renamed it “Victron Smartshunt” and it is now showing in my HA ESPHome page ready for the next step:

Now I’m still not clear on the next step.

If I click on EDIT, I see this:

Is this where I am supposed to copy/paste some code?

And is that code the yaml as per the GitHub link:

external_components:
  - source: github://KinDR007/VictronSmartShunt-ESPHOME@main

uart:
  id: the_uart
  rx_pin: D7
  baud_rate: 19200
  stop_bits: 1
  data_bits: 8
  parity: NONE
  rx_buffer_size: 256

victron_smart_shunt:
  uart_id: the_uart

sensor:
  - platform: victron_smart_shunt
    battery_voltage:
      id: bv
    battery_current:
      id: bc

  - platform: victron_smart_shunt
    battery_voltage:
      name: "Battery Voltage"  
      id: bv

    battery_current:
      name: "Battery Current" 
      id: bc

    fw_version:
      name: "fw"  
      id: fw

    pid:
      name: "pid"  
      id: pid

    instantaneous_power:
      name: "instantaneous power"  
      id: instantaneous_power      

    time_to_go:
      name: "time to go"  
      id: time_to_go

    consumed_amp_hours:
      name: "consumed amp hours"
      id: consumed_amp_hours  
      unit_of_measurement: Ah

    min_battery_voltage:
      name: "Min battery voltage"
      id: min_battery_voltage   

    max_battery_voltage: 
      name: "Max battery voltage"
      id: max_battery_voltage     

    amount_of_charged:
      name: "Amount of charged"
      id:  amount_of_charged   
      filters:
        - multiply: 0.001
      unit_of_measurement: kWh

    bmv_alarm:
      name: "BMV alarm"
      id: bmv_alarm
      
    bmv_pid:
      name: "bmv - pid"
      id: bmv_pid

    last_full_charge:
      name: "Time since last full charge"
      id: last_full_charge

    deepest_discharge:
      name: "Depth of the deepest discharge"
      id: deepest_discharge   
      unit_of_measurement: Ah

    last_discharge:
      name: "Depth of the last discharge"
      id: last_discharge
      unit_of_measurement: Ah

    discharged_energy:
      name: "Amount of discharged energy"
      id: discharged_energy   
      filters:
        - multiply: 0.001
      unit_of_measurement: kWh

    state_of_charge:
      id: state_of_charge
      name: "SoC"  

Is that copy/pasted underneath the other code, then I Save and Install?

Sorry for the dumb questions but the steps for completing this process are just not clear to me.

I recommend learning how to use esptool. AFAIK it is cross platform but I use it in Linux just fine. esptool -p /dev/ttyUSB0 write_flash 0x0 yourfirmware.bin . It really is that simple. If esptool runs on Windows it would be -p COM3 or similar most likely. And Mac might be similar to Linux. Just do Manual Download and Modern. Once flashed over USB everything else is OTA.

Thanks but most of that makes no sense to me.

I am not an IT/comms guy. It’s like you are speaking a foreign language.

My expertise lies elsewhere. I do try to read the guides and search, but there is often a lot of assumed knowledge/experience within IT documentation and often I hit a roadblock where can’t interpret the road signs.

Since you did get as far as installing the base esphome on your device then yes, just paste the rest of the code then you can save the file. Then hit the 3 dots and Validate. If no errors do “Install” and “Wirelessly”.

1 Like

Thanks, went to try that but the device will no longer connect to wifi. No idea what the problem is, it connected yesterday as you saw with my images above.

I connected it to my Mac again and looked at the log .

It keeps scanning for networks, finding them, not connecting and timing out. According to the log it is seeing network with good signal strength but won’t connect.

[I][wifi:257]: WiFi Connecting to 'Telstra25BEB0'...
[W][wifi_esp8266:212]: wifi_apply_hostname_(esphome-web-82e879): lwIP error -16 on interface st (index 0)
[W][wifi:549]: Error while connecting to network.
[I][wifi:257]: WiFi Connecting to 'Telstra25BEB0'...
[W][wifi_esp8266:212]: wifi_apply_hostname_(esphome-web-82e879): lwIP error -16 on interface st (index 0)
[W][wifi:543]: Timeout while connecting to WiFi.
[D][wifi:386]: Starting scan...
[D][wifi:401]: Found networks:
[I][wifi:444]: - 'Telstra25BEB0' [redacted]▂▄▆█
[D][wifi:446]:     Channel: 11
[D][wifi:447]:     RSSI: -31 dB
[I][wifi:444]: - 'Telstra25BEB0' [redacted]▂▄▆█
[D][wifi:446]:     Channel: 2
[D][wifi:447]:     RSSI: -59 dB
[I][wifi:444]: - 'Telstra25BEB0' [redacted]▂▄▆█
[D][wifi:446]:     Channel: 1
[D][wifi:447]:     RSSI: -65 dB
[I][wifi:444]: - 'Telstra25BEB0' [redacted]▂▄▆█
[D][wifi:446]:     Channel: 1
[D][wifi:447]:     RSSI: -33 dB
[D][wifi:449]: - [redacted] [redacted]▂▄▆█
[I][wifi:257]: WiFi Connecting to 'Telstra25BEB0'...
[W][wifi_esp8266:212]: wifi_apply_hostname_(esphome-web-82e879): lwIP error -16 on interface st (index 0)
[W][wifi:549]: Error while connecting to network.
[I][wifi:257]: WiFi Connecting to 'Telstra25BEB0'...
[W][wifi_esp8266:212]: wifi_apply_hostname_(esphome-web-82e879): lwIP error -16 on interface st (index 0)
[W][wifi:543]: Timeout while connecting to WiFi.

Lather, rise, repeat.

OK, update, after a long time it seems to have connected. Not particularly reassuring that it drops offline for so long, especially if I hope to use it for battery monitoring.

Will give the yaml code update a crack.

OK, I pasted in the yaml code at the end and used the validate option. It says it’s invalid and lists a range of errors:

First up is this:

INFO Reading configuration /config/esphome/esphome-web-82e879.yaml...
Failed config

uart: [source /config/esphome/esphome-web-82e879.yaml:33]
  - id: the_uart
    
    Cannot resolve pin name 'D7' for board esp01_1m.
    rx_pin: D7
    baud_rate: 19200
    stop_bits: 1
    data_bits: 8
    parity: NONE
    rx_buffer_size: 256

Not sure what that means. I looked up and came across this:

hoping it might shed some light for me but not really. I tried changing the line

  rx_pin: D7

with

  rx_pin: GPIO7

but that just resulted in a different error.

Next, were the following. Looks like a spelling error for this one:

  [instantaneous_power] is an invalid option for [sensor.victron_smart_shunt]. Did you mean [instanteneous_power], [panel_power]?
  instantaneous_power: 
    name: instantaneous power
    id: instantaneous_power

When I replaced it with the incorrect spelling of instanteneous for instantaneous then the error was resolved.

Then this one:

[bmv_alarm] is an invalid option for [sensor.victron_smart_shunt]. Did you mean [bmv_alarm_text]?
  bmv_alarm: 
    name: BMV alarm
    id: bmv_alarm

So I changed it to the suggested bmv_alarm_text and again the error was resolved.

Finally:

  [bmv_pid] is an invalid option for [sensor.victron_smart_shunt]. Did you mean [pid]?
  bmv_pid: 
    name: bmv - pid
    id: bmv_pid

Since pid is already defined further up in the code, I wasn’t sure what this was for, so I put hashtags in from of these lines and the error was resolved.

So now I am left with the first listed error, Cannot resolve pin name 'D7' for board esp01_1m. when I do a validation check. Bit stuck on that one.

Could you expand on what you meant when you said you started to receive harmless garbage values?
I noticed that occasionally I am seeing my battery voltage spike to 30v or drop to 0v (12v system). Im wondering if you saw similar behavior.

@wattmatters - I have a bit of feeling that many issues here are not directory related to Victron code (like initial flashing ESP modules) and thus maybe in future would be better (cleaner) to start another topic with such issues…
Now, for your WiFi issues it looks like you have several AP with the same name (working on different channels) - this might be a challenge and maybe here there are some ideas how to fix it (in therms of stability)
For your pin name “D7” issue I had it with some ESP boards. For some of them names used by producers (Like D1, D2,…) are accepted by ESPHome add-on editor and for some boards not, and then you have to use GPIOnn instead. Check this site for referencing which D pin is which GPIO for your particular board.