Hello all. I am new to the particle systems so please forgive me. I have a Photon and an Electron, in both cases, they will be running on battery so I will be sleeping them for 1 minute. When they wake up, they will measure light from a sensor and publish to the cloud.
My question is, what is the best way to have my backend application I am creating connect then to the particle cloud to get the last published value from the Photon/Electron? It is almost like the particle cloud is a middle person in this case. I cannot call the Photon directly because it may be sleeping. So, I think it will just publish every minute. Therefore, the cloud is going to have all of the data. But, I want to get that data from the cloud now (or more specifically, just the last value that was published).
My application is a web application that uses javascript but I can also just do simple web api calls instead of using an SDK too. Part of me wishes this product would let me call my web application directly instead of having the particle cloud have to be the middle man, or can this be done? What is stopping me from doing an HTTP call direct from the photon to my application?
There is nothing stopping you from sending data to wherever you want, if you have cloud that means you have internet connectivity so you could could use UPD or TCP or libraries that take advantage of them. If you search around in the forums you should find posts that will help you.
The Cloud just lets you do this easily, take a look at webhooks. It’s probably the simplest route you can go.
The simplest way I found was to push the data to a google spreadsheet using IFTTT. I am also pretty new to the particle electron. I started with IFTTT and it was really useful just to see how the information was being sent and what exactly was being sent.
After that I set up a .php page on a web site to receive the information from a web hook. That was a challenge. Probably not for half the people that respond to the questions you have, but for me it was. I went back and forth from the webhook to the .php page and to the Electron. I had no idea what was going where. then I realized the webhook information being sent to the .php page was showing what the .php was responding to the webhook. So that helped tremendously. I was able to see that my Publish string was missing a " in one spot. Once the webhook showed that the .php was receiving the string, it was still not breaking it down correctly to distribute the data into a MySQL database. I copied the string that was being sent to the .php and used the copy as a variable to parse. Once I was able to break apart the string to the correct variable types, the database I had set up accepted the different values and stored them for me.
Now all this I what I went through to save the data I wanted coming from an electron. You may not need a database to store your data. But I think all this is why it is so difficult for someone to tell you how to store your data. The choices you have are almost endless. I used lots of examples from the Particle Community. I read many books on Database storage, HTML , and .php. Followed countless examples of JSON data strings (that I was still unable to parse properly, had to find another way around it). I have tried Google cloud, Amazon Web services, Microsoft (whatever the call their storage site “Az” something), they were all way over my head. the Google cloud was ok , but I realized in the Pub, Sub part of the cloud , it was the same thing Particle already gives us to use.
I thought about using the Http from the Electron , but everything I saw on the subject warned of Data usage.
Good Luck !!