1

On tindie I bought a RS485 soil moisture sensor with a USB to RS485 dongle. I want to add more sensors for monotorring multiple plants. Since RS485 is a bus system, it seems basically possible to connect multiple sensor on the same USB dongle. The sensor has an address, which should be use to idenfity it when multiple ones are connected on the same wire.

Since the default address of my sensor is 1, my idea is the following: Connect the first sensor, change it's address to 2. Then connect the second one, change the address to 3 and so on, so that I never have duplicate addresses. All sensors should get connected on the same wires of the USB to RS485 dongle.

Is this assumption right?

Am I able to write a program that queries multiple sensors and read the temperature of every one?

Are there any restrictions other than the RS485 limit of 32 devices (which is quite enough for me)?

Example using modbus-serial npm package what I want to do:

var ModbusRTU = require("modbus-serial");

const device = '/dev/ttyUSB0'
const baudRate = 19200;

let options = {
    baudRate: baudRate
}
var client = new ModbusRTU();
client.connectRTU(device, options, async () => {
    for (let clientAddress = 1; clientAddress < 5; clientAddress++) {
        client.setID(clientAddress)
        let moistureRegisterRaw = await client.readInputRegisters(0, 1);
        let moisture = moistureRegisterRaw['data'][0]
        console.log(`Moisture of #${clientAddress}: ${moisture}`)
    }
});

Until now, I tested this only with a single sensor at address 1 (default).

  • 3
    Yes, this should work, but the only way to be sure is to try. – Dmitry Grigoryev Apr 30 '18 at 7:44
  • As this is basically the idea of the RS 485 bus it should work. Did you achieve your goal? If so it would be nice to add (and accept) an answer yourself. Thanks. – Ghanima Oct 15 '18 at 23:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.