Arduino USB Host to Arduino USB Device communication

first, let's define the problem:

I have two "arduino style" devices. Each has a samd21g18a inside and are both usb devices. These communicate to the PC over usb serial connection. Normally, these communicate to a LabView Program on a PC. The devices use the basic included "arduino serial" protocol.

I would like to create another device, to act as a USB "host" to communicate with these two devices, and display information on an LCD display. Communicating to these devices using other protocol is "not possible" without revising the PCB, which is not an option.

Second, the question:

Is there a way to setup an arduino (samd21g18a) as a usb HOST device, to communicate with two arduino (samd21g18a) usb DEVICES which use the arduino usb serial protocol?

I've seen conflicting information online about this, so i'd like to know if its possible before just putting a RPI in a box and running a labview program there.

That is for certain possible, but who would want to write the code, when you can do that "out of the box" with an RPi?

I could do it on an RPI, but thats abit of a headache as id have to source a copy of windows and another labview license. I am not a "skilled" programmer so linux is out of the question. It is an option though, as the labview code already exists.

Then you don't know how difficult the coding would be. USB is extremely asymmetric, and it is not at all simple to write code for a general purpose USB host.

1 Like

i wasn't particularly looking to start from scratch, more wondering if there is an existing library that could be used. Something like this GitHub - gdsports/USB_Host_Library_SAMD: USB host library 2.0 for Zero/M0/SAMD

The issue with this library is there doesn't appear to be a way to use it to communicate over serial, only to preprogrammed devices the library supports.

Try it and let us know whether it solves the problem!

Coding in Python on Pi running Linux is much easier than coding USB host for Arduino, in my opinion. Many people code in Python on Pi to avoid the complexity of writing c/c++ Linux code.

Reading/writing Linux serial ports can be done using pyserial. You do not need to know anything about USB host because USB serial devices appear as /dev/ttyACM* or /dev/ttyUSB* devices. pyserial can open, close, read, and write them like any other serial ports. Search for "pyserial docs".

As for displaying, one option is to write to an attached HDMI monitor. There are a number of Python modules to simplify GUI programming. Search for "pygame docs" or "pysimplegui docs".

Another option is to connect a small display to the Pi 2x20 connector using i2c or spi. Adafruit sells such boards with Python libraries.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.