For my project, i need my Arduino Uno to simulate a GPS. To do this, I need to:
- Generate a 5V Pulse once a second (no problem)
- Send a $GPRMC NMEA sentence with the current time over RS-232 (i've got an RS-232 shield)
The GPRMC message i need to send is the following:
$GPRMC,075832.293,A,4042.695,N,07400.796,W,,,080120,000.0,W*63
Where the first part is the time, and needs to change. I basically implemented it as:
// Setup
String prefix = "$GPRMC,";
String gprmc = "075832.293";
String suffix = ",A,4042.695,N,07400.796,W,,,080120,000.0,W*63";
String all = prefix + gprmc + suffix;
char* buff = (char*) malloc(sizeof(char)*all.length()+1);
Then, in the loop-code i update the time and want to send the message:
//...inside the condition that gets executed once a second
gprmc = String(gprmc.toFloat()+1);
all = prefix+gprmc+suffix;
all.toCharArray(buff, all.length()+1);
mySerial.write(buff);
I'm using an RS-232 shield, which shows me when a message is being sent by blinking an LED. However, is only seems to work, if i shorten the all string, i.e.: Works:
all = prefix+gprmc;
Does not work:
all = prefix+gprmc+suffix;
Is it possible that the message is just too long to send? Is there a way I can fix this? Because it's crucial to send the whole message.
Note: I'm currently working on an Arduino Uno, but I'm switching to an arduino Leonardo today. I currently have low memory available (77% used). could this add to the problem?
Thank you so much for your help!! :)