My Particle Electron is working great, and the Console is getting nicely filled up with useful data it’s publishing. However, it’s a bit unclear to me where I can actually store this data, as whenever I refresh the console, the old events are removed; how does one store all the published events of a sensor?
Events published by the Particle device to the Particle cloud only live on the cloud for approximately 60 seconds. Webhooks can be created which would allow you to log that data to another server somewhere. One way of doing this is by using IFTTT and Google Sheets which would log your events to a google sheet.
It is not possible to keep every event published forever as this would require a huge amount of data storage on the server and they are trying to provide the cloud service at a reasonable cost.
Is this possible even with a multitude of particles? When I go to the IFTTT website, I can only select one device.
I have about 20 different devices here, all running the exact same firmware; during a certain action, they will send out an event. I simply want to have a good overview of the timestamp of each event, and which device broadcasted it. I tried ThingSpeak but it wouldn’t keep track of which device was broadcasting the event.
With ThingSpeak, the example shows a single data channel with:
Name: Dew Point Measurement
Field 1: Temperature (F)
Field 2: Humidity
Field 3: Dew Point
Create a Field 4 for Device ID. This may be the actual device ID of the device or some made up unique identifier. I would advise giving it a unique identifier beyond the native ID for additional security.
You would send the ID with the data packet (4th field). At the other end, you can then sift the data by the inbound ID.
You’re right, I can just add extra fields in the ThingSpeak platform. However, do you have any tips for retrieving the Device Name? I read somewhere that the Device Name is only stored in the cloud, so telling the electron to retrieve it in the firmware isn’t possible?. Right now I’m outputting the device ID which is also fine, but being able to add another ID to it would be even better.
But there is noone holding you back from storing the device name (or any other label) in EEPROM to reuse it once set.
You could add a Particle.function() (or the likes) to trigger a name retrieval and store that result till you decide to change the name.
And I just saw you double posted this "question" so I just answered the same way as @peekay123 has done on your other thread.
That's why double posting is sternly frowned upon.
Apologies for asking so many questions. I’ve been trying to incorporate the lines of codes from the docs; everything seems to compile nicely until it get’s to the publishing.I suspect the issue is in line 115, but Im not really sure how to code this otherwise.
You can already set up the subscription without an active connection in setup(). I’d try that to prevent multiple registrations which will eventually fail after for times.
Since you are using AUTOMATIC mode in conjunction with multi threading, you may also be registering the subscription too late, since there is a finite window to register cloud “assets” after a connection, which will happen any time after power-up due to AUTOMATIC mode.
No problem asking many different questions, just asking the same thing multiple times isn’t appreciated as it ties resources without extra benefit.
I tried to do as you say, calling for the subscription during void setup(). It makes totally sense indeed what you mentioned, as it doesn’t need to keep running that line over and over again every time a connection is made.
The same error appears though;
Particle.publish("spark/device/name", data, PRIVATE); // data can/should be empty to safe on data
The string literal "spark/device/name" already is the event name.
And the reason for the error message is - not surprisingly - because there is no function overload for Particle.publish() that would take three strings.
Oh I see, that makes sense. I will see how this works, especially with my Webhook as I designed that to fetch only ‘‘Pickup Alert’’ events; having the Event Name field being populated with sensor names can make it a bit more tricky.
Yeah, I figured I couldn’t just add extra strings in as when I tried to remove the EventName string before it worked just fine; I just felt I was doing something work and there must be a way to just add in more fields.
Thanks a bunch for your help, this surely will help me out.
But it does without the Particle.subscribe() and/or Particle.publish()?
Do you get any events in https://console.particle.io/logs ?
Can you add some Log statements to follow the flow of your FSM?
yes exactly. Without Particle.subscribe and adding “spark/device/name” in Particle.publish everything works smoothly and I get all the data I want (minus device name). The console right now gives no messages when the sensor wakes up.