Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serial data feature suggestion #2182

Closed
species5618 opened this issue Mar 17, 2018 · 10 comments
Closed

Serial data feature suggestion #2182

species5618 opened this issue Mar 17, 2018 · 10 comments
Labels
enhancement Type - Enhancement that will be worked on fixed Result - The work on the issue has ended

Comments

@species5618
Copy link

I have a use case where I would like to replace and old serial data radio with and esp8266 device using mqtt
It is not contious data stream, just a simple 8-16 chars every 60 seconds of so. So mqtt would be spot on

So my thinking is add support for serial comms in the generic device. Or any device where serial port is easily available

So any text reecived form rx port (with cr on end or Confiurable timeout)
Is forwarded over mqtt
And vice versa.

Baud rate would need to be configurable.
And probably disable boot messages

@Zixim
Copy link

Zixim commented Mar 17, 2018

try google?

"mqtt serial bridge esp8266"

@species5618
Copy link
Author

i have, and built a working protype, however it would be nice for all my iot devices to run the same core software

@Zixim
Copy link

Zixim commented Mar 17, 2018

do a pull request ?

Nice idea though, i can see usage cases for having the serial exposed through mqtt.

@arendst arendst added the enhancement Type - Enhancement that will be worked on label Mar 17, 2018
@arendst
Copy link
Owner

arendst commented Mar 17, 2018

Considering but see opportunities in regards to using the hardware serial for debugging...

I might choose to only support software serial but this needs testing.

@OTrumpf
Copy link

OTrumpf commented Mar 17, 2018

+1 for a serial connection in tasmota!

My use-case: gesture-detection with a dedicate Arduino + several sensors (e.g. IR-/Ultrasonic-sensors) with time critical functions and a serial connection to a tasmota-esp8266 for a bi-dicrectional exchange of MQTT commands.

Perhaps you can define a set of 5 - 10 MQTT-commands in the web interface which are transferred to the Arduino and pass every command from the Arduino to the MQTT-Broker. Example:

Write to Arduino ("IR_SENSOR" is defined in Web interafce):
"IR_SENSOR" --> cmnd/MyDevice/IR_SENSOR:text where "text" ist transferred to the Arduino as "IR_SENSOR:text"

Read from Arduino:
"USM_DISTANCE" --> tele?/MyDevice/USM_DISTANCE:100cm where "USM_DISTANCE:100cm" is transferred from the Arduino.

Software Serial would be fine for me and the text stream of the OP could be integrated via an optional default MQTT-command for received serial text.

arendst added a commit that referenced this issue Mar 18, 2018
5.12.0g
 * Add support for MQTT to hardware serial bridge using commands
Baudrate and SerialSend. Currently supports 8N1 and text only (#2182)
@arendst
Copy link
Owner

arendst commented Mar 18, 2018

Give it a go!

Use command SerialSend to send a text string terminated by tasmota with a \n (linefeed)
Use command SerialSend2 to send a text string without termination
Above command also disables serialloging

Expect responses on mqtt SerialReceived as a text string

Change baudrate with command Baudrate. This also impacts serialloging if/when enabled.

Note: only supported on hardware serial.

And it won't work (and has been disabled) on Sonoff Bridge, Dual (R1), CH4 and SC as they use the serial interface themselves.

@danielztolnai
Copy link

I needed a similar solution for some time to communicate with a projector so I gave it a try and created a software serial implementation (#2190). I hope it is relevant here.

@species5618
Copy link
Author

wow,

compiled using platform io into a ESP-01 , device config set to generic, ,with a DS18B20 on GPIO2
and it just works

still reads temperature and does the Serial port stuff , note the device i am connected to echos a GOOD Message,

/local/Clock/cmnd/Baudrate : 57600
/local/Clock/cmnd/SerialSend2 :aCLSD-0.8------
/local/Clock/stat/RESULT : {"SerialSend":"Done"}
/local/Clock/tele/RESULT : {"SerialReceived":"aCLSD-0.8---"}
/local/Clock/tele/SENSOR : {"Time":"2018-03-18T15:32:04","DS18B20":{"Temperature":22.1},"TempUnit":"C"}

fantastic ..

@danielztolnai
Copy link

danielztolnai commented Mar 18, 2018

I've added support for the transmission of whitespace characters in #2190 when they are escaped in the MQTT message. Also implemented a "delimiter character" functionality, so a single message (if defined) can be transmitted in a single MQTT message.

arendst added a commit that referenced this issue Mar 20, 2018
5.12.0h
 * Add support for Software Serial bridge using commands
SerialDelimiter, SBaudrate and SSerialSend. Supports 8N1 and text only
(#2190)
 * Add support for Hardware Serial bridge using commands
SerialDelimiter, Baudrate and SerialSend. Supports 8N1 and text only
(#2182)
@arendst arendst added the fixed Result - The work on the issue has ended label Mar 20, 2018
@charlietomo
Copy link

This looks great but I'm struggling to get things to work. Anything obvious wrong?

Wemos D1 running 5.12.0i with module set as Generic. Configuration:
TX GPIO1 Serial Out = 67 SerBr Tx
RX GPIO3 Serial In = 68 SerBr Rx

TX/RX and 3.3v are connected to a TTL-RS232 adaptor (like this) which is connected to my RS232 device.

I want to send command to the device (MQTT > Serial) and I also want the messages from RS232 to be delivered over MQTT (regardless of commands).

If I plug the RS232 device into a Raspberry pi with USB-RS232 adaptor I can confirm the device is sending output/takes commands.

I'm not seeing anything related to serial on the Tasmota console. Do I have to do anything specific to set things up?

@arendst arendst closed this as completed Jul 2, 2018
curzon01 pushed a commit to curzon01/Tasmota that referenced this issue Sep 6, 2018
5.12.0g
 * Add support for MQTT to hardware serial bridge using commands
Baudrate and SerialSend. Currently supports 8N1 and text only (arendst#2182)
curzon01 pushed a commit to curzon01/Tasmota that referenced this issue Sep 6, 2018
5.12.0h
 * Add support for Software Serial bridge using commands
SerialDelimiter, SBaudrate and SSerialSend. Supports 8N1 and text only
(arendst#2190)
 * Add support for Hardware Serial bridge using commands
SerialDelimiter, Baudrate and SerialSend. Supports 8N1 and text only
(arendst#2182)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Type - Enhancement that will be worked on fixed Result - The work on the issue has ended
Projects
None yet
Development

No branches or pull requests

6 participants