Skip to content

Arduino sketch for modbus implementation of sensor, switch and thermostat to use with Home Assistant

Notifications You must be signed in to change notification settings

RaggedPi/ArduinoModBusHomeAssistant

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

ArduinoModBusHomeAssistant

Arduino sketch for modbus implementation of sensor, switch and thermostat to use with Home Assistant. This code make the arduino (I've used an a 5V nano) act a Modbus device than can be connected to a Home Assistant controller. Connectione can be made via a usb cable or via 485 bus. Only in this mode you can connect more than a device and with long cables (more than 1000m). Home Assistant deals with 4 types of device:

  • binary sensors (digital readonly inputs)
  • Temperature sensors
  • Switch (or coils in Modbus language: digital output that can also be read)
  • Climate (a block that act as a thermostat)

This arduino can be 1 or all of these object: it can be a temperature sensor if a sensor is connected. Can be a Climate (sensor also needed). Can read up to 16 inputs and control up to 16 outputs (this arduino have less this number of pins). The temperature read by sensor is mapped in the current_temp_register that can be read by HA. Inputs and outputs are mapped to binary_inputs register and binary_outputs register respectively.

See electical schematic for details.

This hardware can serve to many goals: it can be a headless remote actuator (a switch) to control a load (a lihgt, a motor, etc) it can be a headless remote sensor for temperature reading of to check magnetic sensors it can have a display and buttons to show temperature or control lighs or other devices

Modbus registers map All registers are 16 bits wide

reg# reg name function 0 TARGET_TEMP_REGISTER_LOW setpoint temperature 1 TARGET_TEMP_REGISTER_HIGH 2 CURRENT_TEMP_REGISTER_LOW current tempperature read by sensor 3 CURRENT_TEMP_REGISTER_HIGH 4 BINARY_INPUTS read the inputs connected (read only) 5 BINARY_OUTPUTS read and set the outputs connected 6 BINARY_OUTPUTS_LIGHTS read and set the outputs connected (a light output is also controlled by a pin connected to a switch button)

About

Arduino sketch for modbus implementation of sensor, switch and thermostat to use with Home Assistant

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 100.0%