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
}
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.
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.
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.