[solved] Cutting and Pasting Serial Data

I want to be able to load a bunch of music data into a program and store it in EEPROM so I can change the sound without recompiling the program. The arduino serial monitor seems to be made for just one line. Would I be able to use a better serial monitor and past in a ton of data and have the data slowly stream to the arduino so it can be read?

In other words, could I past in 1000 hex digits somehow and have the arduino read them in? Or would this be a problem because the serial monitor can't send the bytes fast enough so it can't handle a past of 1000 characters?


Your are confusing the Serial Monitor with the Arduino Uno's ability to read and send data via its hardware serial port.


Use an other terminal program. Plenty to be found on the web; try some ;) As I have not had a need yet, I have not looked.

Why not have you program read the Serial monitor input, look for a message that starts with 's', 'o', 'n', 'g', once received treat the next 4 digits as the address to start loading data, and put them in memory until the data stops coming in. Then go back to looking for s o n g and an address again.

What I was wondering is if there would be a problem pasting a huge blob of data into a terminal program. Would the arduino miss characters because they are coming in so fast from the terminal?

I think you can miss characters. Table 7.2 on page 23 of the 328 data sheet reports a typical programming time for each byte in the eeprom of 3.3 ms.

So if you get more than 1 character every 3.3 ms (assuming no time taken anywhere else), you'll have a problem.

Sending one character takes 10 bits (there are stop and start bits as well as the 8 bits in the character itself).

That would set an upper limit of 1/0.33ms = about 3,000 baud. The standard baud rate of the Arduino is 9,600 baud so no chance.

You've only got 2k of ram on an Uno too, so I don't like your chances of buffering all of it into RAM then writing to eeprom.

I'd recommend receiving the song in, say, 100 byte chunks. Buffering those 100 bytes in RAM then writing them to the EEPROM.

You could develop your own protocol for this, but you might want to look into the XModem protocol (since it is typically supported by telnet software). IIRC this protocol supports a really simple handshake where you ask for the next block of data when you have finished processing the latest. Perfect for a slow eeprom.

Alternatively, you could switch the Arduino to a lower baud rate (say 300) and send the data slowly. It would take about 1000 * 10 / 300 = 30 seconds to send 1,000 hex characters, give or take.

Yet another approach would be to use an AVI ISPMkII. Its a programmer which plugs into the ICSP connector on many Uno's and can write directly to the eeprom using a program called AVRDude. Some of the early serial bootloaders support writing to the eeprom with AVRDude as well, but most of the ones used now don't unfortunately.

Finally, we have a program called MegunoLink that lets you send serial messages. I just checked and the serial monitor has no limit on message length or you could setup an interface panel and have it send a song when you clicked a button. It is here: www.MegunoLink.com. Feel free to get in touch if you've any questions.

Thank you. That's a lot of good ideas to think about. Since my project will ultimately just be a stand-alone microcontroller, I like the Xmodem-type protocol idea. For an ATTiny, I found code that lets you make a high voltage fuse programmer which was easy to build. I could modify that to program the EEPROM once I better understand the protocol.