String not being forwarded to firebase

Hey there, for some reason I cannot forward a string from my photon to firebase. In the particle online console, you can see that particle is receiving the string fine but then it doesn’t get sent to firebase. My webhook variables are working fine as I tried sending an integer instead and that gets forwarded perfectly fine. Any help would be much-appreciated.

#include "Particle.h"

// Constants
const unsigned long SEND_INTERVAL_MS = 10000;
const size_t READ_BUF_SIZE = 64;
const char *PUBLISH_EVENT_NAME = "photonData";
// Forward declarations
void processBuffer();

// Global variables
int counter = 0;
unsigned long lastSend = 0;

char readBuf[READ_BUF_SIZE];
size_t readBufOffset = 0;

void setup() {

void loop() {
	if (millis() - lastSend >= SEND_INTERVAL_MS) {
		lastSend = millis();
		Serial.printlnf("Sent to other Photon: %d", counter);

	// Read data from serial
	while(Serial.available()) {
		if (readBufOffset < READ_BUF_SIZE) {
			char c =;
			if (c != '\n') {
				// Add character to buffer
				readBuf[readBufOffset++] = c;
			else {
				// End of line character found, process line
				readBuf[readBufOffset] = 0;
				readBufOffset = 0;
		else {
			Serial.println("readBuf overflow, emptying buffer");
			readBufOffset = 0;


void processBuffer() {
	Serial.printlnf("Received from Computer: %s", readBuf);
  char buf[256];
  snprintf(buf, sizeof(buf), "{\"barcode\":%s}", readBuf);

I’d assume your string value needs to be wrapped in double quotes, just like the key.

Also, if you have issues with a webhook posting the webhook definition would be required.

Hey CruffR your right by meaning that the key needs to wrapped in double quotes. I can do it fine with an integer with my webhook configurations, just not this this string. Here are my webhook settings.
Thanks for your help!

I was refering to the key as an example how you should also wrap the string in double quotes.
like this

snprintf(buf, sizeof(buf), "{\"barcode\":\"%s\"}", readBuf);

I’m having the same issue with the GPS string that comes out of the asset tracker.

void publishData(String latlon) 
	char buf[256]; //creates a character buffer with a maximum size of 256 characters long
    snprintf(buf, sizeof(buf), "{\"latlon\":\"%s\"}", latlon); //Creates the buffer with the appropriate information
	Particle.publish(PUBLISH_EVENT_NAME, buf, PRIVATE);
	//Particle.publish(PUBLISH_EVENT_NAME, latlon, PRIVATE); //Sends buffer to firebase


Since you passed in a String latlon, you need to tell sprintf what format to render it in.

snprintf(buf, sizeof(buf), "{\"latlon\":\"%s\"}", latlon.c_str())


snprintf(buf, sizeof(buf), "{\"latlon\":\"%s\"}", (const char *) latlon)

Pick whichever style you prefer, they work identically.

1 Like

Thanks ScruffR that slight change to my code fixed my issue.

Thanks Rick! That sorted it for me.