A few updates on canbus page (#1813)

This commit is contained in:
Jesse Hills 2022-01-19 09:55:08 +13:00 committed by GitHub
parent 6e9007140d
commit 4a74fddd0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -52,7 +52,10 @@ Each canbus platform extends this configuration schema.
std::string b(x.begin(), x.end()); std::string b(x.begin(), x.end());
ESP_LOGD("can id 500", "%s", &b[0] ); ESP_LOGD("can id 500", "%s", &b[0] );
.. _config-canbus:
Configuration variables: Configuration variables:
************************
- **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation. - **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation.
- **can_id** (**Required**, int): default *can id* used for transmitting frames. - **can_id** (**Required**, int): default *can id* used for transmitting frames.
@ -79,6 +82,7 @@ Configuration variables:
- 1000KBPS - 1000KBPS
Automations: Automations:
------------
- **on_frame** (*Optional*, :ref:`Automation <automation>`): An automation to perform when ability - **on_frame** (*Optional*, :ref:`Automation <automation>`): An automation to perform when ability
CAN Frame is received. See :ref:`canbus-on-frame`. CAN Frame is received. See :ref:`canbus-on-frame`.
@ -148,11 +152,24 @@ ESP32 CAN Component
The ESP32 has an integrated CAN controller and therefore doesn't need an external controller necessarily. The ESP32 has an integrated CAN controller and therefore doesn't need an external controller necessarily.
You only need to specify the RX and TX pins. You only need to specify the RX and TX pins.
.. code-block:: yaml
# Example configuration entry
canbus:
- platform: esp32_can
tx_pin: GPIO1
rx_pin: GPIO3
can_id: 4
bit_rate: 50kbps
on_frame:
...
Configuration variables: Configuration variables:
************************ ************************
- **rx_pin** (**Required**, :ref:`Pin <config-pin>`): Receive pin. - **rx_pin** (**Required**, :ref:`Pin <config-pin>`): Receive pin.
- **tx_pin** (**Required**, :ref:`Pin <config-pin>`): Transmit pin. - **tx_pin** (**Required**, :ref:`Pin <config-pin>`): Transmit pin.
- All other options from :ref:`Canbus <config-canbus>`.
MCP2515 Component MCP2515 Component
----------------- -----------------
@ -162,20 +179,6 @@ You need to have an :ref:`SPI bus <spi>` in your configuration with both the **m
For wiring up the MSP2515 please refer to the section below. For wiring up the MSP2515 please refer to the section below.
Configuration variables:
************************
- **cs_pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): Is used to tell the receiving SPI device
when it should listen for data on the SPI bus. Each device has an individual ``CS`` line.
Sometimes also called ``SS``.
- **clock** (*Optional*): One of ``8MHZ``, ``16MHZ`` or ``20MHZ``. Clock crystal used on the MCP2515 device.
Defaults to ``8MHZ``.
- **mode** (*Optional*): Operation mode. Default to ``NORMAL``
- NORMAL: Normal operation
- LOOPBACK: Loopback mode can be used to just test you spi connections to the device
- LISTENONLY: only receive data
.. code-block:: yaml .. code-block:: yaml
# Example configuration entry # Example configuration entry
@ -197,6 +200,22 @@ Configuration variables:
id: light_1 id: light_1
brightness: !lambda "return (x.size() > 0) ? (float) x[0]/255 : 0;" brightness: !lambda "return (x.size() > 0) ? (float) x[0]/255 : 0;"
Configuration variables:
************************
- **cs_pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): Is used to tell the receiving SPI device
when it should listen for data on the SPI bus. Each device has an individual ``CS`` line.
Sometimes also called ``SS``.
- **clock** (*Optional*): One of ``8MHZ``, ``16MHZ`` or ``20MHZ``. Clock crystal used on the MCP2515 device.
Defaults to ``8MHZ``.
- **mode** (*Optional*): Operation mode. Default to ``NORMAL``
- NORMAL: Normal operation
- LOOPBACK: Loopback mode can be used to just test you spi connections to the device
- LISTENONLY: only receive data
- All other options from :ref:`Canbus <config-canbus>`.
Wiring options Wiring options
--------------- ---------------
Easiest approach is to just use fully assembled boards and just add one resistor in the MISO line. Easiest approach is to just use fully assembled boards and just add one resistor in the MISO line.