mb-software / esphome-huawei-r4850

EspHome Component to control a huawei r4850 power supply via CAN bus
MIT License
20 stars 7 forks source link

MCP2515 and ESP8266 #2

Open futschikato opened 1 year ago

futschikato commented 1 year ago

Thank you for the code. I have tested it successfully with an ESP32 and a TJA1051 board (with 5V power supply). In contrast, with an Esp8266 and a MCP2515 board via SPI, I could only read data for about 20 seconds, after which no more data arrived. Additional question: I am a newbie in EspHome. How can I control the current along with the button e.g. with a mqtt command?

mager33 commented 10 months ago

voltage/current control works; of course, you have to activated the proper protocols. It was made to interface with HomeAssistant. Look here: https://esphome.io/components/mqtt.html PS: without HomeAssistant it is important to remove "api:", or the ESP will reboot, desperately trying to find a HomeAssistant instance...

jdrescher2006 commented 8 months ago

I am trying to get the same setup to work. So I have a D1 mini and a MCP2515. First I tried to run this project: https://github.com/KlausLi/Esp-HuaweiR4850-Controller/tree/main. The connection is done exactly like supposed: wiring And then everything works just fine, the values from the R4850 can be written and read.

Now with this project I kept the same wiring but there is no data from the R4850. What I noticed is the R4850 has a connection break LED. This LED is off if I disconnect the R4850.

Relevant part of yaml looks like this: spi: id: McpSpi clk_pin: GPIO14 mosi_pin: GPIO13 miso_pin: GPIO12

canbus: - platform: mcp2515 id: my_mcp2515 spi_id: McpSpi cs_pin: GPIO15 can_id: 0 use_extended_id: true bit_rate: 125kbps

huawei_r4850: canbus_id: my_mcp2515 update_interval: 5s

image

mager33 commented 8 months ago

I succeeded with the recommended transceiver sn65hvd230

jdrescher2006 commented 8 months ago

No the sn65hvd230 cannot be used for the esp8266. This is because the 8266 does not have a build in can controller.

mager33 commented 8 months ago

The ESP32 is so cheap, just go for that and use your time to solve other problems :-)

jdrescher2006 commented 8 months ago

Yeah its cheap but has also more power consumption as esp8266. Anyway it seems the best solution to give up on that and stick with esp32. But that does not work either, see my new issue.

sker65 commented 1 month ago

I created a esp8266 / mcp2515 version purely on ESPHome https://github.com/sker65/huawei-r4850g2-esphome Maybe this works better for you ..

Metalazzo commented 1 month ago

I created a esp8266 / mcp2515 version purely on ESPHome https://github.com/sker65/huawei-r4850g2-esphome Maybe this works better for you ..

sorry but there is a big error somewhere, esp is bootlooping non stop (and OTA section is not working at all). same behaviour with d1 mini and esp32.

sker65 commented 1 month ago

If this is meant for this project: https://github.com/sker65/huawei-r4850g2-esphome you should maybe create an issue there? But other than that I can tell that is it working on my end. Which version of ESPHome do you use?

Metalazzo commented 1 month ago

yes it's for this project for the version of esphome, it's the last official one available for HA there is some panic error during init phase

01:30:03][D][spi:035]: Setting up SPI bus... [01:30:03][D][template.select:014]: Setting up Template Select [01:30:03][D][template.select:017]: State from initial: online [01:30:03][D][select:015]: 'Mode': Sending state online (index 1) [01:30:03][D][SET VAL out voltage::253]: 0.000000 0 [01:30:03]Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.

i'll go there

sker65 commented 1 month ago

I'm still on 2023.7.1. IIRC there was a problem when I tried to upgrade last time. Maybe you can try version 2023.7.1 and see if it works?

Metalazzo commented 1 month ago

I don't know how to downgrade esphome. I tried ESP32 instead of D1mini because I have some Weemos D1 mini V4 (Lolin) but there is still something wrong : verification is OK but init is causing bootloop into safe mode. This project https://github.com/mb-software/esphome-huawei-r4850?tab=readme-ov-file seems to work a bit : i can set max voltage (tested with voltmeter) and max current (but NaN values but CAN chip is not the one recommended) sorry to hijack the topic.

sker65 commented 1 month ago

There is a docker image https://hub.docker.com/r/esphome/esphome for all versions. These can be used either with the webUI or just as CLI to compile your firmware see https://esphome.io/guides/getting_started_command_line.html.

Metalazzo commented 1 month ago

Thanks for the advice. I still don't have any values for power, temperature etc. At least, no more bootloop.