connecting many serial to ESP

Moderators: grovkillen, Stuntteam, TD-er

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

connecting many serial to ESP

#1 Post by giorgino » 29 Oct 2024, 22:58

In my project I need to connect many serial input:
  • 1 - NEXTION display
    2 - GPS
    3 - VICTRON-ve (battery monitor)
    4 - VICTRON-ve (MPTT solar charger)
I'm testing the 4051 multiplexer and seems to work fine
I plan to connect 1 to SWSERIAL
With the 4051 I plan to connect the 2,3,4 to HWSERIAL1
then with ESPEASY I plan to use 2 gpio to address the multiplex, addressing them in sequence

What do you think about his idea?

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

Re: connecting many serial to ESP

#2 Post by TD-er » 29 Oct 2024, 23:30

Like switching serial ports in some sequence from one device to another?
I think it will cause a lot of issues as a task will have a serial port running and if it suddenly receives data from another device, then the task in ESPEasy will absolutely fail to properly switch between those devices.

If you really need so many serial ports, why not use several ESPEasy nodes and share the data among them via ESPEasy p2p?
Or use an I2C to UART chip like the SC16IS752
See: https://espeasy.readthedocs.io/en/lates ... elper.html


N.B. these SC16IS752 chips only have 64 byte FIFO, so better not to use it with devices which chat a lot, like GPS.
However the Victron devices and Nextion should work just fine.

Only need to convince Ton to change the code to perform less calls to available() :)

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

Re: connecting many serial to ESP

#3 Post by giorgino » 29 Oct 2024, 23:40

as I said otherwhere the first rules of my project is to be low-low-low consuption because it live onboard, conneced to a service battery (recharged by solar power) but... consuption has to be the low as possible
So using other nodes is not a way I like

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

Re: connecting many serial to ESP

#4 Post by TD-er » 29 Oct 2024, 23:42

Then having one of those I2C to serial converters is probably the best way to go.

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

Re: connecting many serial to ESP

#5 Post by giorgino » 30 Oct 2024, 00:40

ok
I'm also testing my new ESP32-S3 with 16mBflash

Do you think it could be the best solution?

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

Re: connecting many serial to ESP

#6 Post by TD-er » 30 Oct 2024, 00:46

The S3 is the one with the most serial ports.
But still software serial is quite tricky as it will result in read/write errors, so only to be used when checksums are used. (e.g. on GPS data)

You can see what I mean by simply converting your ESPEasy console settings to use SW serial on the same GPIO pins as Serial0 uses it by default. So you can still see it on the USB serial port (assuming you use USB to uart chip and not native USB which is more common on ESP32-S3 boards with only a single USB port)

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

Re: connecting many serial to ESP

#7 Post by Ath » 30 Oct 2024, 08:28

TD-er wrote: 29 Oct 2024, 23:30 N.B. these SC16IS752 chips only have 64 byte FIFO, so better not to use it with devices which chat a lot, like GPS.
However the Victron devices and Nextion should work just fine.

Only need to convince Ton to change the code to perform less calls to available() :)
I think I've fixed that, see: https://letscontrolit.com/forum/viewtop ... 232#p71232
/Ton (PayPal.me)

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

Re: connecting many serial to ESP

#8 Post by giorgino » 30 Oct 2024, 08:50

Sorry I've never used I2C converter
TD-er wrote: 29 Oct 2024, 23:42 Then having one of those I2C to serial converters is probably the best way to go.
do you mean something like this?
usb to serial.png
usb to serial.png (142.94 KiB) Viewed 1893 times
On my ESP32-S3 board there is 2 usb connector, one called USB and one UART
so one for the power and one fro the seriale (the third) because for the other two exist appropriate pins

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

Re: connecting many serial to ESP

#9 Post by Ath » 30 Oct 2024, 09:08

No, more like these: https://aliexpress.com/item/1005006765729550.html

You connect such board to your ESP via I2C, and get 2 serial ports in return (can be configured from most Serial communication plugins).

As TD-er said, the hardware-buffer in these chips is only 64 bytes, but for the Victron (and Nextion) devices that should be fine.
/Ton (PayPal.me)

Affinite
Normal user
Posts: 122
Joined: 03 Apr 2018, 18:46
Location: United Kingdom

Re: connecting many serial to ESP

#10 Post by Affinite » 30 Oct 2024, 12:56

giorgino wrote: 29 Oct 2024, 23:40 as I said otherwhere the first rules of my project is to be low-low-low consuption because it live onboard, conneced to a service battery (recharged by solar power) but... consuption has to be the low as possible
So using other nodes is not a way I like
Are you using DeepSleep when you are not on the boat?
My on-board ESP boards send sensor readings over MQTT for 30 seconds then they go to sleep for 10 minutes.
Current consumption is around 50-60mA when awake and connected to WiFi router but only 20mA when asleep.

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

Re: connecting many serial to ESP

#11 Post by giorgino » 30 Oct 2024, 19:00

The deepsleep was the strong point of my project :-D

But I've disabled the deepsleep in this weeks that I'm always connected working on the system

I the final version of my system there will be an input to wake in case of an alarm (I have a flooding switch sensor that activate the bilge pump)

Affinite
Normal user
Posts: 122
Joined: 03 Apr 2018, 18:46
Location: United Kingdom

Re: connecting many serial to ESP

#12 Post by Affinite » 30 Oct 2024, 20:49

giorgino wrote: 30 Oct 2024, 19:00 The deepsleep was the strong point of my project :-D

But I've disabled the deepsleep in this weeks that I'm always connected working on the system

I the final version of my system there will be an input to wake in case of an alarm (I have a flooding switch sensor that activate the bilge pump)
I like it. Nice idea!
Did you know that the new Victron plugin is now working?

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

Re: connecting many serial to ESP

#13 Post by giorgino » 31 Oct 2024, 00:25

Sure! I've tested the first release last weekend, with problem about my syntax coding rules
Next weekend I'll be onboard updating the code. I will solve every problem using the ESP32-S3

Very grateful to Ath and Tder for them work

Affinite
Normal user
Posts: 122
Joined: 03 Apr 2018, 18:46
Location: United Kingdom

Re: connecting many serial to ESP

#14 Post by Affinite » 02 Nov 2024, 10:24

giorgino wrote: 31 Oct 2024, 00:25 Sure! I've tested the first release last weekend, with problem about my syntax coding rules
Next weekend I'll be onboard updating the code. I will solve every problem using the ESP32-S3

Very grateful to Ath and Tder for them work
If you test the new Victron plugin (P176) I would really like to know if you get checksum errors.

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

Re: connecting many serial to ESP

#15 Post by giorgino » 06 Nov 2024, 17:51

ok, it's arrived !
51iXrLbj1PL._SX522_.jpg
51iXrLbj1PL._SX522_.jpg (25.82 KiB) Viewed 1353 times
now I only need to learn how to use it :D

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

Re: connecting many serial to ESP

#16 Post by TD-er » 06 Nov 2024, 19:39

VCC and GND, SDA, SCL to the ESP
RXA/TXA for channel A
RXB/TXB for channel B

You can leave the rest alone for now :)

In plugins that need some kind of serial, you can select I2C UART and then there will be a pop-up showing an I2C address selection and whether you will use channel A or B.

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

Re: connecting many serial to ESP

#17 Post by giorgino » 06 Nov 2024, 22:56

what about the 5V / 3,3V ?
Victrons, Nextion (and GPS too) are powered by 5V so I've passed their data TX/RX throw a step down voltage
What I have to do now?

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

Re: connecting many serial to ESP

#18 Post by Ath » 06 Nov 2024, 23:14

Use the same level converter you used to connect f.e. the Victron to the ESP directly.
These chips support an absolute maximum input voltage of 4.6V (and a little bit more under specific conditions), so a level converter is often needed, even when using 5V serial signals.
/Ton (PayPal.me)

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests