Different serial communication with R4

I have problems to get data from the new R4 boards to Exel Datastreamer so I did some testing with the IDE 2.2.1 Serial monitor. There is a difference with the new boards.

I used this simple program for the test:

int i;

void setup() {
i = 1;
Serial.begin(9600);
}

void loop() {
Serial.print("Hello ");
Serial.println(i);
delay (1000);
i = i + 1;

}

Result with R3 Mega2560
I stopped the serial monitor on Hello 30 and then started it again.
The old text is still there and the counting resets to 1.

3:11:40.867 -> Helllo 30
13:11:41.779 -> Hello 1
13:11:42.741 -> Hello 2
13:11:43.781 -> Hello 3
13:11:44.770 -> Hello 4

Result with the new arduino R4 minima.
I stopped on Hello 56 and then restarted the serial monitor.
The old text on the monitor disappeared but the counting continues from where it was.

13:21:52.154 -> Hello 57
13:21:53.203 -> Hello 58
13:21:54.235 -> Hello 59
13:21:55.285 -> Hello 60
and so on.

The R4 WiFi works just like the R4 minima,
and the Uno R3 just like the Mega 2560 R3.

My problem is that I can not start the datastream from R4 with the Exel Datastremer.
The boards R4 boards have a different serial communication. Does anyone know the difference and how to handle it?

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

Thank you, I will try to get it right next time.
I am new at the forum, I did not know how to do it.

If you mean that you closed the Serial monitor and opened it again then, yes, there is a difference between the Mega and the R4

When you open the Serial monitor on the Mega the board is reset so the code starts again at the beginning. Doing the same on the R4 does not reset the board, so the code continues to run

Thank you!
Yes I can see there i a difference.
The big question is:
Can it bee controlled.
Can you do somting with the R4, the Arduino code or the Exel Datastreamer to start the dataflow from the R4 to the datastreamer?

If the datastreamer is connected via Serial then yes, of course, you can do something to start the data flow. You need some type of event such as pressing a button or the passage of time to signal that data streaming should start

Thank you?
Must this event be sendt from the datestreamer in Exel or from some kind of start up code in the Arduino program?

If the Excel datastreamer can send data to the Arduino then it could work either way

However, It would seem to make more sense for the Arduino to initiate the data transfer once it had something to send

Thanks for all help, I think I solved the problem, but of course there are a new one.
How the problem was solved for the R4 Minima:
In the setup I added Serial.dtr(); (data terminal ready) -
And in the loop I added Serial.rts(); (request to send) and it worked.
The datastream showed up in Exel Data streamer. Lowely!

But, and there are always a but. This is the new problem.
This code blocks the Uno R4 for uploads form the IDE 2.2.1.!
I get this message for all my uploads attempts, not only for this program.

Failed to retrieve language identifiers
Failed to retrieve language identifiers
error get_status: LIBUSB_ERROR_TIMEOUT
Failed uploading: uploading error: exit status 74

I have to find a way to clear the program out of the R4. Help ----- anyone?

Here is the code, I hope the format will be right this time.


int i;

void setup() {
i = 1;
Serial.begin(9600);
Serial.dtr();
}

void loop() {
 Serial.rts();
Serial.print("Hello ");
Serial.println(i);
delay (5000);
i = i + 1;
}

The Uno R4 boards have 2 serial interfaces

Serial uses the USB connection for programming and communication using the Serial monitor whilst Serial1 uses pins 0 and 1 on the board so is free to be used for other purposes

Consider using Serial1 and a TTL to USB converter

Thanks again UKHeilBob..
I will try the Serial1 option.
By the way, two fast pushes on R4 reset button made it possible to upload from IDE 2.2.1 to the R4.

1 Like

After some testing I got full two ways communication with Exel.
You must have the Serial.dtr(); in setup.
You do not need Serial.rtc(); in the loop. (as I wrote in the program example)
Then everything worked as intended!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.