Sending lots of data using Serial

Hi,

I need to make a 2D printer plot 100 data points (X,Y). I cant save those X,Y points in my sketch cause arduino memory is to low to keep all those 100 points. So my solution so far was to paste one by one each coordinate in the serial and wait arduino plot it.

It works but it's too tedious. So I thought abou pasting all the X,Y coordinates in the serial but only the first 4 are executed by Arduino. I think it's related to the buffer size.

Can I have a buffer size of 1MB for example? If not, can I tell arduino IDE to send the data in intervals of 1 second so the buffer nevers gets full?

I am using arduino nano clone.

Can I have a buffer size of 1MB for example?

Yes, of course you can
Have you got 1MB of RAM spare?
1MB of any kind of storage?
If yes, use it

Yes I have 8GB of RAM in my computer. Arduino IDE will keep that 1MB of buffer in my computer's memory and just send it to arduino when it already read the last data sent?

100 x, y data points?
What's that?
800 bytes?
What's the rest of the Arduino's RAM doing?

100 of float numbers. I think 800 bytes is too much for arduino RAM. Are you kidding me man? You look smarter than this.

Maybe with all the hand-waving, you're the smarter one.
Who knows?

(deleted)

batata004:
Yes I have 8GB of RAM in my computer. Arduino IDE will keep that 1MB of buffer in my computer's memory and just send it to arduino when it already read the last data sent?

@batata004:

  1. I think you owe AWOL an apology.

  2. There are many solutions and whether you have 800 Bytes of Arduino SRAM available is unknown. But if you need to tie your Arduino sketch to the PC, this is one way:
    Connecting Arduino to Processing - SparkFun Learn

Ray

@mrburnette thank you so much man, processing was the way :slight_smile: It worked like a charm, thanks man!

batata004:
@mrburnette thank you so much man, processing was the way :slight_smile: It worked like a charm, thanks man!

No problem, we are here to help. Glad you have a workable solution.

Ray's Projects

@mrburnette I spent the last entire night seting up my code and it finally worked (thank you @mrburnette).

But there is a prorblem: when I send the data (coordinates) to my printer using Arduino IDE serial the printer gets much more precise. When I use Processing my printer loses a lot its precision. Why?

BTW I didtn do any change to my arduino code, it is still exactly the same. I just created the Processing code to send data to my arduino as I would manually do in the serial.

What could be going on? Is Processing somehow delaying arduino or causing it to lose some "cycles"?

@AWOL I am sorry, I really thought you were fooling me around. I just didnt believe you cause when I send more than 4 coordinates at the same time in my serial arduino will only process the first 4 and after that it gets "buggy" (I think that it's related to some overflow in the serial buffer). So I ask you: if arduino can handle my 100 coordinates, why can I only send 4 of them in the Serial and all the others get lost/corrupted? Why aarduino buffer is not keeping all the coodinates I am sending and processing it as it did with the firt 4 coordinates?

So I ask you: if arduino can handle my 100 coordinates, why can I only send 4 of them in the Serial and all the others get lost/corrupted?

And I ask you back "How the Hell should I know?"

You haven't posted any code.

Maybe your serial flow-control is screwed.

Maybe with all the hand-waving, you're the smarter one.
Who knows?

From one of the OP's previous posts, we learned that the OP is a creative genius, whereas forum members are intelligent but uncreative.

Forum members can, however, send 100 number pairs over serial with no problems.

this forum is full of brilliant people like @jremington who knows how to send 100 number pairs but does not know how to explain... or maybe he cant send 100 number pairs either and is just fooling around

@AWOL here comes the code. I try to use a delay(50) to make arduino wait more than needed so the buffer gets bigger and bigger (less than 100 chars) and it does not work.

Upload this to your arduino:

void setup() {

    Serial.begin(115200);


    while (true) {
        
        if (Serial.available()) {
    
        String resultado = "";
    
            while (Serial.available()) {
     
                delay(50);
                resultado += (char)Serial.read();
    
            }
            
            Serial.println(resultado);
            
    }
        
  }

}

void loop() {

}

Open your serial (set 115200 baud) and send this (100 chars long):

12345678912345678912345678912345678912345678912345678912345678912345678912345aaaaaaaaaaaZZZZZZZZZEND

You will see that ARDUINO wont show up evertyinig, just a few numbers in front.

And this forum is hearing a lot from @batata004 who can't explain his/her problem, can't post code other than snippets, and can't find the Portuguese section of the forum.

  delay(50);

At 115200? Get real.

delay(50) is to allow the OVERFLOW. Unfortuatelly you didnt get the idea, hope another person understand it. You probably does not know what is a snippet.

Portuguese forum is terrible, only a few people can help there.

delay(50) is to allow the OVERFLOW.

It doesn't "allow" it, it ensures it.

Think about it; characters are arriving at 11520 characters a second, and you're reading them out at 20 characters per second, with a 64 character buffer.

Do the arithmetic.

I can't imagine why you'd want to do that, but I'm just an unimaginative Anglo-Saxon.

@AWOL I have a 2D printing code which is too big and I am trying to isolate the problem providing you a small code. Everytime my printer reads 2 numbers from serial it stops reading, prints that coordinates and starts reading again. Usually between each print, it takes about 3 or 4 seconds.

So when it returns back to read the next data in serial it simply disappeared (it actually can read it in the second and third time, but after that the remaining serial data is gone).

You told me arduino could easily hold those 100 numbers in serial, but my code just proves you are wrong - at least in some conditions, like the code I provided you, what you say it not true.

You told me arduino could easily hold those 100 numbers in serial, but my code just proves you are wrong

No. Your code is the problem, as AWOL explained.