Skip to content
Bernhard Kirchen edited this page Mar 25, 2024 · 38 revisions

Device Profiles

It is possible to change hardware settings like pin assignments or ethernet support using a JSON file. The JSON file can be uploaded using the configuration management in the web interface. Select Pin Mapping (pin_mapping.json) in the recovery section.

When the file is uploaded the ESP performs a reboot. This is required as the pin settings could have changed within the file. By default all the pin assignments are used as compiled into the firmware. In recent releases, less and less default pin assignments are part of the firmware. Please always upload and select the appropriate device profile for your platform.

To change the device profile, navigate to the Device Manager and selected the appropriate profile. You can see the current (Active) and the new (Selected) in assignment in the table below the combobox.

The JSON file can contain multiple profiles. Each profile requires a name and different parameters. If one parameter is not set, the default value, as compiled into the firmware is used.

Sample files for some boards are provided as part of the project's GIT code repository.

Structure of the pin_mapping.json file

NOTE: These profiles are partially incomplete and merely serve as example snippets.

[
    {
        "name": "Generic NodeMCU 38 pin",
        "nrf24": {
            "miso": 19,
            "mosi": 23,
            "clk": 18,
            "irq": 16,
            "en": 4,
            "cs": 5
        },
        "victron": {
            "rx": 22,
            "tx": -1
        },
        "battery": {
            "rx": 27,
            "tx": 14
        },
        "huawei": {
            "miso": 12,
            "mosi": 13,
            "clk": 26,
            "irq": 25,
            "power": 33,
            "cs": 15
        },
        "eth": {
            "enabled": false,
            "phy_addr": -1,
            "power": -1,
            "mdc": -1,
            "mdio": -1,
            "type": -1,
            "clk_mode": -1
        }
    },
    {
        "name": "Generic NodeMCU 38 pin with SSD1306",
        "nrf24": {
            "miso": 19,
            "mosi": 23,
            "clk": 18,
            "irq": 16,
            "en": 4,
            "cs": 5
        },
        "eth": {
            "enabled": false,
            "phy_addr": -1,
            "power": -1,
            "mdc": -1,
            "mdio": -1,
            "type": -1,
            "clk_mode": -1
        },
        "display": {
            "type": 2,
            "data": 21,
            "clk": 22
        }
    },
    {
        "name": "Olimex ESP32-POE",
        "nrf24": {
            "miso": 15,
            "mosi": 2,
            "clk": 14,
            "irq": 13,
            "en": 16,
            "cs": 5
        },
        "eth": {
            "enabled": true,
            "phy_addr": 0,
            "power": 12,
            "mdc": 23,
            "mdio": 18,
            "type": 0,
            "clk_mode": 3
        }
    },
    {
        "name": "OpenDTU FUSION v2 + JK BMS on RS485 Transceiver",
        "battery": {
            "rx": 16,
            "rxen": 15,
            "tx": 45,
            "txen": 46
        }
    },
    {
        "name": "OpenDTU FUSION v2 + Victron MPPT + Victron SmartShunt",
        "nrf24": {
            "miso": 48,
            "mosi": 35,
            "clk": 36,
            "irq": 47,
            "en": 38,
            "cs": 37
        },
        "cmt": {
            "clk": 6,
            "cs": 4,
            "fcs": 21,
            "sdio": 5,
            "gpio2": 3,
            "gpio3": 8
        },
        "led": {
            "led0": 17,
            "led1": 18
        },
        "battery": {
            "rx": 16,
            "tx": -1
        },
        "victron": {
            "rx": 22,
            "tx": -1
        }
    }
]

Implemented configuration values

See the upstream project's Wiki for JSON objects and pins that are not specific to features of OpenDTU-OnBattery, but inherited from the upstream project. The table below only lists OpenDTU-OnBattery-specific pins.

Parameter Data Type Description
victron.rx integer Victron MPPT Charger VE.Direct receive pin
victron.tx integer Victron MPPT Charger VE.Direct transmit pin, can be set to -1 for now
victron.rx2 integer Second Victron MPPT Charger VE.Direct receive pin
victron.tx2 integer Second Victron MPPT Charger VE.Direct transmit pin, can be set to -1 for now
battery.rx integer Pylontech battery CAN bus receive pin,
JK BMS receive pin or
Victron SmartShunt VE.Direct receive pin
battery.tx integer Pylontech battery CAN bus transmit pin,
JK BMS transmit pin or
Victron SmartShunt VE.Direct transmit pin, can be set to -1 for now
battery.rxen integer JK BMS receive enable pin for RS485 transceiver mode
battery.txen integer JK BMS transmit enable pin for RS485 transceiver mode
huawei.miso integer MISO Pin for Huawei CAN bus interface
huawei.mosi integer MOSI Pin for Huawei CAN bus interface
huawei.clk integer CLK Pin for Huawei CAN bus interface
huawei.cs integer CS Pin for Huawei CAN bus interface
huawei.irq integer IRQ Pin for Huawei CAN bus interface
huawei.power integer Power Pin for Huawei power control (e.g. using slot detect)

Example configuration with most options

Be aware that some combinations are not possible (more Information below)

VE.Direct cable connection (red/white cables) is shown as "Direct" cable, instead of "Crossover" cable (for more information look Wiki under VE.Direct )

Wiring_ESP32_Symbol - Victr1Victr2PylontechHuaweiRelaisCMT2300upd

        "name": "Victron Pylontech HUAWEI NodeMCU 38 pin",
        "nrf24": {
            "miso": 19,
            "mosi": 23,
            "clk": 18,
            "irq": 16,
            "en": 4,
            "cs": 5
        },
        "victron": {
            "rx": 22,
            "tx": 21
        },
        "battery": {
            "rx": 27,
            "tx": 14
        },
        "huawei": {
            "miso": 12,
            "mosi": 13,
            "clk": 26,
            "irq": 25,
            "power": 33,
            "cs": 15
        },
        "eth": {
            "enabled": false,
            "phy_addr": -1,
            "power": -1,
            "mdc": -1,
            "mdio": -1,
            "type": -1,
            "clk_mode": -1
        }
    },

Other Information

SPI Bus

Using an ESP32 board is not a "free card" to add any and every Add-On, without previous consideration. Actually, in most cases it actually is... however, do not expect you can add all modules at the same time.

CaCu15 gives some background explanations:

SPI Bus (Serial Peripheral Interface bus) A four-line, synchronous, serial bus from Motorola that is widely used to connect a microcontroller to peripheral chips on a circuit board.

The ESP32 has 2 SPI buses available.

Several modules used by the OpenDTU, for example

  • MCP2515 CAN bus module for the Huawei AC charger
  • LRF24L01 Radio Board for HM- Inverters
  • CMT2300A Radio Board for HMT-/HMS- Inverters
  • various LCD Displays

use "SPI bus" for the connection.

The SPI supports in principle several SPI clients on the same bus, but this must be coded accordingly in the Software.

Currently, there are modules are "hardcoded" to one of the SPI buses:

The MCP2515 is hardcoded to SPI 2, see https://github.com/helgeerbe/OpenDTU-OnBattery/blob/development/docs/hardware_flash.md#mcp2515-can-bus-module

Currently the SPI bus host is hardcoded to number 2. This may change in future. Please note: Using the Huawei AC charger in combination with the CMT2300A radio board is not supported at the moment.

The CMT2300A is also fixed to an SPI, see https://github.com/helgeerbe/OpenDTU-OnBattery/blob/development/docs/hardware_flash.md#cmt2300a-radio-board--see-inverter-table-above-for-supported-inverters

The CMT2300A uses 3-Wire half duplex SPI communication. Due to this fact it currently requires a separate SPI bus. If you want to run the CMT2300A module on the same ESP32 as a NRF24L01+ module or a PCD8544 display, make sure you get a ESP which supports 2 SPI busses. Currently the SPI bus host is hardcoded to number 2. This may change in future.

In short, some combinations of controllers and displays are not supported at the moment.

Input Only / Output Only Pins

The picture above and the Pinout examples are illustrative. You can choose which ESP32 PINs you want to use as you like.

Please be aware, however, that you have to take care not to use the input-only pins for output tasks (ESP32 "input-only" pins are: GPIO 34/35/36/39, see picture).

U0 TX/RX and U2 TX/RX may require some attention, too.

U0 TX might be used as output PIN for example but, during Boot, there is debug output on the PIN. Subsequently, an Add-On connected to that PIN may receive unwanted erroneous commands during boot. Just a word of caution.

Clone this wiki locally