leodesigner / esphome-emerson-vertiv-r48

Esphome custom component to control Emerson / Vertiv R48 PSU
MIT License
4 stars 0 forks source link

Any hints on getting CAN bus "on_frame" to work? #1

Open Jalle19 opened 1 month ago

Jalle19 commented 1 month ago

I bought an MCP2515 chip, hooked it up to my ESP32 and used the following configuration (minus all the boilerplate):

spi:
  clk_pin: GPIO18
  mosi_pin: GPIO23
  miso_pin: GPIO19

canbus:
  - platform: mcp2515
    use_extended_id: true
    cs_pin: GPIO5
    can_id: 0x0607FF83
    bit_rate: 125kbps
    mode: NORMAL
    on_frame:
    - can_id: 0x0707F803
      use_extended_id: true
      then:
      - lambda: |-
          std::string b(x.begin(), x.end());
          ESP_LOGD(">>> canbus:", "%s", &b[0] );
    - can_id: 0x060F8007
      use_extended_id: true
      then:
      - lambda: |-
          std::string b(x.begin(), x.end());
          ESP_LOGD(">>> canbus:", "%s", &b[0] );

The setup looks okay in the logs, but it's like I'm not receiving any frames at all. Do you have any pointers? Do I need to add a jumper on the board to terminate the bus?

Jalle19 commented 1 month ago

I should add that when I connect the same device to a Raspberry Pi with a CAN hat, communication works fine.

leodesigner commented 1 month ago

this is work in progress, I have a new local version, I will update repo soon.

leodesigner commented 1 month ago

There is a bug in the esphome mcp2515 CAN initialisation, this is why the on_frame does not work.

Jalle19 commented 1 month ago

Okay, good to know, maybe I've connected everything correctly after all! I'll gladly help with the code if you could get a working version that compiles published, I'm new to ESPHome development.

leodesigner commented 1 month ago

@Jalle19 check the working version that has been published now.