I need to add 20 UART sensors to a Raspberry Pi - any thoughts?

Thread Starter

joshctaylor

Joined May 17, 2017
11
Dear All,
I need to run a comparison study of 20 sensors which currently only come with a UART interface. They send a 3 byte message at 10 Hz with 9600 baud, 3.3v logic level. Does anyone have experience of setting up a lot of serial devices? Any suggestions / help is very welcome.

Options I am aware of to start discussion:
- USB converters - I'm not too keen on this as I will need a 20 port hub
- RS485 or similar - The sensor does not have an address, does anyone know of a device which will add an address to multiple serial streams?
- I2C convertors, I have seen I2C chips with 4 UART interfaces
- bitbanged serial
- <the magic perfect solution I don't know about>
 

shteii01

Joined Feb 19, 2010
4,644
Get a bunch of Chinese 3.3V arduino boards. Use Software Serial (standard feature in current arduino software) to use two digital pins for UART. This way you can hook up 3 or more sensors to each arduino board.

Usually arduino boards have dedicated UART pins, use them to connect to RPi. Or use Software Serial to use any two digital pins for UART to talk to RPi (just like you did with the sensors).

Arduino Due has 54 digital pins. Two digital pins per sensor for UART. Save a few pins for just in case, figure you have 40-48 digital pins, that is 20-24 sensors. Do more research, you might be able to fit all 25 sensors on one Due.
 

Thread Starter

joshctaylor

Joined May 17, 2017
11
Get a bunch of Chinese 3.3V arduino boards. Use Software Serial (standard feature in current arduino software) to use two digital pins for UART. This way you can hook up 3 or more sensors to each arduino board.

Usually arduino boards have dedicated UART pins, use them to connect to RPi. Or use Software Serial to use any two digital pins for UART to talk to RPi (just like you did with the sensors).

Arduino Due has 54 digital pins. Two digital pins per sensor for UART. Save a few pins for just in case, figure you have 40-48 digital pins, that is 20-24 sensors. Do more research, you might be able to fit all 25 sensors on one Due.
thanks, I've done a little more research now and rather than attaching many more UARTs I'm looking at multiplexing a single UART using CD74HC4067.
 

JohnInTX

Joined Jun 26, 2012
4,787
If you can poll the sensors, I kind of like the multiplexer approach as well.

If the sensors don't wait for polling, I'd consider using a little PIC at each sensor and bussing them with I2C or CAN. I2C could be multi master or the host could poll each slave. Since the PIC has memory, it could coordinate the timing of the sensor reads and buffer multiple readings as necessary, sending several points to the host when polled. CAN would be a little more expensive but the protocol is built in. The sensor PIC would again read the sensor and use CAN to send the readings. The host just reads the CAN messages and determines which sensor by the COB_ID. I have implemented large 'smart point' systems using both I2C and CAN with great success.

I don't like the multiple Arduino with multiple firmware UARTs as a data switch.

Just my .02

Thinking more, PICs with 2-wire RS-485 would work and be pretty cheap and easy. Local PICs would manage and buffer the sensors. The host would poll each by sending the address of the desired slave and that one would transmit its data.
 
Last edited:

dendad

Joined Feb 20, 2016
4,641
I too would vote for an RS485 or CAN network.
What are the actual sensors? If they are just temperature, you could use "1 wire" temperature sensors all wired to the same cable.
The cheap Arduino way is good, but with a network so you just use 4 wires, +5V, Net+, Net- and 0V.
https://arduino-info.wikispaces.com/SoftwareSerialRS485Example
You will probably have to Google for more detailed info.
RS485 is used extensively in industrial applications, often running Modbus protocols.
All you would need to do is an a MAX485 chip to each Arduino. An Ebay board will be the easiest way to go with that too.

I've not read this all but it may help a bit...
https://github.com/4-20ma/ModbusMaster
http://4-20ma.io/ModbusMaster/



And many others.
 
Last edited:

Thread Starter

joshctaylor

Joined May 17, 2017
11
Thanks for all your suggestions. The sensor is a PMS5003 particle sensor. Its a cheap Chinese sensor but it seems that they might have stumbled on something that works with a little more modelling - hence the comparison. It does support polling so I'm thinking multiplexing is the way to go as it has the least parts and cost.
 
Top