ser2net little trouble

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
giorgino
Normal user
Posts: 63
Joined: 24 Oct 2022, 21:06

ser2net little trouble

#1 Post by giorgino » 20 Jun 2023, 23:25

Hi I'm using the serial server to get datas from a device (a VICTRON ve-direct) and publishing them on MQTT with this (getting data from HW SERIAL0)

Code: Select all

on !Serial* do 
   Publish,'VICTRON-ve','{substring:8:15:%eventvalue%}'
endon
and this work good.


Now I want to connect another device (a counter) that sends data on a second serial HW SERIAL1
and i need to read this data to publish on MQTT

Code: Select all

on !Serial* do // Include * to process string values  -- se c'è traffico sulla seriale
  Publish,'waterflow','{%eventvalue%}'    // Lo pubblica MQTT
endon
This works good too, BUT the data is mixed
How can I divide the readings from SERIAL0 from the data coming from SERIAL1 ?

do I need to check the syntax in !Serial* ?

thanks
gio

bidrohini
Normal user
Posts: 106
Joined: 03 Nov 2022, 16:24

Re: ser2net little trouble

#2 Post by bidrohini » 21 Jun 2023, 20:48

Try it this way:

Code: Select all

on !Serial0* do
    Publish,'VICTRON-ve','{substring:8:15:%eventvalue%}'
endon

on !Serial1* do
    Publish,'waterflow','{%eventvalue%}'
endon

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

Re: ser2net little trouble

#3 Post by TD-er » 22 Jun 2023, 00:07

Not sure where this 0 or 1 should come from as -as far as I can remember- the event is rather hard-coded.
See: https://github.com/letscontrolit/ESPEas ... #L246-L252

I do agree it would be a good feature to distinguish or configure the event.
But I am not sure how it would be doable without changing the source code right now. (or am I missing something?)

giorgino
Normal user
Posts: 63
Joined: 24 Oct 2022, 21:06

Re: ser2net little trouble

#4 Post by giorgino » 22 Jun 2023, 00:43

bidrohini wrote: 21 Jun 2023, 20:48 Try it this way:

Code: Select all

on !Serial0* do
    Publish,'VICTRON-ve','{substring:8:15:%eventvalue%}'
endon

on !Serial1* do
    Publish,'waterflow','{%eventvalue%}'
endon
so do you think the answer is to use "!Serial0*" and "!Serial1*" to get difference from the input?

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

Re: ser2net little trouble

#5 Post by TD-er » 22 Jun 2023, 08:54

I don't think so, as I don't see the '0' or '1' being attached to that event.

You can have a look at the logs to see if such events are being generated, but I doubt it.

bidrohini
Normal user
Posts: 106
Joined: 03 Nov 2022, 16:24

Re: ser2net little trouble

#6 Post by bidrohini » 22 Jun 2023, 22:54

giorgino wrote: 22 Jun 2023, 00:43
bidrohini wrote: 21 Jun 2023, 20:48 Try it this way:

Code: Select all

on !Serial0* do
    Publish,'VICTRON-ve','{substring:8:15:%eventvalue%}'
endon

on !Serial1* do
    Publish,'waterflow','{%eventvalue%}'
endon
so do you think the answer is to use "!Serial0*" and "!Serial1*" to get difference from the input?
I hoped that the!Serial0* event handler would only trigger when there is data received on SERIAL0, and it will publish the data to the 'VICTRON-ve' topic on MQTT. Similarly, the!Serial1* event handler will trigger only when there is data received on SERIAL1, and it will publish the data to the 'waterflow' topic on MQTT.

I thought that using separate event handlers for SERIAL0 and SERIAL1 will ensure that the data from each device will be published to its respective MQTT topic without getting mixed up.

giorgino
Normal user
Posts: 63
Joined: 24 Oct 2022, 21:06

Re: ser2net little trouble

#7 Post by giorgino » 23 Jun 2023, 00:02

Unfortunatelly I'm not so sure, because at the moment I have data on "HW Serial0" and, using this syntax:

Code: Select all

on !Serial* do   				// when there is trafic on the serial
  Publish,'waterflow','{%eventvalue%}'    	// publish it on MQTT
endon
I see it on mqttexplorer

So it doesn't seem discriminating to use the extension ...0 or ...1

:?

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

Re: ser2net little trouble

#8 Post by Ath » 23 Jun 2023, 08:39

giorgino wrote: 23 Jun 2023, 00:02 So it doesn't seem discriminating to use the extension ...0 or ...1
That suggestion is based on wishful thinking and lack of knowledge, so not in place at the moment.

I am thinking of treating this as a feature request, and may add it in the (still open) PR for this plugin.
/Ton (PayPal.me)

giorgino
Normal user
Posts: 63
Joined: 24 Oct 2022, 21:06

Re: ser2net little trouble

#9 Post by giorgino » 23 Jun 2023, 16:24

please, Ath, do you think there is another way to use two serials "input channel" ?

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

Re: ser2net little trouble

#10 Post by Ath » 23 Jun 2023, 16:52

giorgino wrote: 23 Jun 2023, 16:24 please, Ath, do you think there is another way to use two serials "input channel" ?
At this time that can only be done by using 2 separate ESP controllers running ESPEasy, not from a single one, unless you can determine a difference in content to select on. I'll see if I can add that as a feature during the weekend.
/Ton (PayPal.me)

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

Re: ser2net little trouble

#11 Post by Ath » 24 Jun 2023, 16:07

I have been able to add 2 features in the PR I linked before
- Option to use the selected Serial Port name as the event name. All names start with 'serial', and are appended with their interface, f.e. HW Serial0 -> serial0, HW Serial1 -> serial1, USB HWCDC -> serialhwcdc, etc. (Only available when Event processing Generic is selected)
- Option to append the Task number to the event name, f.e. Serial8 when task 8 is used for the plugin. (Only available when Event processing Generic or RFLink is selected)

You can download from this GH Actions build (Once the build is finished).

Please report your findings here
/Ton (PayPal.me)

giorgino
Normal user
Posts: 63
Joined: 24 Oct 2022, 21:06

Re: ser2net little trouble

#12 Post by giorgino » 26 Jun 2023, 22:59

Ath, you're great !
Thank you very much, this solve many thinghs. I will test the system next weekend (The application lives on my sailboat)
For me the problem working with a second ESP is about the current absorbtion, I'm "offgrid" with solar panel and 120A lead battery, so every mA is important. The final step of my project will be the use of deep sleep, waking the system on events

(beer paid)

giorgino
Normal user
Posts: 63
Joined: 24 Oct 2022, 21:06

Re: ser2net little trouble

#13 Post by giorgino » 29 Jun 2023, 23:29

Just to explain, this is my project:
Schematic_dimmiBOX_2023-06-29.png
Schematic_dimmiBOX_2023-06-29.png (208.24 KiB) Viewed 2161 times
so I will connect serial0 to P33 and serial1 to P25
both with the samebaud rate

Do you think is it right the connection of the 5v 3.3v shiftlevel? with all the GNDs connected toghether? and the 5v too?

giorgino
Normal user
Posts: 63
Joined: 24 Oct 2022, 21:06

Re: ser2net little trouble

#14 Post by giorgino » 04 Oct 2023, 21:22

Please this doesn't work as i tought...
I have been able to add 2 features in the PR I linked before
- Option to use the selected Serial Port name as the event name. All names start with 'serial', and are appended with their interface, f.e. HW Serial0 -> serial0, HW Serial1 -> serial1, USB HWCDC -> serialhwcdc, etc. (Only available when Event processing Generic is selected)
- Option to append the Task number to the event name, f.e. Serial8 when task 8 is used for the plugin. (Only available when Event processing Generic or RFLink is selected)
I have 2 serial inputs, one connected in device so:

Communication - Serial Server VictronMPTT HW Serial0
Communication - Serial Server VictronBMW HW Serial1

one connected at pin 32 and one at 33
in rules I expected to write :

Code: Select all


on !Serial0* do
  Publish,ESP_DIMMIBOX/VictrMPTT,{substring:8:15:%eventvalue%}
endon


on !Serial1* do
  Publish,ESP_DIMMIBOX/VictrBMW,{substring:8:15:%eventvalue%}
endon

to obtain different topic on mqtt, but the extension 0 or 1 isn't good, it produce nothing

the only way to publish something is to use the classic syntax:

Code: Select all

on !Serial* do
without difference form serial0 or serial1

where am I wrong?

Build: ESP_Easy_mega_20230822_display_ESP32_4M316k Aug 22 2023

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

Re: ser2net little trouble

#15 Post by Ath » 04 Oct 2023, 22:12

giorgino wrote: 04 Oct 2023, 21:22 Please this doesn't work as i tought...

...

without difference form serial0 or serial1

where am I wrong?

Build: ESP_Easy_mega_20230822_display_ESP32_4M316k Aug 22 2023
The PR isn't yet merged into a release of ESPEasy so those 'fancy features' aren't yet available in the regular builds, you can download a fresh, up to date, PR build once this GH Actions run is finished.
/Ton (PayPal.me)

giorgino
Normal user
Posts: 63
Joined: 24 Oct 2022, 21:06

Re: ser2net little trouble

#16 Post by giorgino » 04 Oct 2023, 22:29

ah ok , thanks. I haven't understand much but it's ok. I think I have to wait :)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 39 guests