I’ve not yet looked at all of this, but this would be the first thing I’d change
char msg[256];
// assuming batvolts is double or float
snprintf(msg, sizeof(msg), "{\"1\":\"%.2f\",\"k\":\"%s\"}", batvolts, key);
Particle.publish("thingSpeakWrite_batterytest", msg, PRIVATE);
I’m not sure whether webhook event names are prefix filters like Particle.subscribe()
filters.
And I’m also not sure whether ThingSpeak doesn’t expect numeric values to be sent without the double quotes.
I’ll have to check.