Skip to content

wiredlab/mqtt_esp8266_uart_bridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mqtt_esp8266_uart_bridge

Bidirectional bridge between a UART TX/RX port and MQTT topics.

Target is the ESP-01s board using the ESP8266.

Features

  • Bytes published to …​/stdin are sent out of the device UART’s TX pin.

  • Bytes received on the device UART’s RX pin are published to …​/stdout.

  • Device periodically publishes telemetry to …​/status.

  • Device subscribes to …​/control for commands.

MQTT topics

The base topic is constructed as:

  • PREFIX = MQTT_TOPIC_PREFIX + my_mac

Caution
Pay attention to the / separators!

The device uses the following subtopics for various purposes:

  • PREFIX/status — MCU publishes JSON-formatted telemetry here. See pub_status_mqtt(state) for the contents.

  • PREFIX/control — MCU subscribes to listen for configuration changes. (ignored for now)

  • PREFIX/stdin — MCU subscribes and passes payload as-is out of TX pin. MQTT handles the variable-length binary payload already. There is presently no extra framing added to the byte stream.

  • PREFIX/stdout — MCU publishes frames received on its RX pin. A frame is presently: bytes received within CHAR_TIMEOUT of each other and ended with a \n character (0x0A), which is not passed on.

TODO

  • There needs to be a better way to extract payload frames from the UART RX receive port. Presently it ignores \r, uses \n as a payload terminator (not passing on the \n to MQTT), and publishes after a timeout if no \n has been seen yet.

    • Consistent Overhead Byte Stuffing is a candidate.

    • But, it should be something that includes a start-of-frame also (in both directions), since the UART TX is also used for random debugging printf’s. Open to your suggestions!

About

MQTT to UART bridge via ESP8266

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published