3

I am trying to connect a CDC communication device to the Leonardo USB port and have communication with it via the TTL com port. Basically I want to echo to the TTL port whatever is transmitted over USB and vice-versa.

ASCII data is transmitted out the USB from the CDC device into the USB port of the Leonardo Aurduino. The Arduino needs to xtransfer this info over to the UART pins D0 (RX) and D1 (TX) that are connected to the UART of another micro-controller. I should be able to test it by connecting an FTDI TTL-RS232 cable and see results and have comms in my terminal program.

I came across this sketch that appears to be basically what I want, but I think the "hosting" portion is not being set up:

void setup() {
 Serial.begin(9600); // rx/tx pins
 Serial1.begin(9600); // USB port
 Serial1.write("2nd Version");
} 
void loop() {
 // copy from virtual serial line to UART and vice-versa
 if (Serial.available()) {
 char c = (char)Serial.read();
 Serial1.write(c);
 }
 if (Serial1.available()) {
 char c = (char)Serial1.read();
 Serial.write(c);
 } 
}

What am I missing? Note I am NOT trying to do HID but CDC. Basically I want to eliminate using a PC as a Host device and use the "bridge" between my CDC device and another micro-controller.

dda
1,5951 gold badge12 silver badges17 bronze badges
asked Oct 20, 2017 at 14:13
2
  • Interesting. I do know nothing about CDC. Can you show us a schematic showing the connectiions? Commented Oct 20, 2017 at 14:17
  • 1
    Nothing to it really....ASCII data is transmitted out the USB from CDC device into USB Port of the Leonardo Aurduino. The Aurduino needs to xtransfer this info over to the UART pins D0(RX) and D1(TX) that is connected to the UART of another microcontroller. I should be able to test it by connecting an FTDI ttl-RS232 cable and see results and have comms in my terminal program Commented Oct 20, 2017 at 14:54

1 Answer 1

2

No, the Leonardo cannot be a USB Host. You may be able to use a USB Host Shield in conjunction with the Leonardo, though I have never tried it and cannot vouch for compatibility with the Leonardo.

USB is a host->device protocol, not a peer-to-peer protocol. You cannot just connect two devices together. Only a USB Host can communicate with a USB device.

answered Oct 20, 2017 at 16:15
2
  • Not even with an OTG cable? Commented Oct 20, 2017 at 16:18
  • 1
    No. The Leonardo cannot be a USB Host. Commented Oct 20, 2017 at 17:06

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.