Serial
The serial
sensor integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] is using the data provided by a device connected to the serial port of the system where Home Assistant is running. With ser2net
socat
To check what kind of data is arriving at your serial port, use a command-line tool like minicom
or picocom
on Linux, on a macOS you can use screen
or on Windows putty
.
Configuration
To setup a serial sensor to your installation, add the following to your configuration.yaml
The configuration.yaml file is the main configuration file for Home Assistant. It lists the integrations to be loaded and their specific configurations. In some cases, the configuration needs to be edited manually directly in the configuration.yaml file. Most integrations can be configured in the UI. [Learn more] file.
After changing the configuration.yaml
The configuration.yaml file is the main configuration file for Home Assistant. It lists the integrations to be loaded and their specific configurations. In some cases, the configuration needs to be edited manually directly in the configuration.yaml file. Most integrations can be configured in the UI. [Learn more] file, restart Home Assistant to apply the changes. The integration is now shown on the integrations page under Settings > Devices & services. Its entities are listed on the integration card itself and on the Entities tab.
Configuration Variables
Number of data bits. Possible values: 5=FIVEBITS
, 6=SIXBITS
, 7=SEVENBITS
, 8=EIGHTBITS
.
Enable parity checking. Possible values: N=PARITY_NONE
, E=PARITY_EVEN
, O=PARITY_ODD
, M=PARITY_MARK
, S=PARITY_SPACE
.
Number of stop bits. Possible values: 1=STOPBITS_ONE
, 1.5=STOPBITS_ONE_POINT_FIVE
, 2=STOPBITS_TWO
.
value_template for Template sensor
TMP36
Examples
Arduino
For controllers of the Arduino family, a possible sketch to read the temperature and the humidity could look like the sample below.The returned data is in JSON format and can be split into the individual sensor values using a template.
Devices returning multiple sensors as a text string
For devices that return multiple sensors as a concatenated string of values with a delimiter, (i.e., the returned string is not JSON formatted) you can make several template sensors, all using the same serial response. For example, a stream from the Sparkfun USB Weather Board
To parse this into individual sensors, split using the comma delimiter and then create a template sensor for each item of interest.
Digispark USB Development Board
This blog post describes the setup with a Digispark USB Development Board.