Teensy to Teensy 3.5 Serial communication

Status
Not open for further replies.

laptophead

Well-known member
I am trying to transmit 9 Variables from one teensy to another using the Serial port 1.
I think I got the hardware part right , I connected the Pin 1 of the transmitting Teensy to the pin 0 of the receiving one.

Than I tried the example of this blog https://www.pjrc.com/teensy/td_serial.html

Transmitter code is
int number = 1234;
Serial.println("string"); // string
Serial1.println('a'); // single character
Serial1.println(number); // number (base 10 if 16 or 32 bit)
Serial1.println(number, DEC); // number, base 10 (default)
Serial1.println(number, HEX); // number, base 16/hexidecimal
Serial1.println(number, OCT); // number, base 8/octal
Serial1.println(number, BIN); // number, base 2/binary
Serial1.println(number, BYTE); // number, as a single byte
Serial1.println(3.14); // number in floating point, 2 digits

And the receiver code is
if (Serial1.available()) {


incomingByte = Serial1.read(); // will not be -1
//Serial.println(incomingByte);
}
// Serial.println("SerialWorks");
Serial.println(incomingByte);

When I monitor the incomingByte , all I see is 2 digit numbers repeating, but nothing resembling what was sent.

How to I parse these values? How do I get to see them for what was sent?
How do I make new integers that equal each of them, so I can use them??

Thanks
 
That's because print translates it into human-readable.

You want Serial.write();
Serial.print(value, BYTE) converts the value to the ASCII character that corresponds to value, and sends that character. Therefore, it is valid only for values that are in the range 0 to 255.

Serial.write, on the other hand, streams the bit pattern for value. Therefore, it will send any one-byte value as is.
 
I think Detriot_Aristo has probably hit the nail on the head, but check the baud rates are the same on both sides also.
 
Small details matter. That's why we have the Forum Rule. Complete programs are expected when asking these sorts of questions. When you post a complete program (where it can be copied and pasted into Arduino and run on a real board), we can see critical details like the type of "incomingByte" which you probably didn't know mattered. That's why complete programs are expected, because often the problem is in some other key detail you're not expecting.
 
You are right, I will post next time the entire code. For this one, I gave up on Serial, and used Wire.h to communicate.
Works like a charm. It is light on the processor, cant even tell the difference.

I found these examples, Simple and workable. If anyone wants to do them, dont forget the PullUP resistors on pins 18 and 19 on teensy 3.5

https://github.com/Prince-of-Persia/I2CBus
 
Status
Not open for further replies.
Back
Top