Constant disconnection

Hi, there

Continuing the discussion from Monitoring two cores via web:

I posted a situation where I am controlling two particle cores, but having hard time monitoring them through web. I am using Spark.variable and Spark.function to communicate with web.
When I fresh start computer, web and two cores working pretty well, however, after several flashes or after certain amount of time passed, it gets different types of problems.

Here are some symptoms:

  1. reading variable from cloud gets delay as time goes
  2. eventually web cannot read variable
  3. Particle Core goes to infinite loop(where cyan breathing led, but inaccessible)
  4. if I push reset button, it works for couple of minutes and it goes to same loop.
  5. sometimes cyan led rapidly flashing.
  • I know there must be tons of different reasons and situations causing the problem like this (wifi setting and etc) but this seemingly promising device is hard to control for new users. And it is very frustrating. :fearful:

Please advice me, I am stuck.

Thanks in advance

Are you using any Spark.publish() calls?

If so try commenting them out. I had the exact same issue.

@kmoses thanks for your reply!

Yes, I think there is something wrong with API and web communication. @Dave @kennethlimcp
And my javascript code is not stabilized too. I used the example from Tutorial: Spark Variable and Function on One Web Page

I am not familiar with Javascript and I have very little knowledge about web server. I duplicated getJson to retrieve data from API. The example code gets data from API every one second, whether the device is found or not. And it causes delay on API when it cannot retrieve data but constantly calling the API. I assume when certain amount of time delay happens, API blocks or detours to time-out. In that point Particle Core seems still connected, but something that is not reachable status.
I need to optimize calling and publishing it.
And I found out if you give Particle Core to publish data with one second interval, it performs better.

Hi @cherltte,

I think polling the API once or twice a second forever will be a really inefficient method of getting data from your device. Have you considered using Spark.publish, and webhooks? If your device or local network connection drops out, you’ll notice API calls taking longer, since the API will be waiting for a reply from your device, etc.

I hope that helps! :slight_smile:



Thanks Dave

I hope web hook system that you are developing is launching soon! It is a bit confusing for me to deal with Terminal and json and other language, bit scary too. T - T
But I am going to try this! thanks for your advice! :slight_smile:

@Dave Hey Dave,

I need some help. Now I understand the concept of web hooks and its capabilities. This awesome feature can mine data in the web by GET function. And weather example is very good. However I still don’t get how to monitor device via web browser properly.
I want to read multiple types of data from device that has been published in API via web browser. I have searched examples, but non of them were web based. Either they were using third service providers like Pushover, or Google sheet.
Last time I used Spark.publish to update data in variables, and tried to retrieve it by getJSON function. But as you said, polling the API data frequently is not efficient, (I would say it is not working). Is there way I can make a pipe between web and the API?

Thanks in advance :slight_smile:


1 Like

Hi @cherltte,

If you want to consume published events from a web app in a browser, then you might want to use SparkJS

here’s a demo on how to subscribe to events:


1 Like