Giter Club home page Giter Club logo

esphome-modbus-server's Introduction

esphome-modbus-server

ESPHome Modbus Server component

Example configuration:

esphome:
  name: 'modbus-slave'

esp32:
  board: esp32dev
  variant: esp32
  framework:
    type: arduino
    version: '2.0.2'
    platform_version: '4.0.0'

external_components:
  - source: github://aj-nagrom/esphome-modbus-server@master
    refresh: 60s
    components:
      - modbus_server

# Enable logging
logger:
#  level: VERBOSE

# Enable Home Assistant API
api:
ota:
wifi:
  ssid: YourSSID
  password: YourPassword

uart:
  - id: intmodbus
    tx_pin: 13
    rx_pin: 16
    baud_rate: 9600
    stop_bits: 1
    data_bits: 8
    parity: NONE
    debug:
      direction: BOTH

modbus_server:
  - id: modbuserver
    uart_id: intmodbus
    address: 1 # slave address
    re_pin: GPIO32 # optional
    de_pin: GPIO14 # optional
    holding_registers:
      - start_address: 79 # starting register range
        default: 82 # default value for all those registers
        number: 10 # number of registers in the range
        on_read: | # called whenever a register in the range is read
          // 'address' contains the requested register address
          // 'value' contains the stored register value 
          ESP_LOGI("ON_READ", "This is a lambda. address=%d, value=%d", address, value);
          return value; // you can return the stored value or something else.
      - start_address: 200 # in this example we map register 200 to a switch
        number: 1
        on_write: |
          if(value)
            id(testswitch)->turn_on();
          else
            id(testswitch)->turn_off();
          return value;
        on_read: |
          return id(testswitch)->state ? 1 : 0;

switch:
  - platform: gpio
    pin: 2
    id: testswitch

esphome-modbus-server's People

Contributors

jpeletier avatar aj-nagrom avatar flomeyer avatar sibrenvasse avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.