Problem reading data via serial USB

I’m trying to read data from a serial port (USB cable) and can’t figure out why “if (Serial3.available()) “ is not working. Here’s the setup:

Uno outputs a string every second via the Serial port on the board (sketch is below)
Data set from USB cable B connection on Uno to Mega which I spliced into Serial3
Mega setup to receive the data on Serial3
Mega output results to its Serial port connected to my computer (sketch is below).

Problem: The Mega never detects something coming via the serial3 connection in this statement: “if (Serial3.available()) “ Help – thanks in advance.

Uno sketch
String pdrValues = “SD 5-Oct-2013 13:16:38 3.82 19.7 27 764”;
int inByte= -1; // incoming byte from serial RX

void setup() {
Serial.begin(19200); //Serial communication for Arduino Serial Monitor
}

void loop() {
Serial.print(pdrValues);
delay(1000);
}

Mega sketch

int inByte= -1; // incoming byte from serial RX

void setup() {
Serial.begin(19200); //Serial communication for Arduino Serial Monitor
Serial3.begin(19200);

}

void loop() {

Serial.println(“in loop”);

if (Serial3.available()) {
inByte = Serial3.read();
Serial.println(inByte);
}
}

You can't use the USB connector of the Arduino UNO to send Serial data. Use D0, D1, and Ground.

Ok thanks. What I’m trying to do is get an air quality instrument (see pic), which outputs serial data every second via USB-B to the Mega where it will be processed. But the Mega does not detect the incoming data from the instrument. Are my connections on the Mega correct? Thanks.

If you want to connect a USB device to an Arduino you will need something like a USB Host Shield.

What kind of connector is on the "air quality instrument"?

Hi John, Thanks for your help. The connector on the air quality instrument is USB with a B connector. Can you recommend any USB Host Shields? Thanks.

Can you recommend any USB Host Shields?

Before you go that route, what do you know about writing USB drivers? You'll need to know how to write one in order for the USB host to make the USB slave (your air quality instrument) do anything.

Here’s a video showing what I’m trying to accomplish.

IMG_5249.MOV (3.39 MB)

SensorTim: Here's a video showing what I'm trying to accomplish.

The problem is that USB (Universal Serial Bus) is not even close to being a TTL Serial port. It is a set of protocols over a high-speed differential bi-directional communication line. That is why there is a USB-to-Serial chip on the Arduino. The USB side talks to a USB Host and the Serial side talks to a serial port on the ATmega processor.

You may find that the air quality device has a similar chip inside connecting a serial signal to the USB Host. You may be able to open the air quality device and tap into the Serial signal before it is converted to USB. If so, that might allow you to connect the air quality device to an Arduino serial port.