I am trying to pass a char array variable as the 'msg' in the PubNub.publish(channel, msg) command. The 'msg' parameter in the command needs to be in JSON array format but my 'input' variable is a char array. The code is firmware for a Particle Photon
This works:
char msg[64] = "{\"Device\":\"on\"}";
PubNub.publish(channel, msg);
But this doesn't work
char msg[64] = "{\"DeviceID\": input}"; //'input' is my char variable for storing serial data
PubNub.publish(channel, msg);
@craig Conover Below is the code for "input" variable and there is data in it. It publishes correctly to particle.io but not to PubNub :
if(Serial1.available()){
Particle.publish("Tagged", "Tag Detected");
count = 0;
while(Serial1.available() && count < 12) // Read 12 characters and store them in input array
{
input[count] = Serial1.read();
count++;
delay(5);
}
Particle.publish("tagnumber", input, PRIVATE);
char msg[64] = "{\"DeviceID\": input}"; //'input' is my char variable for storing serial data
PubNub.publish(channel, msg);