Electron Particle Subscribe Sometimes Works?

This post is a subliminal plug for @ScruffR to jump in as he sort of already knows what I’ve been building with the keyword being Klaxon.

So I went around and installed my 20 devices and they are powered via solar panels/12v AGM batteries and the ControlEverything 2 relay boards with the lipo battery as well. Not that this is crucial data at this point but posting it may help find a bug or give other Particle user get ideas for there projects.

Any way, here is the use case. We are using a web API that I built to publish data that will trigger the signs to turn on/off. Here is our findings. When adding a new device the entire fleet has to be reset in order to work as expected. If you don’t, the newest sign installed is the only one that will react to the published data. After having all 20 on a light pole 7 feet up the only way to “reset” is to re-flash the firmware OTA to each of the devices. Now then, here is the final question/problem. I notice that some of the signs function and some don’t but it’s super random. One day signs ‘X, Y, and Z’ all work as expected but the other ones don’t. The next day could be ‘A, B, and C’. We also noticed that some will turn on and never turn back off with the given even data “off”. So is there a better firmware/callback to be written that could used to ensure every sign will turn on or off as needed? or is this a cloud issue where it gets hung up on something?



What do you mean by “adding a new device”? How are you managing these Electrons; as a product, or are all claimed by you?

Can’t you add a function which would set a flag that causes System.reset() to be called in loop?

Does your electron code have a way to inform the web app that a publication has been received (like publish a return message)? Having one would tell you whether it’s a cloud problem, or something else.

1 Like

I’ve got a suspicion and I had pinged Particle in the background but haven’t heard anything back.

Your devices are part of a product in the free tier - aren’t they?

Okay back from a couple days off work. Sorry for the late reply folks.

At the moment my signs have not been converted into a product. Also these signs are registered to a different user account than the one I am using (my personal particle account). I was contacted by DJ about an enterprise level account but I don’t know what that involves, so I asked him to give me a call.

Does your electron code have a way to inform the web app that a
publication has been received (like publish a return message)? Having
one would tell you whether it’s a cloud problem, or something else.

No, not at the moment. I was considering this as @ScruffR had shown me a code example that would do this. So as I write v2 of my API I will surely include this concept.

Did I miss something in the Docs? This could save me a little data in the long run. Any code examples?

So again, I tested them this morning and 5 random signs didn’t respond to my call to turn on lights. I really have to pin down reliability on this because now 23-26 more projects for other locations have been added to my list. So we are looking making this a product that could have a total of 520 new devices.


Okay today still the same issues…

I went and reset every single one of them and still a huge lack of consistency… Any help?

@callen wondering if you are facing any issues?

Happy to help work through the problem :wink:

@kennethlimcp we are still having major issues with the fleet of devices. So after several weeks I finally got back to looking at the problem. So basically, if I come in first thing in the morning (a few hours of no use) and try to activate my signs some of them may work and some may not. Sometimes the whole fleet is not responding. So essentially, I have to log in to the build IDE and flash all of the devices with the firmware one by one. They are too high up to easily open the enclosure and hit the reset button not mention they are scattered all over the place on base so it would take a whole day to reset this way.

Once they are reset, I have better luck for an hour but then it breaks again and some of them will just stay on. which forces me to drive all over to use the Particle App to manually send the “turnoffallrelays” data. Really embarrassing to say the least. My boss is looking at me like “why did we spend $7000 on this again?”.

Hey @callen, sorry for the frustration. I have 2 beta electrons that are running 24/7 close to 6 months without hiccups but they are using tinker firmware.

How do you determine that they are working or not? What system firmware are they on?

Have you tried adding a System.reset() call in loop so you can reset them without having to flash new code? You just need a function that sets a flag to true, lets say shouldReset, and then check that in loop.

void loop() {
    if (shouldReset == true) {
        shouldReset = false;

The fact that they work for a while after a reset, but then start behaving erratically, could be due to corrupting your memory by writing into an area that you shouldn’t be. That’s one possibility anyway, but we would need to see your code to diagnose what’s going on.


You may also want to consider using the Application Watchdog to reset the Electron if a key part of your code is not running.

Yes I was looking at this very thing last night… Is that Time firmware restricted to 0.6.0? I was looking at thinking maybe I could have a reset every thirty minutes or so.

I’m not sure what you mean by that. The watchdog has been available since v0.5.0 of the firmware. However, if the running code stalls FreeRTOS then the watchdog will not work. I would consider @Ric’s comments regarding your code possibly causing the problem. Also, extensive use of Strings can cause heap fragmentation leading to failure.

I’m not sure which Time firmware you mean. Do you mean Time.hour(), Time.minute(), etc.? If so, that’s been available for a long time. However, you really need to find the source of the problem, not try to patch it up by doing frequent resets. You need to determine if your software is still running when the Electrons are unresponsive to your commands. Does your web app look at the return value you get from a function call? If so, are you seeing those? You could put a Particle variable that is set to the current time inside loop(), and see if you can retrieve that value. Whether you can retrieve it, and if so, what value it contains might give some insight into what’s going wrong.

Also, what’s with this: “forces me to drive all over to use the Particle App to manually send the “turnoffallrelays” data.” Can you explain what you’re doing here? Is this a function call? Why do you have to drive all over?