mqtt-io


Namemqtt-io JSON
Version 2.6.0 PyPI version JSON
download
home_pageNone
SummaryExpose GPIO modules (Raspberry Pi, Beaglebone, PCF8754, PiFace2 etc.), digital sensors (LM75 etc.) and serial streams to an MQTT server for remote control and monitoring.
upload_time2024-10-17 21:23:11
maintainerNone
docs_urlNone
authorEllis Percival
requires_python<4.0,>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <!--
***************************************************************************************
DO NOT EDIT README.md DIRECTLY, IT'S GENERATED FROM README.md.j2 USING generate_docs.py
***************************************************************************************
-->

# MQTT IO

[![Discord](https://img.shields.io/discord/713749043662290974.svg?label=Chat%20on%20Discord&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/gWyV9W4)

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](https://mqtt-io.app/) 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

  - Beaglebone GPIO (`beaglebone`)
  - Linux Kernel 4.8+ libgpiod (`gpiod`)
  - GPIO Zero (`gpiozero`)
  - MCP23017 IO expander (`mcp23017`)
  - Orange Pi GPIO (`orangepi`)
  - PCF8574 IO expander (`pcf8574`)
  - PCF8575 IO expander (`pcf8575`)
  - PiFace Digital IO 2 (`piface2`)
  - Raspberry Pi GPIO (`raspberrypi`)
  - XL9535/PCA9535/TCA9535 IO expander (`xl9535`)

### Sensors

  - ADS1x15 analog to digital converters (`ads1x15`)
  - ADXl345 3-axis accelerometer up to ±16g  (`adxl345`)
  - AHT20 temperature and humidity sensor (`aht20`)
  - AS3935 lightning detector (`as3935`)
  - BH1750 light level sensor (`bh1750`)
  - BME280 temperature, humidity and pressure sensor (`bme280`)
  - BME680 temperature, humidity and pressure sensor (`bme680`)
  - DHT11/DHT22/AM2302 temperature and humidity sensors (`dht22`)
  - DS18S20/DS1822/DS18B20/DS1825/DS28EA00/MAX31850K temperature sensors (`ds18b`)
  - ENS160  digital multi-gas sensor with multiple IAQ data (TVOC, eCO2, AQI) (`ens160`)
  - FLOWSENSOR generic flow rate sensor like YF-S201, YF-DN50 or others (`flowsensor`)
  - FREQUENCYCOUNTER Counts pulses from GPIOs and return the frequency in Hz (`frequencycounterr`)
  - HCSR04 ultrasonic range sensor (connected to the Raspberry Pi on-board GPIO) (`hcsr04`)
  - INA219 DC current sensor (`ina219`)
  - LM75 temperature sensor (`lm75`)
  - MCP3008 analog to digital converter (`mcp3008`)
  - PMS5003 particulate sensor (`pms5003`)
  - SHT40/SHT41/SHT45 temperature and humidity sensors (`sht4x`)
  - TSL2561 light level sensor (`tsl2561`)
  - VEML7700 light level sensor (`veml7700`)
  - YF-S201 flow rate sensor (`yfs201`)


### Streams

  - Serial port (`serial`)
  - PN532 NFC/RFID reader (`pn532`)

## 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:

- `MQTT_IO_HOST` - Host name or IP address of the MQTT server.
- `MQTT_IO_PORT` - Port number to connect to on the MQTT server.
- `MQTT_IO_USER` - Username to authenticate with on the MQTT server.
- `MQTT_IO_PASSWORD` - Password to authenticate with on the MQTT server.
- `MQTT_IO_PROTOCOL` - Version of the MQTT protocol to use.

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](https://github.com/flyte/pi-mqtt-gpio/wiki/Configuration) for details.

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

- Publish MQTT messages on the `home/input/doorbell` topic when the doorbell is pushed and released.
- Subscribe to the MQTT topic `home/output/port_light/set` and change the output when messages are received on it.
- Periodically read the value of the LM75 sensor and publish it on the MQTT topic `home/sensor/porch_temperature`.
- Publish any data received on the `/dev/ttyUSB0` serial port to the MQTT topic `home/serial/alarm_system`.
- Subscribe to the MQTT topic `home/serial/alarm_system/send` and send any data received on that topic to the serial port.

```yaml
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
```


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "mqtt-io",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Ellis Percival",
    "author_email": "mqtt-io@failcode.co.uk",
    "download_url": "https://files.pythonhosted.org/packages/1f/1d/8a7eba94575661cd0ffcf27fc3d4486deac59089b3787c5ca38ceb1af0d0/mqtt_io-2.6.0.tar.gz",
    "platform": null,
    "description": "<!--\n***************************************************************************************\nDO NOT EDIT README.md DIRECTLY, IT'S GENERATED FROM README.md.j2 USING generate_docs.py\n***************************************************************************************\n-->\n\n# MQTT IO\n\n[![Discord](https://img.shields.io/discord/713749043662290974.svg?label=Chat%20on%20Discord&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/gWyV9W4)\n\nExposes 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.\n\nVisit the [documentation](https://mqtt-io.app/) for more detailed information.\n\n## Supported Hardware\n\nHardware 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.\n\n### GPIO Modules\n\n  - Beaglebone GPIO (`beaglebone`)\n  - Linux Kernel 4.8+ libgpiod (`gpiod`)\n  - GPIO Zero (`gpiozero`)\n  - MCP23017 IO expander (`mcp23017`)\n  - Orange Pi GPIO (`orangepi`)\n  - PCF8574 IO expander (`pcf8574`)\n  - PCF8575 IO expander (`pcf8575`)\n  - PiFace Digital IO 2 (`piface2`)\n  - Raspberry Pi GPIO (`raspberrypi`)\n  - XL9535/PCA9535/TCA9535 IO expander (`xl9535`)\n\n### Sensors\n\n  - ADS1x15 analog to digital converters (`ads1x15`)\n  - ADXl345 3-axis accelerometer up to \u00b116g  (`adxl345`)\n  - AHT20 temperature and humidity sensor (`aht20`)\n  - AS3935 lightning detector (`as3935`)\n  - BH1750 light level sensor (`bh1750`)\n  - BME280 temperature, humidity and pressure sensor (`bme280`)\n  - BME680 temperature, humidity and pressure sensor (`bme680`)\n  - DHT11/DHT22/AM2302 temperature and humidity sensors (`dht22`)\n  - DS18S20/DS1822/DS18B20/DS1825/DS28EA00/MAX31850K temperature sensors (`ds18b`)\n  - ENS160  digital multi-gas sensor with multiple IAQ data (TVOC, eCO2, AQI) (`ens160`)\n  - FLOWSENSOR generic flow rate sensor like YF-S201, YF-DN50 or others (`flowsensor`)\n  - FREQUENCYCOUNTER Counts pulses from GPIOs and return the frequency in Hz (`frequencycounterr`)\n  - HCSR04 ultrasonic range sensor (connected to the Raspberry Pi on-board GPIO) (`hcsr04`)\n  - INA219 DC current sensor (`ina219`)\n  - LM75 temperature sensor (`lm75`)\n  - MCP3008 analog to digital converter (`mcp3008`)\n  - PMS5003 particulate sensor (`pms5003`)\n  - SHT40/SHT41/SHT45 temperature and humidity sensors (`sht4x`)\n  - TSL2561 light level sensor (`tsl2561`)\n  - VEML7700 light level sensor (`veml7700`)\n  - YF-S201 flow rate sensor (`yfs201`)\n\n\n### Streams\n\n  - Serial port (`serial`)\n  - PN532 NFC/RFID reader (`pn532`)\n\n## Installation\n\n_Requires Python 3.6+_\n\n`pip3 install mqtt-io`\n\n## Execution\n\n`python3 -m mqtt_io config.yml`\n\nSome configuration parameters can be passed as environment variables:\n\n- `MQTT_IO_HOST` - Host name or IP address of the MQTT server.\n- `MQTT_IO_PORT` - Port number to connect to on the MQTT server.\n- `MQTT_IO_USER` - Username to authenticate with on the MQTT server.\n- `MQTT_IO_PASSWORD` - Password to authenticate with on the MQTT server.\n- `MQTT_IO_PROTOCOL` - Version of the MQTT protocol to use.\n\nEnvironment variables take precedence over configuration files.\n\n## Configuration Example\n\nConfiguration is written in a YAML file which is passed as an argument to the server on startup.\n\nSee the [full configuration documentation](https://github.com/flyte/pi-mqtt-gpio/wiki/Configuration) for details.\n\nThe following example will configure the software to do the following:\n\n- Publish MQTT messages on the `home/input/doorbell` topic when the doorbell is pushed and released.\n- Subscribe to the MQTT topic `home/output/port_light/set` and change the output when messages are received on it.\n- Periodically read the value of the LM75 sensor and publish it on the MQTT topic `home/sensor/porch_temperature`.\n- Publish any data received on the `/dev/ttyUSB0` serial port to the MQTT topic `home/serial/alarm_system`.\n- Subscribe to the MQTT topic `home/serial/alarm_system/send` and send any data received on that topic to the serial port.\n\n```yaml\nmqtt:\n  host: localhost\n  topic_prefix: home\n\n# GPIO\ngpio_modules:\n  # Use the Raspberry Pi built-in GPIO\n  - name: rpi\n    module: raspberrypi\n\ndigital_inputs:\n  # Pin 0 is an input connected to a doorbell button\n  - name: doorbell\n    module: rpi\n    pin: 0\n\ndigital_outputs:\n  # Pin 1 is an output connected to a light\n  - name: porch_light\n    module: rpi\n    pin: 1\n\n# Sensors\nsensor_modules:\n  # An LM75 sensor attached to the I2C bus\n  - name: lm75_sensor\n    module: lm75\n    i2c_bus_num: 1\n    chip_addr: 0x48\n  # An INA219 sensor attached to the I2C bus\n  - name: ina219_sensor\n    module: ina219\n    i2c_bus_num: 1\n    chip_addr: 0x43\n\n\nsensor_inputs:\n  # lm75 - The configuration of the specific sensor value to use (LM75 only has temperature)\n  - name: porch_temperature\n    module: lm75_sensor\n  # ina219 - The configuration of the specific sensor value to use (4 options for the ina219 sensor)\n  - name: power\n    type: power\n    module: ina219_sensor\n  - name: bus_voltage\n    type: bus_voltage\n    module: ina219_sensor\n  - name: current\n    type: current\n    module: ina219_sensor\n  - name: shunt_voltage\n    type: shunt_voltage\n    module: ina219_sensor\n\n# Streams\nstream_modules:\n  # A serial port to communicate with the house alarm system\n  - name: alarm_system\n    module: serial\n    device: /dev/ttyUSB0\n    baud: 9600\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Expose GPIO modules (Raspberry Pi, Beaglebone, PCF8754, PiFace2 etc.), digital sensors (LM75 etc.) and serial streams to an MQTT server for remote control and monitoring.",
    "version": "2.6.0",
    "project_urls": {
        "Documentation": "https://flyte.github.io/mqtt-io/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2d31c7d84bd4535848c824c113182b760fa2b2916cffb1b5be96e44ac03a131e",
                "md5": "70221dcadab4524aa641714a46409117",
                "sha256": "f967c86a0aae0ffdf0de8ccb3b016c6eb29ee82a0740ce6fa1f6443245abc2c3"
            },
            "downloads": -1,
            "filename": "mqtt_io-2.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "70221dcadab4524aa641714a46409117",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 102714,
            "upload_time": "2024-10-17T21:23:10",
            "upload_time_iso_8601": "2024-10-17T21:23:10.269860Z",
            "url": "https://files.pythonhosted.org/packages/2d/31/c7d84bd4535848c824c113182b760fa2b2916cffb1b5be96e44ac03a131e/mqtt_io-2.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1f1d8a7eba94575661cd0ffcf27fc3d4486deac59089b3787c5ca38ceb1af0d0",
                "md5": "f0c4fa21b4122204bbd7ce2b24ed3519",
                "sha256": "df983d01eed3c46a6d3a59290186aeb3bc9ed05aaaa915c2519f5ae4beb75e92"
            },
            "downloads": -1,
            "filename": "mqtt_io-2.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f0c4fa21b4122204bbd7ce2b24ed3519",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 69238,
            "upload_time": "2024-10-17T21:23:11",
            "upload_time_iso_8601": "2024-10-17T21:23:11.909135Z",
            "url": "https://files.pythonhosted.org/packages/1f/1d/8a7eba94575661cd0ffcf27fc3d4486deac59089b3787c5ca38ceb1af0d0/mqtt_io-2.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-17 21:23:11",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "mqtt-io"
}
        
Elapsed time: 0.55961s