[SDFat] Logging data from sensor to sd card


#1

I am trying to store data from an analog light sensor to an sd card at an interval. By referring to this tutorial (Particle electron SD card problem [SDFAT library]) I think I was able to get the sd card to work? I tested on the program tryMeFirst from the sdfat library, with the following output

1:
2

So I think my sdcard works. But I don’t know how to approach logging the data from my light sensor (analog read from pin B5, 3.3V connection, and GND connection) onto the sd card. I looked at some other examples in the sdfat library, but it’s kind of overwhelming. In the loop, I’d like the sensor to gather data, then have it store the data to the sd card. then possibly introduce a delay for a period of time, and have the process repeat. This is what I’ve coded so far. The light sensor data is being read and outputted on the serial monitor, but no file is being created… Any advice?

P.S. For the following code, even the light data is not read on read


#2

You could try @rickkas7’s SD card logger
https://build.particle.io/libs/SdCardLogHandlerRK/0.0.4/tab/example/SdCardLogExample.cpp


#3

Can’t even compile the code. It says “Arduino.h: No such file or directory”


#4

This suggests that you are targeting a too old device OS version.
It needs to be 0.6.2 or higher - currently 1.0.0 would be your best choice.


#5

How would I do that?

Here is what I currently see:


#7

You were right about my device. I updated it to 1.0.0. I tried to run the code, but still fails. The SdFat is updated as well.


#8

How did you update?
Have you changed the target firmware in Web IDE?
image


#9

Particle CLI in the command prompt I typed in particle update and it said updated successfully


#10

Can you post a SHARE THIS REVISION link?


#12

https://go.particle.io/shared_apps/5c3fe35e1a6c23999f000128