Ideas for datalogger project


#1

Hi,
I have a project that will be receiving data from serial port, adding a timestamp and then saving records to SD card.

What I want to do next is to upload any records on the SD card when cloud is available and store them when it is not.

I am looking for ideas to implement the functionality below in firmware.

  1. Check cloud is available
  2. If available then start sending batches of records from log file to cloud
  3. If all records are sent then rewrite log file (start with clean 0 record file again)
  4. Otherwise, remove records that have been sent (only leave unsent records)

The thing that I am not sure about is how to write into a single record without having to read all data into ram first and not sure if there is a “getNumberOfLines” function. Maybe I read line by line into a single variable (to simply count number of items) and have a pointer at end of the file that indicates last line read.

Therefore I would open the file, determine how many lines exist and read the last line to get current lastSent pointer.
Then close and reopen the file and scan through until last lineSent and start sending more data.
If I reach end of file then the file can be re-written back to zero bytes?

Hopefully, I am missing something and it is more straight forward than this.


#2

I think it might depend a bit on how much data you’re talking about, but you may need to do what you talk about.

One thing that might make this a little easier is the HologramCloud.print() function. This lets you basically construct and queue up a message but not send it until you call the sendMessage function.

Hopefully I’m not misunderstanding your message here.