Strange. It was a few months ago, but when I did the tests for using an accelerometer to wake a Photon from sleep when shaken, I didn't wait at all before publishing and I'm pretty sure all of the publishes went through as I was actually looking for that as part of the testing.
As you can see as soon as Particle.connected() returns true, I did the publish. Now I did wait 4 seconds after that before disconnecting and sleeping; that may or may not be significant.
case PUBLISH_STATE:
if (Particle.connected()) {
// The publish data contains 3 comma-separated values:
// whether movement was detected (1) or not (0) The not detected publish is used for battery status updates
// cell voltage (decimal)
// state of charge (decimal)
char data[32];
float cellVoltage = batteryMonitor.getVCell();
float stateOfCharge = batteryMonitor.getSoC();
snprintf(data, sizeof(data), "%d,%.02f,%.02f", awake, cellVoltage, stateOfCharge);
Particle.publish(eventName, data, 60, PRIVATE);
// Wait for the publish to go out
stateTime = millis();
state = SLEEP_WAIT_STATE;
}
else {
// Haven't come online yet
if (millis() - stateTime >= MAX_TIME_TO_PUBLISH_MS) {
// Took too long to publish, just go to sleep
state = SLEEP_STATE;
}
}
break;
Full code here: