Invio coordinate GPS formattate (Parsing)

Abbiamo lavorato sullo sketch Arduino per poter mandare coordinate GPS con relativo messaggio da inviare sul cellulare scritto nel codice con Parsing.

Parsing: frammentazione di una stringa di testo

Esempio di Parsing:

String input = “1,1,20181206123453.000,45.652260,8.784088,219.900,0.00,11.4,1,,1.3,2.4,2.0,,10,7,,,48,,”;

String pieces[30];

// Keep track of current position in array
int counter = 0;

void setup(){


void loop() {
// Keep track of the last comma so we know where to start the substring
int ultimavirgola = 0;
int i=0;

for (i = 0; i < input.length(); i++) {

// Loop through each character and check if it’s a comma
if (input.substring(i, i+1) == “,”) {

// Grab the piece from the last index up to the current position and store it
pieces[counter] = input.substring(ultimavirgola, i);

// Update the last position and add 1, so it starts from the next character
ultimavirgola = i + 1;
// Increase the position in the array that we store into


// If we’re at the end of the string (no more commas to stop us)
if (i == input.length()-1) {
// Grab the last part of the string from the lastIndex to the end
pieces[counter] = input.substring(ultimavirgola, i);



for (i=0; i<=counter; i++){


String latitudine=pieces[3];
String longitudine=pieces[4];
String linkgoogle = “”


// }

// Data is now available in pieces array
// pieces[0] is first item
// pieces[1] is second item, and so on
// You can call toInt() on the data to convert it to an int

// ex. int value = pieces[0].toInt();


Related posts

Leave a Comment