helgeerbe / OpenDTU-OnBattery

Software for ESP32 to talk to Hoymiles Inverters and Victrons MPPT battery chargers (Ve.Direct)
GNU General Public License v2.0
298 stars 63 forks source link

[Request] configurable HW-SPI (for Huawei CAN and CMT wireless module) #605

Closed mager33 closed 1 month ago

mager33 commented 8 months ago

Is your feature request related to a problem? Please describe.

Both use the same HW SPI

Describe the solution you'd like

Make HW-SPI configurable for each device.

Describe alternatives you've considered

Hard-assign HW-SPI 2 to CMT and HW-SPI 1 to Huawei and disable other modules the require SPI, like display

Additional context

No response

gitisgreat2023 commented 8 months ago

Its an abstract request. You're interested that the Huawei can be used together with HMT/HMS Hoymiles, right? (those need the CMT module)

Currently only the HM series can be combined with the Huawei.

mager33 commented 8 months ago

 

Yes, that was my idea. I don't see a reason why this could not be possible.

 

As an alternative I'd suggest to use the build-in CAN-controller, as is done here: https://github.com/mb-software/esphome-huawei-r4850 - that would free up the SPI for other parts. Using the build-in CAN also means that a cheaper sn65hvd230 module must be used.

 

Gesendet: Montag, 22. Januar 2024 um 10:30 Uhr Von: "gitisgreat2023" @.> An: "helgeerbe/OpenDTU-OnBattery" @.> Cc: "Martin" @.>, "Author" @.> Betreff: Re: [helgeerbe/OpenDTU-OnBattery] [Request] configurable HW-SPI (for Huawei CAN and CMT wireless module) (Issue #605)

 

Its an abstract request. You're interested that the Huawei can be used together with HMT/HMS Hoymiles, right? (those need the CMT module)

Currently only the HM series can be combined with the Huawei.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

gitisgreat2023 commented 8 months ago

Reading through the software issue here and this I'm wondering whether its feasible to get the software fixed...

@mager33 I don't get how this solution works. Lets say take PCB solutions like on akkudoktor (for example this PCB or this one. How do they need to be modified? Those designs also use a CAN chip, aren't they? Whats the difference then and why does it solve the problem?!

mager33 commented 8 months ago

The EPS32 has a hardware CAN controller. So we can use that (together with an external transceiver). That would free up one SPI that could be used for other stuff.

I don't know why so many solution (I know the procets you'Ve refered to) do not use the built-in CAN-controller but go SPI->external-controller->transceiver. It does not make sense me - and the other solution just works (I've tested it myself)

The ESP32 has two available hardware SPIs, but each can handle multiple devices via CS; some background: https://randomnerdtutorials.com/esp32-spi-communication-arduino/

Backgroud for CAN: https://docs.espressif.com/projects/esp-idf/en/release-v3.3/api-reference/peripherals/can.html https://www.designer2k2.at/de/home/arduino/191-esp32-can-bus-twai https://esphome.io/components/canbus.html

The Arduino library can use both CAN methods: https://github.com/sandeepmistry/arduino-CAN

 

gitisgreat2023 commented 8 months ago

@mager33 yeah, but in those applications the built in CAN controller of the ESP32 is used for the Pylontech communication.

mager33 commented 8 months ago

The Pylontech has CAN and RS485, so we could free the CAN-bus. And if the library can use both CAN methods we could add a configuration option: (a) CAN via SPI and external controller and (b) CAN via built-in controller

gitisgreat2023 commented 8 months ago

Which interface is then used to steer the RS485? Some general IO pins of the ESP32?

mager33 commented 8 months ago

Yes, RS485 is standard serial via an external transceiver (MAX485 or similar, available on cheap modules). There are 3 hardware UARTs available: https://circuits4you.com/2018/12/31/esp32-hardware-serial2-example/

 

gitisgreat2023 commented 8 months ago

Relevant discussion here on adding an ethernet controller via CAN...

mager33 commented 8 months ago

That looks like a well thought out request, only the title is misleading. We can thus close my request.

gitisgreat2023 commented 8 months ago

Fully agree.

krissfr commented 7 months ago

Pylontech can use UART protocol like the JKBMS, and i don't think people will use JKBMS and Pylontech a the same time (and if needed, esp32 has 3 UART controllers). Pylontech using uart is very used with esp devices : https://esphome.io/components/pylontech.html https://github.com/irekzielinski/Pylontech-Battery-Monitoring

So if Pylontech use the UART communication, the Huawei charger can use the CAN bus of the esp, and people can use other SPI for NRF and CMT tranceiver.

AndreasBoehm commented 1 month ago

I create an pull request to make huawei usable together with HMS: https://github.com/helgeerbe/OpenDTU-OnBattery/pull/1144

github-actions[bot] commented 1 week ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new discussion or issue for related concerns.