Publish to Google sheet question

I am suffering a severe brain cramp. Usually when I encounter a problem with my code, I can eventually fix it once I engage a few in-reserve brain cells. This one is driving me nuts though:

I have been successfully publishing events to a Google sheet via a webhook for months. The events have been integers converted to strings like this:

Particle.publish ("Height",String(height));

I recently decided that it’d be useful to append a plus sign to the event data, so I modified the code as follows:

Particle.publish ("Height",String(height)+"+");

Now nothing shows up in the sheet for that event name.

The attached screenshot of a section of the sheet shows that the Height field was empty until I removed the “+” sign around 6 AM.

I’m sure there is a simle explanation but it escapes me. Anyone able to offer advice?

@blshaw45 it doesn’t work because “+” is considered a special character in building a string. You could use Particle.publish ("Height",String(height)+String(“+”)); or specify the “+” as a character literal like this: Particle.publish ("Height",String(height) + '+');

Personally, I avoid using Strings and use snprintf() and c-string arrays (char array), which avoids dynamic memory allocation used by String and possible heap fragmentation.

4 Likes

Oops; I take it back. Neither of those first two suggested solutions work. Same blank data field/cell. I’ll experiment with snprintf() next. Stay tuned.

BINGO!!

You’re the man PK! Muchas Gracias!

2 Likes