3

I have two devices I want to use (GPS module and a PM2.5 sensor) that both use serial communication. I know you can't throw two devices on the same serial line. However, I've seen some badly explained serial communication using the USB ports examples and I'm still not 100% certain.

If I take one module and connect it to the TX/RX pins in the GPIO area, then can I hook the other one through a USB port? Furthermore, could I accomplish this by constructing two serial objects using the wiringPi serial class?

1 Answer 1

4

You can use multiple USB serial dongles. They will appear as /dev/ttyUSBx where x will be a small number such as 0, 1, 2. You can use any serial software you want. They will all use the Linux serial driver "under the hood".

You can connect one serial device directly to the Pi expansion header on TXD/RXD (GPIO 14/15, pins 8/10). The device must be 3V3 TTL (i.e. 0V for low and 3V3 for high). Voltages outside that range will eventually destroy the GPIO and the Pi. You can use any serial software you want. They will all use the Linux serial driver "under the hood".

3
  • Thank you, this is similar to some of the other resources I've found. So I'll use averaging to have confidence in going forward. I'll start small with testing. I wanted to ask before I dove in, just in case. But Thank you again! Commented Feb 7, 2018 at 19:23
  • @BrandonWilliams I recently deployed a piece of manufacturing equipment backed by raspberry pi and 4 USB-Serial Dongles. It works just fine, however, there is one caveat. The /dev/ttyUSBX order can be scrambled if you plug/unplug devices, you will need to mess with udev if a fixed handle is important to you. Using a 4:1 usb-serial adapter is easier for this than 4x 1:1 usb-serial adapters in my experience.
    – crasic
    Commented Feb 7, 2018 at 23:25
  • Thank you, the dongles won't be moved when put together. I'll keep this in mind though. Commented Feb 7, 2018 at 23:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.