New answers tagged

2

Actually there are 2 buffers per Serial hardware interface: The hardware buffer, that is 1 byte (per direction of data transfer). The Serial library then transfers this byte in an extra buffer (64 bytes big) from an ISR. Every hardware Serial interface (Serial and Serial1 to 3 on the Mega) has it's own hardware buffer. Then the Serial library is implemented ...


1

Every instance of class HardwareSerial has own buffers. Here you can see it in source code. The instances are declared/definded at the end of the HardwareSerial.h/.cpp.


1

First, you got some logic wrong in the receiver: you have a test for Serial1.available()>=size_gyro and, when this is true, you read size_gyro + 9 bytes. You should change the test in order to only start reading when you actually have size_gyro+9 bytes available. Then, note that command_name is transmitted twice: first as part of the 9-byte preamble (...


1

how to make [two Arduinos communicating with each other] working while connect to computer? There are a variety of ways for 2 Arduinos to directly communicate with each other while one or both are communicating with the Serial Monitor of a laptop computer over USB. Use a UART for the Arduinos to communicate that is independent of the USB connection. (See ...


2

First of all, you have to decide whether you want to send the data as raw bytes (“binary data”) or as an ASCII text representation. Binary tends to be more efficient: you can send a float with full precision in only four bytes, whereas you would typically need 8 to 9 significant digits to recover the full precision from an ASCII representation. Binary is, ...


3

I tried the code from the link you posted and it worked: struct Gyro_data_structure { char command_name[6]; int gyro_X; int gyro_Y; int gyro_Z; }; struct Gyro_data_structure Gyro_data = {"Hello", 48, 49 , 50}; int size_gyro = sizeof(struct Gyro_data_structure); void setup() { Serial.begin(9600); // opens serial port, sets data rate to ...


4

Suppose one connected two of the Arduino Uno boards through Rx and Tx pins. I assume you will connect the TX of one Arduino to the RX of the other one and vice versa, which is the right way to connect them. As theSealion explained in his answer, you shouldn't connect two TX Pins together. if one or both of the Arduino boards were connected to computer, ...


0

You should't connect two TX Pins together. The Arduino has some protection resistors but even it is not recommended to connect two output pins. The only save way to use the RX / TX pins directly is to remove the protection resistors (RN4A and RN4B in the reference design) or at least the RN4A and use only one connection at a time. It doesn't help if you do ...


1

You can't set timeout for read(), but you can use readBytes() to read one byte. byte b; int count = Serial.readBytes(&b, 1); // read one byte with timeout if (count) { // 0 or 1 Serial.write(b); //echo }


Top 50 recent answers are included