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

RS232 command how it works ? #4558

Closed
betux69 opened this issue Mar 21, 2023 · 31 comments · Fixed by #4559 or #4283
Closed

RS232 command how it works ? #4558

betux69 opened this issue Mar 21, 2023 · 31 comments · Fixed by #4559 or #4283

Comments

@betux69
Copy link

betux69 commented Mar 21, 2023

Good morning,

First of all, I wanted to thank you for the incredible work done. I'm not a technician and I manage to create sensors in a simple way which seems amazing to me.

I want to turn my Epson video projector on and off with the rs232.
I followed this thread:
serialsend is unknown command · Issue #3351 · letscontrolit/ESPEasy · GitHub

The command I need to send is PWR ON.

There is very little documentation on the subject and not necessarily understandable by a beginner.

I use the console and not the rules to try to turn on the VP.

Question 1: Should a port be specified in the module Serial Server?

Question 2: I use the standard tx, rx. Some command notation there’s :
serialsend,1, the command. What is 1?

Question 3: Do you need "" in the command?
Exemple :
Serialsend, “PWR ON”
Or
Serialsend, PWR ON

Thanks a lot

Regards

@tonhuisman
Copy link
Contributor

For that to work, you need:

  • Disable/uncheck the Tools/Advanced option Enable Serial port, to free the serial port for use by plugins (this implies that you won't be able to view logging via usb-serial, as that always uses HWSerial0).
  • (optional: Hardware reset or power-cycle the ESP to free the serial port)
  • A Serial Server task defined to use HWSerial0 with the required serial settings like baud rate, data bits etc. and enable that task.
  • Send the command using serialsend,<any characters you need to send to the port>, so if quotes are needed, then these should be included (this plugin uses a more 'plain' way of fetching that data from the command, not the regular command parsing as described here).

NB: If you want to use different GPIO pins, so the regular serial logging is available (or if the above steps won't work), then on ESP8266 you can configure the task for Software Serial, or on ESP32 configure HWSerial1 or HWSerial2, using any available GPIO pin.

@betux69
Copy link
Author

betux69 commented Mar 21, 2023

thanks a lot for your answer.

point 1 done
point 2 done
point 3 :
Capture1

1234 is it good for tcp port ?

Command send : serialsend,"PWR ON"

and ... no response of the video projector ;o( grr !!

@tonhuisman
Copy link
Contributor

tonhuisman commented Mar 21, 2023

You might want to enable Process events without client option, but for sending that shouldn't matter.

Maybe the projector expects a CR or LF character at the end of the command, you could try the key-combination ctrl-M or ctrl-J for that, but I'm not sure if that'll work 🤔. There is only the regular special character translation available, where %R% and %N% would be converted into a CR and LF character.
And I think you will need to remove the quotes from your serialsend command.

@betux69
Copy link
Author

betux69 commented Mar 21, 2023

in the documentation there is : Add a Carriage Return (CR) code (0Dh)
How i can do what ?

@betux69
Copy link
Author

betux69 commented Mar 21, 2023

i tried

serialsend, %R% "PWR ON" %N%
serialsend, %R% PWR ON %N%
serialsend, PWR ON %N%
serialsend, PWR ON %R%

With an other software this command work
0xOD. »PWR ON »,OxOD

i think we're not far ... i hope ;o)

@tonhuisman
Copy link
Contributor

serialsend, PWR ON %R%

I would expect that this should work, but maybe there shouldn't be a space before PWR and between ON and %R%. (Computers can be quite picky about these extra characters 😉)
If the CR before the command is needed, it would then be serialsend,%R%PWR ON%R%

Is there a way you can monitor if the sent data is actually received at the projector?

@betux69
Copy link
Author

betux69 commented Mar 21, 2023

it doesn't work.
i think your right i need to find a way to check the signal.

@tonhuisman
Copy link
Contributor

You can also try to switch to Software Serial, that allows to select the GPIO pins, so it is not 'hindered' by the regular Serial pins (that have a tendency to quite stubbornly keep hanging on to the default RX/TX pins, locking them for use by a plugin like Serial Server). 9600 baud should be handled correctly via Software Serial.

@TD-er
Copy link
Member

TD-er commented Mar 21, 2023

Maybe also check to see if the logic levels are correct.
The ESP may not be able to send a logic "1" higher than 3.3V and perhaps your device needs higher logic levels.

A level converter may be required here (or simply using a transistor and 5V)

@betux69
Copy link
Author

betux69 commented Mar 21, 2023

i see what you both mean, thanks !
i'm going to work on what ways, keep in touch ;o)

@betux69
Copy link
Author

betux69 commented Mar 21, 2023

Is it possible to send this : 0x50,0x57,0x52,0x20,0x4F,0x4E,0x0D ?

@tonhuisman
Copy link
Contributor

Is it possible to send this : 0x50,0x57,0x52,0x20,0x4F,0x4E,0x0D ?

But that would be exactly like sending serialsend,POW ON^M (where that ^M would be you, typing the keys).

That's not supported yet, but there is a similar PR open to support that kind of command in the P087 Serial Proxy plugin, though that's not yet ready to be merged.
It would be nice to have that also in this plugin, I'll have a look at that. Probably will be a different command, for backward compatibility, where you could combine (quoted) plain text and decimal or hex values transformed to ASCII.

Did you see the sent signal being received by the projector?

@betux69
Copy link
Author

betux69 commented Mar 21, 2023

the command serialsend is link to this project ?
https://batchloaf.wordpress.com/serialsend/

Not yet i need some stuff to test the signal

@betux69
Copy link
Author

betux69 commented Mar 21, 2023

what is serial proxy plugin ? should u use it for my case ?

@TD-er
Copy link
Member

TD-er commented Mar 21, 2023

SerialProxy was originally intended to receive strings from the serial port and forward them to a MQTT controller.
You can send data to the serial port with that plugin, but I doubt it is better suited for this than the one you're already trying to use now.

I wonder if you need to wrap the command arguments in "" since you're using spaces in the strings you try to send.
Or if you need to use "" in the string itself, you could try to wrap the command argument in other quotes like a single quote or backtick.

@tonhuisman
Copy link
Contributor

I wonder if you need to wrap the command arguments in "" since you're using spaces in the strings you try to send.

No, this plugin doesn't use parseString(), but a simple substring(11) for the remainder of the arguments.

@tonhuisman
Copy link
Contributor

the command serialsend is link to this project ?
https://batchloaf.wordpress.com/serialsend/

No, serialsend in ESPEasy is a complete local interpretation of that concept, implemented explicitly in this plugin.

@tonhuisman
Copy link
Contributor

tonhuisman commented Mar 21, 2023

@betux69 I have added a new command serialsendmix to P020 Serial Server, that supports the suggested syntax, please see the [P020] PR linked above for details (actual documentation is to do).
You can test by downloading from this Actions run, once that's finished.

Edit: Removed outdated link.

@tonhuisman
Copy link
Contributor

@betux69 I've made a few small improvements to the code, so a new build is getting ready, in this GH Actions run.
Please test this latest build once it's completed, TIA!

@betux69
Copy link
Author

betux69 commented Mar 24, 2023

when I put the rs232 output on the oscilloscope I have a signal without me doing anything.
I connected the rx of the max232 module to the rx of the esp and the tx of the rs232 module to the tx of the esp.
If I cross rx and tx I have no signal.

espeasy

i'm going to install your firmeware. Thanks a lot !

@betux69
Copy link
Author

betux69 commented Mar 24, 2023

a precision when I send a command I see it on the oscilloscope and after the default signal is sent again.

@tonhuisman
Copy link
Contributor

Looking at the scale the scope is using (5.00V), and the height of the signal level, maybe you need to use a level converter (as suggested before) to get the signal on the projector input on +/- 12V, the regular RS232 signal level. Most likely the signal you show isn't enough to be accepted/recognized by the projector.

@betux69
Copy link
Author

betux69 commented Mar 24, 2023

With you're built i have no signal when i send nothing.
good point !

@betux69
Copy link
Author

betux69 commented Mar 24, 2023

do you have an exemple of serialsendmix command ?

@betux69
Copy link
Author

betux69 commented Mar 24, 2023

we're going to see to send 12v ;o)

@betux69
Copy link
Author

betux69 commented Mar 24, 2023

i tried this :
Command unknown: serialmixt,0xOD"PWR ON"OxOD

@tonhuisman
Copy link
Contributor

tonhuisman commented Mar 24, 2023

There is an explanation in the documentation, but that Sphinx source code isn't that readable, so here's a screenshot:

Screenshot - 24-03-2023 , 15_52_48

So essentially: serialsendmix,0x0D,"PWR ON",0x0D

@betux69
Copy link
Author

betux69 commented Mar 24, 2023

i put max3232 to 5V it's better but it doesn't work yet.
Next try monday ;o)

espeasy

@betux69
Copy link
Author

betux69 commented Apr 3, 2023

Sorry to be late a lot of work.

It's working !!!!!!!!!!!!
You're awesome thanks a lot !!!!!

This would be in the next firmeware ?

BIG THANK YOU

@betux69
Copy link
Author

betux69 commented Apr 3, 2023

Gosh! i've a little problem ..
Power On is working but power off not.
How is it possible ?

i send :
serialsendmix,0x0D,"PWR OFF",0x0D

@betux69
Copy link
Author

betux69 commented Apr 3, 2023

Found 👍

serialsendmix,"PWR OFF",0x0D
serialsendmix,"PWR ON",0x0D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants