flyte / mqtt-io

Expose GPIO modules (Raspberry Pi, Beaglebone, PCF8754, PiFace2 etc.) and digital sensors (LM75 etc.) to an MQTT server for remote control and monitoring.
MIT License
470 stars 159 forks source link
am2302 bananapi beaglebone beaglebone-black dht11 dht22 gpio gpio-pins home-assistant lm75 mqtt pcf8574 piface-digital python raspberry-pi raspberry-pi-gpio rpi

MQTT IO

Discord

Exposes general purpose inputs and outputs (GPIO), hardware sensors and serial devices to an MQTT server. Ideal for single-board computers such as the Raspberry Pi.

Visit the documentation for more detailed information.

Supported Hardware

Hardware support is provided by specific GPIO, Sensor and Stream modules. It's easy to add support for new hardware and the list is growing fast.

GPIO Modules

Sensors

Streams

Installation

Requires Python 3.6+

pip3 install mqtt-io

Execution

python3 -m mqtt_io config.yml

Some configuration parameters can be passed as environment variables:

Environment variables take precedence over configuration files.

Configuration Example

Configuration is written in a YAML file which is passed as an argument to the server on startup.

See the full configuration documentation for details.

The following example will configure the software to do the following:

mqtt:
  host: localhost
  topic_prefix: home

# GPIO
gpio_modules:
  # Use the Raspberry Pi built-in GPIO
  - name: rpi
    module: raspberrypi

digital_inputs:
  # Pin 0 is an input connected to a doorbell button
  - name: doorbell
    module: rpi
    pin: 0

digital_outputs:
  # Pin 1 is an output connected to a light
  - name: porch_light
    module: rpi
    pin: 1

# Sensors
sensor_modules:
  # An LM75 sensor attached to the I2C bus
  - name: lm75_sensor
    module: lm75
    i2c_bus_num: 1
    chip_addr: 0x48
  # An INA219 sensor attached to the I2C bus
  - name: ina219_sensor
    module: ina219
    i2c_bus_num: 1
    chip_addr: 0x43

sensor_inputs:
  # lm75 - The configuration of the specific sensor value to use (LM75 only has temperature)
  - name: porch_temperature
    module: lm75_sensor
  # ina219 - The configuration of the specific sensor value to use (4 options for the ina219 sensor)
  - name: power
    type: power
    module: ina219_sensor
  - name: bus_voltage
    type: bus_voltage
    module: ina219_sensor
  - name: current
    type: current
    module: ina219_sensor
  - name: shunt_voltage
    type: shunt_voltage
    module: ina219_sensor

# Streams
stream_modules:
  # A serial port to communicate with the house alarm system
  - name: alarm_system
    module: serial
    device: /dev/ttyUSB0
    baud: 9600