Send command to ESPEasy via UDP.

Moderators: grovkillen, Stuntteam, TD-er

Message
Author
Smotek7
Normal user
Posts: 226
Joined: 01 Aug 2020, 16:18
Location: SK

Re: Send command to ESPEasy via UDP.

#101 Post by Smotek7 » 06 Apr 2025, 19:17

Guys, I have another question.
Is there a command to send to TCP?
Something like SendToTcp.
I accidentally got a question today whether it is possible to read data from a PV inverter that has Modbus TCP and process it in rules.
In the controller there are only http and udp.

I thought of connecting two ESPs via uart, one as a standard Ser2net, and using the other to send data to uart.

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

Re: Send command to ESPEasy via UDP.

#102 Post by Ath » 06 Apr 2025, 19:30

Ser2Net has support for sending data to the connected TCP device/port using the plugin command ser2netclientsend,<content>. This doesn't have support for the 'mix' type of content.
SendToHTTP, PostToHTTP and PutToHTTP commands use the GET, POST and PUT verbs of the HTTP protocol to transport data to a specific address/port. Not sure if any of those protocols matches your TCP device though :?
/Ton (PayPal.me)

Smotek7
Normal user
Posts: 226
Joined: 01 Aug 2020, 16:18
Location: SK

Re: Send command to ESPEasy via UDP.

#103 Post by Smotek7 » 05 May 2025, 23:21

I don't know if I've asked this before but I couldn't find the answer.
Can I set up two Ser2net on one ESP32?
So I can do it in tasks, but how do I then distinguish in Rules which ones I send to, for example, SerialSendMix....
And then how do I distinguish "on !Serial do" ....

If I need to use uart on HWserial0 on IO1 and IO3.
The HW is already designed that way.
Just turn off the console in Tool
Enable Serial Port Console: 0 ?
Or is it better for the backdoor to put the console on another GPIO?

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

Re: Send command to ESPEasy via UDP.

#104 Post by Ath » 06 May 2025, 08:38

Smotek7 wrote: 05 May 2025, 23:21 I don't know if I've asked this before but I couldn't find the answer.
Can I set up two Ser2net on one ESP32?
Yes, that's possible, at least on ESP32 builds, as they have multiple serial ports available.
Smotek7 wrote: 05 May 2025, 23:21 So I can do it in tasks, but how do I then distinguish in Rules which ones I send to, for example, SerialSendMix....
As per the documentation, you can address a command to a specific task by prefixing the command with [taskname]. (The taskname, enclosed in square brackets, though that's optional, and a period)
Smotek7 wrote: 05 May 2025, 23:21 And then how do I distinguish "on !Serial do" ....
The setting "Append Task Number to eventname" does what it implies, for most configurations ;)
Smotek7 wrote: 05 May 2025, 23:21 If I need to use uart on HWserial0 on IO1 and IO3.
The HW is already designed that way.
Just turn off the console in Tool
Enable Serial Port Console: 0 ?
Or is it better for the backdoor to put the console on another GPIO?
Console always uses Serial0, so for your situation it's probably better to disable that.
/Ton (PayPal.me)

TD-er
Core team member
Posts: 9915
Joined: 01 Sep 2017, 22:13
Location: the Netherlands

Re: Send command to ESPEasy via UDP.

#105 Post by TD-er » 06 May 2025, 09:23

On an ESP32 you have 3 hardware-serial ports, so why do you need to use Serial0 ?

Smotek7
Normal user
Posts: 226
Joined: 01 Aug 2020, 16:18
Location: SK

Re: Send command to ESPEasy via UDP.

#106 Post by Smotek7 » 06 May 2025, 12:51

@Ath
like this?

Code: Select all

[UART0].SerialSendMix,'0x010400010002200b' 

The task name in devices is UART0

and

Code: Select all

on !Serial#9 do
My task number is 9.

@TD-er
The final assembly should be
- BMS uart
- Modbus sensor
- Nextion
I still have SC16IS752 in the pipeline, that might be the way for Nextion.
For me, the ideal situation would be to put a free GPIO DIP switch and switch one serial in two modes, uart console and, for example, BMS uart.
I have a JST PH2.0 connector on that uart and so I have a ready USBtoUART converter. Otherwise, I would just pull out the BMS and insert the USBtoUART there.

Otherwise, I still can't explain why I have a problem sending commands via USBtoUART. There is an SI8422BB splitter. I thought I had a HW problem with the connector. 3 days ago it worked.
Yesterday it didn't. I have WT32, on the SI8422BB board and a USBtoUART converter. I always see the data log with ESP on the terminal. When I send a command, no response. I also have a second USBtoUart connected to the Rx pin on the WT32 for testing and there I watch whether the command arrives at the Rx. I see the command there. But it is not executed. My last suspicion is that the SI8422BB is powered by 5v and the Pollup with Rx is also at 5V. Is that the cause?

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

Re: Send command to ESPEasy via UDP.

#107 Post by Ath » 06 May 2025, 13:29

Smotek7 wrote: 06 May 2025, 12:51 @Ath
like this?

Code: Select all

[UART0].SerialSendMix,'0x010400010002200b' 

The task name in devices is UART0
That's the correct way indeed.
Smotek7 wrote: 06 May 2025, 12:51 and

Code: Select all

on !Serial#9 do
My task number is 9.
Close, but no cigar :? :

Code: Select all

on !Serial9 do
/Ton (PayPal.me)

TD-er
Core team member
Posts: 9915
Joined: 01 Sep 2017, 22:13
Location: the Netherlands

Re: Send command to ESPEasy via UDP.

#108 Post by TD-er » 06 May 2025, 14:23

WT32 as in WT32-ETH01?
Ethernet is also consuming quite a lot of GPIO pins, so not many left.
See: https://espeasy.readthedocs.io/en/lates ... e-on-esp32
Not all of the left over pins can be used for everything.
For example there are some pins which need to have a specific state at boot of the ESP and some are input-only.

As an absolute last resort you could also try to use Software Serial.
I advice to only use it on not too "chatty" sensors.
For example those that only send when requested and not too long messages with error correction or checksum.
Since you don't really get feedback from a display like Nextion, I guess using SW serial for those isn't that practical.
The timing of SW serial isn't that good on ESP32-xx, so it might result in transmission errors.

TD-er
Core team member
Posts: 9915
Joined: 01 Sep 2017, 22:13
Location: the Netherlands

Re: Send command to ESPEasy via UDP.

#109 Post by TD-er » 06 May 2025, 14:39

Smotek7 wrote: 06 May 2025, 12:51 [...]
Otherwise, I still can't explain why I have a problem sending commands via USBtoUART. There is an SI8422BB splitter. I thought I had a HW problem with the connector. 3 days ago it worked.
Yesterday it didn't. I have WT32, on the SI8422BB board and a USBtoUART converter. I always see the data log with ESP on the terminal. When I send a command, no response. I also have a second USBtoUart connected to the Rx pin on the WT32 for testing and there I watch whether the command arrives at the Rx. I see the command there. But it is not executed. My last suspicion is that the SI8422BB is powered by 5v and the Pollup with Rx is also at 5V. Is that the cause?
I didn't know about the SI8422BB and looked at the datasheet.
Looks like an impressive isolator chip.
If you have this connected to GPIO 1 and 3, then you should also see something when the ESP boots, before ESPEasy is started.
Could be that your terminal filters out data at the wrong baudrate. Some ESPs use ((26/40) * 115200 = 74880) as baudrate at boot to show some boot-messages. This is then due to wrong assumptions about the used crystal, where it is assumed to be 40 MHz but is actually 26 MHz.
This is only at boot and only if GPIO-15 is not low during boot.

N.B. If I'm not mistaken, the shield of the Ethernet connector is connected to GND, or at least not isolated.
So better not use high-end Ethernet cables which have a metal shield. This then creates a ground loop to the switch, which may cause all kinds of issues electrically.

Smotek7
Normal user
Posts: 226
Joined: 01 Aug 2020, 16:18
Location: SK

Re: Send command to ESPEasy via UDP.

#110 Post by Smotek7 » 06 May 2025, 20:02

@TD-er
I tried everything possible.
I ended up with just the WT32 solo module and the USBtoUART converter.
Now I'm trying the ESP32-ETH1 V1.4 module which has the ESP32-WROOM-32 chip.

My settings are set to default:
konzola1.png
Communication - Serial Server
konzola2.png
Log from ESP to PC always goes.
But commands from PC to esp only work when I have Ser2net deactivated.
When I activate it, esp stops receiving commands on uart.
So it's different hw uart console is on HW Serial0 and SerToNet is on HW Serial1.
I have the version
ESP_Easy_mega_20250430_collection_E_ESP32_4M316k_ETH Apr 30 2025

Could this be a bug in Espeasy?
Or should I check some settings?

I'll try it with another board later.
I also have the original WT32 ETH01 v1.2 from wireless tag.
You do not have the required permissions to view the files attached to this post.

Smotek7
Normal user
Posts: 226
Joined: 01 Aug 2020, 16:18
Location: SK

Re: Send command to ESPEasy via UDP.

#111 Post by Smotek7 » 06 May 2025, 20:10

I'll add
I downgraded to
ESP_Easy_mega_20241222_collection_E_ESP32_4M316k_ETH Dec 22 2024
It works the same.

TD-er
Core team member
Posts: 9915
Joined: 01 Sep 2017, 22:13
Location: the Netherlands

Re: Send command to ESPEasy via UDP.

#112 Post by TD-er » 06 May 2025, 20:54

We have to check the source of the plugin to see if there is a bug.
To be honest, it does sounds like one..

Who is online

Users browsing this forum: OpenAI GPTBot [bot] and 16 guests