Sniffing Serial Port

hbtousa

Active member
After I uploaded the code below on my receiver board, I was able to see what data was coming out from a second Arduino board. To accomplish this task, I used two jumpers: (Tx/Rx), and ground.


Transmitter side Tx (Re-assigned by SoftwareSerial ) connected to Rx Receiver board.
Transmiter GND to Receiver GND

After verifying the code was up and running flawlessly, I decided to replace the receiver board for a Teensy 3.6. I used the same wiring and unfortunately nothing shows on my Teensy Serial port. Can anyone give me a light ?
Code:
int chVal = 0;

void setup() {  
  Serial.begin(57600);
}
void loop() {
  for (;;) {
    while (!Serial.available());
    chVal = Serial.read();
    Serial.println(chVal);
  }
}



Thanks
 
The Serial ports on Teensy are addressed as Serialx where x is the port number. The first port is addressed as Serial1 using pins 0 and 1.
The T3.6 has 6 serial ports in total. Rx6 and Tx6 are on the underside of the board.
So your code would become:

Code:
void setup() {  

    int chVal = 0;

    Serial.begin(9600);                      //Start the USB Serial port
    while (!Serial && (millis() < 4000)) {}  // Wait for USB Serial to become available or timeout after 4 seconds.

    Serial1.begin(57600);

}
void loop() {
    for (;;) {
        while (!Serial1.available());
        chVal = Serial1.read();
        Serial.println(chVal);
  }
}
The USB port is addressed as Serial.
 
You might take a look at the example sketch:
<examples>/teensy/USB Serial/USBToSerial - It turns your teensy into a usb to serial converter.
 
Back
Top