forked from flyte/mqtt-io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.md.j2
103 lines (76 loc) · 3 KB
/
README.md.j2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!--
***************************************************************************************
DO NOT EDIT README.md DIRECTLY, IT'S GENERATED FROM README.md.j2 USING generate_docs.py
***************************************************************************************
-->
# MQTT IO
{% if not repo -%}
_Documentation version: `{{ version }}`_
{% endif -%}
[![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.
{% if repo -%}
Visit the [documentation](https://mqtt-io.app/) for more detailed information.
{% endif -%}
## 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.
{%- for module_type, modules in supported_hardware|dictsort %}
### {{ module_type }}
{% for module_name, description in modules|dictsort %}
- {{ description }} (`{{ module_name }}`)
{%- endfor %}
{%- endfor %}
## Installation
_Requires Python 3.6+_
`pip3 install mqtt-io`
## Execution
`python3 -m mqtt_io config.yml`
## Configuration Example
Configuration is written in a YAML file which is passed as an argument to the server on startup.
{% if repo -%}
See the [full configuration documentation](https://github.com/flyte/pi-mqtt-gpio/wiki/Configuration) for details.
{%- endif %}
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
sensor_inputs:
# The configuration of the specific sensor value to use (LM75 only has temperature)
- name: porch_temperature
module: lm75_sensor
# Streams
stream_modules:
# A serial port to communicate with the house alarm system
- name: alarm_system
module: serial
device: /dev/ttyUSB0
baud: 9600
```