[RS232] add JSON parsing and hardware serial support to RS232 gateway (#1409)
* add JSON parse option to RS232 gateway * add hardware UART support to RS232 gateway * changed default RS232toMQTTmode to raw (instead of JSON) * removed reference to Arduino Mega in RS232 gateway config * update RS232 gateway doc
This commit is contained in:
1 parent
c1afc02ffe
commit
6e3e8c3330
3 files changed
+266
-31
No files matched your search
@@ -1,5 +1,7 @@
|
||||
# RS232 gateway
|
||||
|
||||
The RS232 gateway can be used to send and receive data from the serial connection to and from MQTT. Both softwareSerial as hardwareSerial are supported. HardwareSerial can be used for higher baud rates, but is limited to specific pins on most platforms.
|
||||
|
||||
## Sending an RS232 message
|
||||
|
||||
Simply publish the message you wish to transmit, minus the prefix and postfix. For example, to send the "Turn On" signal for a Mitsubishi XD221U projector, the code is simply '!' so you would use the command
|
||||
@@ -8,7 +10,12 @@ Simply publish the message you wish to transmit, minus the prefix and postfix. F
|
||||
|
||||
It will automatically add the prefix and postfix you set in [config_RS232.h](https://github.com/1technophile/OpenMQTTGateway/blob/master/main/config_RS232.h).
|
||||
|
||||
|
||||
## Receiving an RS232 message
|
||||
|
||||
Two modes are available for receiving RS232 messages.
|
||||
|
||||
### Single MQTT message mode (default)
|
||||
To receive a message, subscribe to all with `mosquitto_sub -t +/# -v`
|
||||
and perform an action that should get a response from the device. For example, If I were to send the "Turn On" signal from earlier, I would receive back
|
||||
|
||||
@@ -21,3 +28,29 @@ Because this projector echoes back a received command to acknowledge. Some devic
|
||||
```json
|
||||
home/OpenMQTTGateway/RStoMQTT {"value":"!:N"}
|
||||
```
|
||||
|
||||
### JSON mode
|
||||
This mode can be used if the received message on the serial link is JSON. The JSON keys are used as separate MQTT sub-topics. For nested JSON this will be repeated for sub-keys up to the specified nesting level.
|
||||
|
||||
For example:
|
||||
|
||||
input received at serial link:
|
||||
```json
|
||||
{temperature: {sens1: 22, sens2: 23}, humidity: {sens1: 80, sens2: 60}}
|
||||
```
|
||||
|
||||
|
||||
output in case of max nesting level 1:
|
||||
```json
|
||||
home/OpenMQTTGateway/RS232toMQTT/temperature "{sens1: 22, sens2: 23}"
|
||||
home/OpenMQTTGateway/RS232toMQTT/humidity "{sens1: 80, sens2: 60}"
|
||||
```
|
||||
|
||||
output in case of max nesting level 2 (or higher):
|
||||
```json
|
||||
home/OpenMQTTGateway/RS232toMQTT/temperature/sens1 22
|
||||
home/OpenMQTTGateway/RS232toMQTT/temperature/sens2 23
|
||||
home/OpenMQTTGateway/RS232toMQTT/humidity/sens1 80
|
||||
home/OpenMQTTGateway/RS232toMQTT/humidity/sens2 60
|
||||
```
|
||||
|
||||
Reference in new issue
Block a user