Subscribe to two Spark Core boards and decided which one published data first

instead of json, you could even go simpler:

String data = "SAXE"; // however you get your data
unsigned long now = millis();
String publishData = String(now) + "|" + data; // e.g. 692865|SAXE
Particle.publish("EVENT_NAME", publishData);

And then on the receiving side:

int separator = receivedData.indexOf("|");
unsigned long deviceEventMillis = receivedData.substring(0, separator).toInt();
String deviceEventData = recievedData.substring(separator + 1);

Couple things to note.

  1. Here’s a post on getting time with milliseconds, which currently you can’t.

  2. I am making the assumption that your two events could happen within the same second and that you need the accuracy. So the other thing I would do is that when the device start, they would publish their start time and millis so you can do the math to get the actual time.

1 Like