letscontrolit / ESPEasy

Easy MultiSensor device based on ESP8266/ESP32
http://www.espeasy.com
Other
3.22k stars 2.19k forks source link

Generic RS232 plugin #539

Closed Grovkillen closed 10 months ago

Grovkillen commented 6 years ago

My projector, my receiver, and my tv all have serial communication over RS232 (different physical ports though). I have an idea of a generic RS232/Serial plugin which let you control devices that have this interface, and maybe even monitor its status. Would it be possible to create such a plugin or does it need to be unit specific? My hope was to have a ESP Easy unit connected to these devices and have them controlled using MQTT and rules? Is this to much to ask for? :)

Just as info: My tv got this connection (EX-link aka Service Port) and accept these commands. My projector got this connection and accept these commands. My receiver got this connection and accept these commands.

Inspiration video :)

The cables are easy to make yourself but the hard part might be to create a generic plugin? Feel free to comment! :)

TD-er commented 6 years ago

What are the signal levels required for these devices? RS232 is so old, its original standard even required negative voltage signals, but later devices were more 'friendly' and accepted TTL levels.

But still, TTL levels are up-to 5V, so you maybe also need a level converter. And you may need a lot of settings, so maybe some kind of profile per device may be useful.

Grovkillen commented 6 years ago

Ah, yes different profiles would be a way of doing it. I haven't studied my particular devices yet so I don't know the voltage levels.

mikeluyten commented 6 years ago

I'm currenty doing this via http commands http://10.0.0.15/control?cmd=serialsend,* 0 IR 001

This sends the command "* 0 IR 001" over the tx pin; Which is then hooked up to a TTL to RS232 converter from AliExpress (https://www.aliexpress.com/item/MAX3232-RS232-to-TTL-Serial-Port-Converter-Module-DB9-Connector-MAX232/32353317234.html)

Regardless of the connector, if it says serial or RS232, you will need a TTL to RS232 converter of some kind due to the floating ground used in RS232 signals, and the potentially -25v to +25v.

Grovkillen commented 6 years ago

Great, will try that and see if it is easy enough for end users (if so I will add it to the wiki).

Grovkillen commented 6 years ago

I have now installed this at home but I'm unable to control my projector. I suspect that the baud rate might be an issue? The projector expects 9600 but my TTL-RS232 is okay with higher baud rates than that. What's the baud rate ESP Easy is communication on by default?

https://www.aliexpress.com/item/10PCS-Serial-Port-Mini-RS232-to-TTL-Converter-Adaptor-Module-Board-MAX3232-115200bps/2038558345.html?spm=a2g0s.9042311.0.0.qjHCM7

mikeluyten commented 6 years ago

11200 I believe is the default, you can change this under Tools -> Advanced -> Baud Rate. Then restart your esp

TD-er commented 6 years ago

Make sure you connect the Rx of the ESP board to the TX of the projector and vice verse.

And for RS232 communication, you also should take the number of start and stop bits and parity into account.

Sometimes you have to add some dummy value to "wake" the device and allow for synchronization. Can you control the projector from a PC? If so, you can try to capture the data using some tools like GPSgate, which split the COM port in software.

Grovkillen commented 6 years ago

Thanks for your suggestions. I will try to control it from a PC first. Good advice. It might be something that I need to do to "trigger" the activity on the RS232 side on the projector.

TD-er commented 6 years ago

A very commonly used value to 'pre-trigger' communications is to send several 0xFF (8 times '1') or 0xA5 (10100101). So if you see that at the start of a message, you know why that's needed :)

rr10 commented 5 years ago

Summarize of the problem/feature request would like to make an adapter from rs232 to mqtt. I need this adapter to read the data provided by a barcode scanner with rs232 port (female). Can I do it with espeasy? I also bought a rs232 (female) to ttl (max232) converter and a rs232 male to male adapter. how can I do?

https://www.aliexpress.com/store/product/MAX3232-RS232-to-TTL-Serial-Port-Converter-Module-DB9-Connector-MAX232/1504763_32842352700.html

https://www.aliexpress.com/store/product/9-Pin-RS-232-DB9-Male-to-Male-Serial-Cable-Gender-Changer-Coupler-Adapter/502834_686740151.html

http://www.letscontrolit.com/forum/viewtopic.php?f=2&t=5697

do not have experience of plugins of this type, I would like to learn a lot but at this moment I have short time. if someone wanted to implement the plugin I would be willing to make an economic contribution and I would like the plugin to be used by the whole community

ShardanX commented 5 years ago

Agree. A two-way ser2net would be very appreciated so you could send and receive RS232 from ant to WiFi, It's not only TV sets, HiFi and such, we have some sensors using serial for example. Some devices are just rare so a plugin for every device would be overkill in my opinion. Most home controls like FHEM, OpenHAB domotics etc can be extended easily with some lines of code. So it should be possible to just send/receive raw data via the ESP and let the controler do the work. MQTT would be a way, maybe http too.

BTW it is same with I²C. A generic I²C would allow to test and use sensors etc that are not implemented.

Both would be a powerfull extension that makes ESPEasy really universal

TD-er commented 5 years ago

Would it also make sense to make the ESP as "wireless bridge"? One on the "PC" side, and one on the device side.

ShardanX commented 5 years ago

Hm.... Usually a nowadays PC has a connection via Wifi or LAN. For rare sensors or devices it's not the big difference if i get data from MQTT, html or RS232 as long as I can use data in home control server. From another point of view: For a TV or Hifi or such that have it's own software on PC this might be helpfull as it could replace a long cabling.

ShardanX commented 5 years ago

Just some ideas i just ran into: (for a much later release, really)

On long view ressources are limited.. Flash isn't unlimited, and ram is a even more limited ressource. They can't take all and every possible device users may want on a long time view.

One way out might be a compilation on demand, just compiling the plugins needed into a binary. Complex to realize via a web page, and definitely not the darling for most users, on top self compiling this way is nearly impossible to support.

Such generic plugins might be a way out. They should be reusable so roughly one generic plugin for I²C could serve nearly any I²C device. There should be configuration samples so the plugin is easy to handle. Optimal case would be loadable configurations similar to loading rules from a file...

One could even think of a combination, use the nowadays plugins for the most wanted devices (BME-Sensors, I²C-Displays...) and do the other stuff with generic plugins. This would allow a smooth change from today's state to generic plugins.

(To keep that clear - it's just a raw idea to be discussed....)

Have a nice 2nd Advent, all of you.

uzi18 commented 5 years ago

Just teach controller how to send/receive serial data, for mqtt it could be mqtt import plugin

tparvais commented 5 years ago

Hello How can I send a serie of Hexa values to control my videoprojector ? I need to send 0x08 0x22 0x00 0x00 0x00 0x16 via serialsend command ? thanks

Tobias007 commented 5 years ago

Hi, you can pass it via URL: http://192.168.4.1/control?cmd=serialsend,%A0%01%A1 however it doesn't work, if you want to send 0x00 as this is interpreted as end of string... I fear without developing e.g. a serialsendhex command it's not possible to send 0x00...

foice commented 4 years ago

My projector got this connection and accept these commands.

You have got a broken link for the commands accepted by your projector (which seems to be a EMP TW-700, isn't it?)

Grovkillen commented 4 years ago

Yep it's a TW-700. I haven't gotten around to fiddle more with this though.

foice commented 4 years ago

Got you! : ) Are you saying that you were not successful in operating it via RS232? I have just connected it to my FTDI232 but the projector seems to not really be talking to the chip. I can set the speed at 9600 but so far I get nothing when I turn on the projector on my terminal. Any suggestion on how to connect the projector to my OS X or linux terminal?

tonhuisman commented 10 months ago

With all the serial communication stuff we have available, this is no longer relevant. Can be closed.