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:
reading variable from cloud gets delay as time goes
eventually web cannot read variable
Particle Core goes to infinite loop(where cyan breathing led, but inaccessible)
if I push reset button, it works for couple of minutes and it goes to same loop.
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.
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.
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 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!
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?