Reputation: 477
On one side I have a device with a USB (FTDI chip) interface communicating in serial 9600bps,N,8,1 - the default configuration for the Arduino USB/serial interface. On the other side I have a simple Arduino sketch that starts a serial session and transmits data.
void setup() {
// put your setup code here, to run once:
Serial.begin(9600,SERIAL_8N1);
}
void loop() {
// put your main code here, to run repeatedly:
char* data_to_send="66";
SSEND(data_to_send);
delay(5000);
}
String SSEND(char* data){
String protocol="AT$SF=";
protocol+=(String)data;
// protocol+="\r";
Serial.println(String(protocol));
delay(1000);
return "OK";
}
The sketch works just fine when connected to the computer. Then I try to connect to the device and I see the Tx LED that stops blinking so it doesn't send anything and of course the device doesn't work like expected. Besides, I tried sending serial commands directly from the computer to the device and it works just fine.
So my questions are:
Thanks for your help
Upvotes: 1
Views: 2685
Reputation: 1
I found that this code works well for receiving data from the device. Set the baud rate tailored to your needs, but do not connect the TX pin on the Arduino to the RX pin on your device, or else it sends all the data that the device is outputting back to itself. You can find another mean of outputting, but to send data to the device you can use 'Serial.println()'.
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) {
char incomingByte = Serial.read();
Serial.print(incomingByte);
}
}
Upvotes: 0
Reputation: 65136
I suspect that device is a USB device and not a USB host, and you plugged two USB devices together. That Arduino is not a USB host, and a USB connection always needs a host.
The plug adapter you're using is not even supposed to exist according to the USB spec, because the different shapes of plugs are specifically there to make it impossible to plug two devices into each other like you've done here.
The way to make it work would be to use another board that actually supports acting as a USB host.
Upvotes: 2