zephyr_ha_mqtt_sample/README.rst

2.2 KiB

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> </head>

Modbus MQTT Gateway

Overview

This Zephyr application serves as an MQTT gateway, primarily designed to bridge Modbus devices with a Home Assistant instance. It connects to a WiFi network, obtains an IP address, and communicates with an MQTT broker.

Features

  • WiFi Connectivity: Connects to a specified WiFi network using credentials provided via Kconfig.
  • Network Configuration: Supports both DHCP and static IP addressing for flexible network integration.
  • MQTT Integration: Configured to communicate with an MQTT broker, with specific options for Home Assistant discovery.
  • Configurability: All major parameters, including WiFi, network, and MQTT settings, are configurable through Kconfig.
  • Simulation Support: Includes a script and configuration for running in a simulated environment (native_sim).

Configuration

The application is configured using Kconfig. Key options can be found in the "Home Assistant MQTT Options" menu.

  • WiFi Settings: - CONFIG_WIFI_SSID: The SSID of the WiFi network. - CONFIG_WIFI_PASSWORD: The password for the WiFi network.
  • Network Settings: - CONFIG_NET_DHCP: Enable or disable DHCP. - CONFIG_NET_IP_ADDR: Static IP address. - CONFIG_NET_IP_MASK: Static IP netmask. - CONFIG_NET_IP_GATEWAY: Static IP gateway. - CONFIG_NET_DNS_SERVER: Static DNS server.
  • MQTT Broker Settings: - CONFIG_HA_MQTT_BROKER_HOSTNAME: Hostname or IP of the MQTT broker. - CONFIG_HA_MQTT_BROKER_PORT: Port of the MQTT broker. - CONFIG_HA_MQTT_USERNAME: Username for MQTT authentication. - CONFIG_HA_MQTT_PASSWORD: Password for MQTT authentication.
  • Home Assistant Device Info: - CONFIG_HA_MQTT_NAME: Device name. - CONFIG_HA_MQTT_MANUFACTURER: Manufacturer name. - CONFIG_HA_MQTT_MODEL: Model name.

Building and Running

Building for Hardware (e.g., ESP32-C6)

System Message: WARNING/2 (<stdin>, line 53)

Cannot analyze code. Pygments package not found.

.. code-block:: shell

   west build -b esp32c6_devkitc_hpcore

Running in Simulation

A simulation can be run using the provided script:

System Message: WARNING/2 (<stdin>, line 61)

Cannot analyze code. Pygments package not found.

.. code-block:: shell

   ./run_sim.sh

This will build and run the application for the native_sim target.

</html>