how to connect esp32 to other device by RS232?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
pitrio
Normal user
Posts: 26
Joined: 23 Apr 2018, 16:49

how to connect esp32 to other device by RS232?

#1 Post by pitrio » 16 Jan 2024, 19:29

dear all,
sorry for my question, i'm tried to search similar topics on forum, but i do not found a solution for my problems.
The question is:
I would connect an ESP32 to an other device by RS232. For testing I'm tring to use Arduino Due that can send and receive data via RX1/TX1 for example.

on the other side, I use ESP mini D1, loaded with this firmware: ESP_Easy_mega_20231225_normal_ESP32_4M316k.

I have configured (I suppose...) "serial server" on HW Serial2 (16 RX - 17 TX) with some Baud rate and parity and so on...
Now, if I have undestand well (and for this I'm not sure), for send and recieve, I have to use command inside "rules". it'nt?

my problems are:
1)
to send data on serial port HW2, what command i have to use?
Becouse i saw just "serialsend".. but what do this command? and where send? on console seem...
2)
to receive data from serial2, (sent from Arduino in that case), waht should i use? I saw a lot of example that use:

On serial...
---
endon

but nothing happens. The exact sintax where i can find?

thank yuo in advance!!

User avatar
Ath
Normal user
Posts: 3521
Joined: 10 Jun 2018, 12:06
Location: NL

Re: how to connect esp32 to other device by RS232?

#2 Post by Ath » 16 Jan 2024, 21:01

The documentation for Serial Server (P020) can be found here: https://espeasy.readthedocs.io/en/lates ... #p020-page

The SerialSend command (documented on that same link) will send to the port configured in the task, so if you have set that for Serial2, it will send the output there.
You can type the commands in the Command field on the Tools page, but that will quickly become tedious and hard to repeat, so it will probably be easier to send from Rules. You have probably already found the Tools/Advanced checkbox to enable that ;)

The plugin is often used to receive data from a serial device, to be consumed by an application that connects to the configured network port (default: 1234), if nu consumer is connected there, no data will be sent or processed unless the "Process events without client" checkbox is enabled, and "Event processing" should then also be set, Generic will do for testing, later you might want to change that.

That data can then also be found in the log, either via a Serial0 / USB serial connected terminal or on the Tools/Log weblog page.
/Ton (PayPal.me)

pitrio
Normal user
Posts: 26
Joined: 23 Apr 2018, 16:49

Re: how to connect esp32 to other device by RS232?

#3 Post by pitrio » 18 Jan 2024, 17:35

dear all,
thank you for your answers,
of course i saw the link and many many other :-( but still i have problems...

1)
for example:
if I do this on rules:

On Rules#Timer=1 do
serialsend 123.456
timerSet,1,3
endon

this, just send data 123.456 on console (I also can see on terminal on Arduino IDE) and do not send on real TX/RX (I check this by using an arduino attached on serial interface.

2)
on the orther side, i can see the data that send arduino on serial interface, becouse on the console i saw this:

EVENT: !Serial#mandato da arduino... H:3.40T:5.40

my Arduino sent <mandato da arduino... H:3.40T:5.40>.
but if on rule i wrote this:

On !Serial# do
TaskValueSet 9, 1, ((%syssec%/59)*16)+1 //pseudo..pseudo random
endon

on task 9 I cannot see nothing. Like if event is not recognized.

thank you

User avatar
Ath
Normal user
Posts: 3521
Joined: 10 Jun 2018, 12:06
Location: NL

Re: how to connect esp32 to other device by RS232?

#4 Post by Ath » 18 Jan 2024, 20:08

You have a few things mixed up:

1) You can not use the Serial0 connection and the console log active on the same port. This will cause issues like you are seeing. Either use a different Serial port for the task, or disable the serial log (Tools/Advanced: "Enable Serial Port Console" unchecked, save and reboot).

2) "on !Serial# do" will only trigger when the "Serial" event is triggered without data. That's never going to happen, so the # has to be removed for it to be triggered. Then use %eventpar% to get at the data after the #
/Ton (PayPal.me)

pitrio
Normal user
Posts: 26
Joined: 23 Apr 2018, 16:49

Re: how to connect esp32 to other device by RS232?

#5 Post by pitrio » 18 Jan 2024, 22:41

ciao,
1)
I use Serial2 for "my connection" (I have configured on serial server task) and not serial0... serial0 i leave just for check what happens ... Why i have to disable Log if I use Serial2 ?

2)
the things is that "on !Serial# do" do not trigger when arrive data frome Serial2 (sent by arduino). Happen that for a few time trigger... and after some minuts stop to work and no more trigger happen. Why?

3)
why serialsend do not sent no data on Serial2 ? I don't see anything... not on console... not on input of arduino.
(if I use 2 arduino of course communicate each other.

I don't understand is the thing is so simple why i cannot find no working example about this? :(((

thank you in advance

pitrio
Normal user
Posts: 26
Joined: 23 Apr 2018, 16:49

Re: how to connect esp32 to other device by RS232?

#6 Post by pitrio » 21 Jan 2024, 20:32

good evening,

someone can still help me with this problems?

thank you in advance.

ricc

User avatar
Ath
Normal user
Posts: 3521
Joined: 10 Jun 2018, 12:06
Location: NL

Re: how to connect esp32 to other device by RS232?

#7 Post by Ath » 21 Jan 2024, 21:17

pitrio wrote: 18 Jan 2024, 22:41 1)
I use Serial2 for "my connection" (I have configured on serial server task) and not serial0... serial0 i leave just for check what happens ... Why i have to disable Log if I use Serial2 ?
OK

A few more questions, as not all is clear to me.
pitrio wrote: 18 Jan 2024, 22:41 2)
the things is that "on !Serial# do" do not trigger when arrive data frome Serial2 (sent by arduino).
Does this not trigger at all, or stops triggering after a few messages?
pitrio wrote: 18 Jan 2024, 22:41 Happen that for a few time trigger... and after some minuts stop to work and no more trigger happen. Why?
This remark makes me ask the previous question, I don't understand what you are saying exactly.
Do you have "Event processing" set to something other than None?
Do you have the setting "Process events without client" enabled?
It is advised to have an "RX Receive Timeout(mSec)" setting (10 to 50 msec), is that set?
pitrio wrote: 18 Jan 2024, 22:41 3)
why serialsend do not sent no data on Serial2 ? I don't see anything... not on console... not on input of arduino.
(if I use 2 arduino of course communicate each other.

I don't understand is the thing is so simple why i cannot find no working example about this? :(((

thank you in advance
The SerialSend command is sending out data on the port configured in the task, at the baud rate that is set there. There is no log output when sending a command.
Is your Arduino using the same baud rate?
/Ton (PayPal.me)

pitrio
Normal user
Posts: 26
Joined: 23 Apr 2018, 16:49

Re: how to connect esp32 to other device by RS232?

#8 Post by pitrio » 25 Jan 2024, 12:53

hi,
thank you for you time!

From one side, I use Arduino Due (Serial1, 3.3 volt... so to avoid level translator) of course with the same baud rate of ESP32.

Communication - Serial Server is set like this:
serial2
Event processing: generic
Process events without client: marked
RX buffer size (bytes): 256
RX Receive Timeout (mSec): 10

1)
Arduino Due send one time at second this string: "da ard mandato... H:9.00T:1.50"

on Rulus of ESP32 i have:

On !Serial* do
TaskValueSet 9, 1, ((%syssec%/59)*16)+1 //pseudo..pseudo random
TaskValueSet 9, 2, "%eventvalue%"
Publish, pannelli_solari/prova, "%eventvalue%"
Publish, pannelli_solari/prova1, "come ti chiami 123.456"
endon

on the console (but I can see the same things also on the serial monitor of Arduino IDE connected with ESP32 ... )) I can se that there are serial trigger but with some problem:

Generally works and I can see this:
------
EVENT: !Serial#da ard mandato... H:8.40T:7.10
ACT : Publish, pannelli_solari/prova, "!Serial#da ard mandato... H:5.00T:5.40"
ACT : Publish, pannelli_solari/prova1, "come ti chiami 123.456"
------
but I saw that the data received from serial2, "some time" are not complete, they are truncate... like if ESP32 receieve data just partially. (does not change if i use 9600 or 115200)
------
EVENT: !Serial#da ard mandato... H:
EVENT: !Serial#8.40T:7.10
------
I'm also try to upload firmware on ESP32 many times (each time that upload firmware, i use blank firmware before) and I saw that serial2 some time works fine and some time no. why?
Now I have a situation that ESP32 can receive well data that come from Arduino, I also publish on MQTT server (check also with MQTT-explorer)

Why happen this?
you consider that EspEasy is configured with just 2 devices, one Dummy generic device and one Communication-Serial Server.


2)
to send data from ESP32 to Arduino...
I put on Rules this:

On Rules#Timer=1 do
serialsend 123.456
timerSet,1,3
endon

but nothing happens, what i can do?
Arduino is listening on TTY with the same baudrate of corse.
just for complete the description... if I connect another Arduino Due (instead of ESP32), boths works fine and communicate eachother

3)
I also saw one problem:
If I have "Communication - Serial Server" (on Hserial2) task enabled, I cannot send serial command through serial command console of ESP32. For example reset, reboot, WifiSSID ...
No commands are received and executed from ESP32.
But if I disable "Communication - Serial Server" task the serial command works again.
You consider that on consolle I can see data output from ESP32 all time... but stop to works like input when serial interface it's enabled.
It's normal?

Can you help me in some way? thank you in advance.

ricc

pitrio
Normal user
Posts: 26
Joined: 23 Apr 2018, 16:49

Re: how to connect esp32 to other device by RS232?

#9 Post by pitrio » 30 Jan 2024, 21:59

dear all,
someone have some other hints to resolve this problems?

thank you in advance

ricc

User avatar
Ath
Normal user
Posts: 3521
Joined: 10 Jun 2018, 12:06
Location: NL

Re: how to connect esp32 to other device by RS232?

#10 Post by Ath » 30 Jan 2024, 22:28

Due to time-constraints I've not yet been able to replay your scenario, though I'm trying to schedule time for that this weekend (ESPEasy is not my day-job...). No ETA though :|
/Ton (PayPal.me)

pitrio
Normal user
Posts: 26
Joined: 23 Apr 2018, 16:49

Re: how to connect esp32 to other device by RS232?

#11 Post by pitrio » 30 Jan 2024, 22:57

don't worry... when you have time.
Meanwhile i'm tryng to do other test for better understand.

thank you in advance Ath!

ricc

pitrio
Normal user
Posts: 26
Joined: 23 Apr 2018, 16:49

Re: how to connect esp32 to other device by RS232?

#12 Post by pitrio » 14 Feb 2024, 15:38

dear all,
I'm traing with other test... but no news.
someone have some other hints to resolve this problems?

thank you in advance

ricc

pitrio
Normal user
Posts: 26
Joined: 23 Apr 2018, 16:49

Re: how to connect esp32 to other device by RS232?

#13 Post by pitrio » 26 Feb 2024, 19:53

dear all,

does anyone know how to solve this problem or is it not possible to connect esp32 with RS232 in ESPeasy?

Thank you and sorry for my request.

ricc

User avatar
Ath
Normal user
Posts: 3521
Joined: 10 Jun 2018, 12:06
Location: NL

Re: how to connect esp32 to other device by RS232?

#14 Post by Ath » 26 Feb 2024, 20:00

Can you try to use the SerialProxy plugin (P087) available in the Collection C builds, it works somewhat differently from P020/P044 (these 2 plugins use the same code-base), so maybe it solves your issue.
/Ton (PayPal.me)

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 44 guests