Can I have a local db to lookup values on the device?

Hi all,
Just getting started with Particle and hardware in general, so excuse me for a noob question. I would like to be able to check certain values on the device before the events are sent to the cloud, the reason being: I want the hardware to function even if the connectivity breaks. Sending data to cloud is good, but it’s more for logging.
One way of doing it is - I can include the file itself, and parse it myself, but then if the data changes, I have to reflash the firmware. Is there a sync kind of library, where it’s a lightweight database, which can manage the delta synchronisation with an external source?
I had a look and couldn’t find anything. Trying to do a sort of edge computing scenario here.

What amount of data are we talking about?
Depending on that you may have a variety of competing ways to do what you ask - some fitting one scenario better than another.

I also sense two “independent” layers to your one question.
You mention that you want your code to also work without cloud connection - which of course is possible - but then how would the data on the remote end change (if at all)?
If the potential changes only can happen on the device side, the device should know about it all along.
If data can change on the remote side too, you’d need to retrieve the remote data first to check for differences. At that point you could just send your local data to the remote and and let the check happen there (optionally with “boolean” feedback whether a change was detected or not).

Thank you for your reply @ScruffR.
What amount of data? - the csv of the current database is <1mb, which would change <1kb a week.

The changes to the DB happen from the remote side only. Let’s say I’m added some data to it, and then I want the devices to be able to get new data, when they are online.
But I mentioned being able to function offline, because even if the connection breaks for whatever reason, the local db should be enough to operate normally.

So yeah, it’s kind of a two layers to the question, but I think they are dependent.
One is how can I do a local db on the device?
And the other is how can I do it so that I don’t have to send the whole db when it’s updated and do a delta sync instead?
Thank you!

A suggestion, use an SD card (or FRAM) locally. Use the EDB library to create a rudimentary database (in really just a list of records with fields). In the record have one of the fields used as a checksum. Then when you connect, send each record num and its checksum to your server db and if incorrect send back a update just to that record number. I use this method to have variables and values on my remote devices to make sure that stay in sync with the servers.


Thank you, I will give it a go. Might have to modify it slightly, but will reply later with the solution I end up implementing. Thank you!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.