I2C
The I2C module provides access to I2C/SMBus devices via the Linux kernel driver.
Don’t forget to install the requirements
pip3 install -r requirements/i2c.txt
Attention
You must have the I2C Kernel module installed and configured for this module to work. This process will vary based on the board and operatering system you are using.
Permissions
A udev
rule file is provided to simplify access permissions for I2C buses.
First add the i2c
group if it does not exist and add the user running
MQTTany to the i2c
group:
sudo addgroup --system i2c
sudo usermod -aG i2c mqttany
Then install the udev
rule and reboot:
sudo cp udev/98-i2c.rules /etc/udev/rules.d/
sudo reboot now
Devices
See the device pages below for details on each one and to see any additional options available.
Paths
Device IDs are used as the nodes in this module, giving paths like
{device-id}/{property-id}
. The device pages give more detail on the properties
they provide.
Path |
Description |
---|---|
|
The polling interval will be published here
with |
|
Sending any message (even blank) here will poll all configured devices to publish their current states. |
|
Device address will be published here with
|
Configuration
Optional settings are commented out with default values shown.
i2c:
#polling interval: 60
device-id:
#name: '{device_id}'
device: ''
#bus: 1
address: 0x
Module Settings
Option |
Description |
---|---|
|
Interval in seconds to publish all device states. Optional, default |
Device Definition
Device configuration section names must be unique throughout the config file as they
are used as node IDs. Node IDs can only contain lowercase letters a-z
, numbers
0-9
, and hyphens -
. The following settings are for device definitions:
Option |
Description |
---|---|
|
Friendly name for the device Substitutions:
Optional, default |
|
Device model, see Devices for available options. |
|
I2C bus ID or full path to bus Optional, default |
|
7-bit hex address of the device (Ex. |