Photon v0.6.3 publish fails

I’m having trouble with publishing events. It seems to work once per event, then future attempts to publish fail (with different data). The photon is connected and breathing cyan. It subscribes to events and I can publish from the web console and it receives them (its behavior changes appropriately). The photon is running the code correctly (its just controlling a fan on a schedule). I added a routine to make sure to do a Particle.connect if its not connected (including a waitfor), but still nothing. Any ideas?

Are you observing the once per second rate limit on publishing? Posting your code would be helpful, otherwise we’d just be guessing.

1 Like

Yes, for the fan status, it just publishes when that changes, which will only be a couple times per hour. Here is a method in the Fan class to set its state…

 void setFanState(int state)
        if(state != _lastFanState)
            digitalWrite(_relayPin, state);
            _lastFanState = state;
            publishEvent("FAN", state == ON ? "ON" : "OFF");

The fan turns on and off as expected - right now runs for 5 minutes, then off for 25 minutes… I only ever see the events (any events for this photon) when I push new code to it. After that first pass, no events. BTW, not sure it matters, but this is a Sparkfun Photon Redboard.

That’s not enough of the code to diagnose your problem. Can you post the whole Fan class code (and the publishEvent function if that’s not in the Fan class).

1 Like

quick question - I did find a place that publishes 2 events very quickly (within the same second - and thats the last time I see events). Does violating the publishing speed prevent any more events from getting published?

I commented out the place that had sent the multiple events and now events seem to be flowing. Maybe I should look at closer :slight_smile: Possibly its sending more and they were being suppressed - and that was preventing other events from being published. Thanks for your help!

You should also publish the events as PRIVATE and not flood the public event stream if not absolutely necessary.

Ok thanks - I had assumed it was private by default… Switching my calls to private now!