EEVblog Electronics Community Forum

Electronics => Beginners => Topic started by: Aston01 on August 13, 2024, 10:20:59 pm

Title: Choosing a RS485 transceiver for use with an ESP32 & 12v sensor
Post by: Aston01 on August 13, 2024, 10:20:59 pm
I am trying to get the correct hardware ordered for my first time working with RS485 and I am a little confused about what I need as far as a transceiver is concerned.


As mentioned previously this is my first time selecting hardware for RS485 so if you see a reason to go a different direction than I am currently mentioning I am open to suggestions.

Dev board
ESP32-S3 powered via LiPo battery
https://www.mouser.com/ProductDetail/392-FS3-U-01 (https://www.mouser.com/ProductDetail/392-FS3-U-01)

Moisture Sensor (RS485 Modbus RTU)
[attach=1]

Because the only aspect of what I am doing that requires 12v is the sensor I was going to use one of these boost converters
https://www.mouser.com/ProductDetail/485-5644 (https://www.mouser.com/ProductDetail/485-5644)

These are the RS485 transceivers I was looking at
https://docs.m5stack.com/en/unit/rs485 (https://docs.m5stack.com/en/unit/rs485)
https://docs.m5stack.com/en/unit/iso485 (https://docs.m5stack.com/en/unit/iso485)
https://docs.m5stack.com/en/stamp/stamp_pwr485 (https://docs.m5stack.com/en/stamp/stamp_pwr485)
Title: Re: Choosing a RS485 transceiver for use with an ESP32 & 12v sensor
Post by: PGPG on August 14, 2024, 11:32:58 am
For me RS485 transceiver is the 8 pin integrated circuit (see MAX485 as an example).
From your Moisture Sensor tabele I understand that it already has transceiver inside (it not outputs TXD and RXD lines that you would have to convert (using RS485 transceiver) to RS485 A, B lines.
So you not need transceiver.

But I think at last I understood what you write.
Even we use RS485 since 90s about Modbus I know practically nothing (only heard that name and imagine a little what it is).
So not assume what I write as being certainly true. According what I know (not sure) I think Modbus is stupid communication protocol that forces system to use on transmission much more energy than it is really needed. As the whole world is trying to limit the energy consume I am against using RS485 this way.
In our RS485 use device sends something only when it has something to tell and not have to answer 50 times a second that it has nothing to send (I think, but not sure, Modbus works that way).

So:
- RS485 is the physical specification of connection,
- Modbus is one of possible communication protocols.

I don't know these devices you name transceiver.
I can suppose that those of them that call only RS485 allow to communicate through them in any protocol so if Modbus is needed it then have to be realized at PC using this transceiver.
It is possible that those of them that have Modbus in specification realize that protocol themselves so at PC connected to them you need not to worry about Modbus protocol itself.

You should read these transceivers detailed specification to understand what they offer you.
Title: Re: Choosing a RS485 transceiver for use with an ESP32 & 12v sensor
Post by: xvr on August 14, 2024, 08:08:11 pm
You need RS485 transceiver connected by TX/RX pins to ESP32 board and by A/B pins to Moisture sensor. You also should connect DIR pin of transceiver to any pin of ESP32 board (to control direction of communication - send or receive).
GND pins of sensor and ESP32 board also should be connected together.
For powering up sensor you can use boost converter you mentioned.

On ESP32 you should use software library to access your sensor via Modbus RTU protocol.
Modbus is build around abstraction of 'registers' that placed inside sensor. Your ESP32 code can read and write them via Modbus RTU protocol. Which registers are implemented in sensor and what does they mean should be specified in sensor documentation.

PS. Modbus on protocol level do not poll anything on its own, but it do not provide any 'interrupt' notion. If you need to monitor any activity inside sensor you should periodically poll for 'register' contents by explicitly reading it.

PPS. Transceivers in OP are not suitable for ESP32 - it use 3.3V logic levels, not 5V. Use separate 3.3V chip (it will be much simpler)