Micro SD adapter

[ [ images & links ] ]

Pada mashup sebelumnya, telah diungkapkan mengenai data logging shield. Di papan logger yang ditujukan untuk ukuran papan Arduino Uno itu sudah terdapat RTC. Namun ukuran sistem itu relatif besar dan karenanya pin papan itu tidak mudah diterapkan di sistem lain seperti papan Arduino Nano atau papan Arduino Micro. Alternatif lain adalah MicroSD Card Adapter seperti yang akan ditampilkan di halaman ini.

Gambar 1. [elabpeers.com]

Arduino SD Card and Data Logging to Excel Tutorial :

Gambar 3.


Arduino Data Logging

Now let’s make another more interesting example of data logging a temperature sensor. For that purpose we will use the DS3231 Real Time Clock module which has a built-in temperature sensor as well. You can find more details about how to connect and use this module in my previous tutorial.

So after connecting the two modules to the Arduino let’s take a look at the code for this example.

Arduino LC Studio SD Card Tutorial :

Arduino LC Studio SD Card Tutorial Hook UpGambar 4. [henrysbench.capnfatz.com]

Arduino Nano SD Card Connection :

Arduino Nano SD Card ConnectionGambar 5.


What is a Data-logger [datalogger.pbworks.com ]

Gambar 6.

Data logging shield

[ [ images & links ] ]

https://learn.adafruit.com/adafruit-data-logger-shield?view=all :

Gambar 1. learn.adafruit.com


adafruit_products_labeled.jpgGambar 2.


Place the SD library folder your sketchbook libraries folder. You may need to create the libraries subfolder if its your first library.



https://learn.adafruit.com/adafruit-data-logger-shield?view=all :

adafruit_products_Logger_bb.jpgGambar 3.

Adafruit library examples.

Deek-Robot: Data logging shield V1.0

D10 – Chip Select

“Next is the error() function, which is just a shortcut for us, we use it when something Really Bad happened, like we couldn’t write to the SD card or open it. It prints out the error to the Serial Monitor, turns on the red error LED, and then sits in a while(1); loop forever, also known as a halt

“Now the code starts to talk to the SD card, it tries to initialize the card and find a FAT16/FAT32 partition.

Next it will try to make a logfile. We do a little tricky thing here, we basically want the files to be called something like LOGGERnn.csv where nn is a number. By starting out trying to create LOGGER00.CSV and incrementing every time when the file already exists, until we get to LOGGER99.csv, we basically make a new file every time the Arduino starts up

To create a file, we use some Unix style command flags which you can see in the logfile.open() procedure. FILE_WRITE means to create the file and write data to it.

Assuming we managed to create a file successfully, we print out the name to the Serial port.”

“OK we’re wrapping up here. Now we kick off the RTC by initializing the Wire library and poking the RTC to see if its alive.

Then we print the header. The header is the first line of the file and helps your spreadsheet or math program identify whats coming up next. The data is in CSV (comma separated value) format so the header is too: “millis,time,light,temp” the first item millis is milliseconds since the Arduino started, time is the time and date from the RTC, light is the data from the CdS cell and temp is the temperature read.

You’ll notice that right after each call to logfile.print() we have #if ECHO_TO_SERIAL and a matching Serial.print() call followed by a #if ECHO_TO_SERIAL this is that debugging output we mentioned earlier. The logfile.print() call is what writes data to our file on the SD card, it works pretty much the same as the Serial version. If you set ECHO_TO_SERIAL to be 0 up top, you won’t see the written data printed to the Serial terminal.

Finally, we set the two LED pins to be outputs so we can use them to communicate with the user. There is a commented-out line where we set the analog reference voltage. This code assumes that you will be using the ‘default’ reference which is the VCC voltage for the chip – on a classic Arduino this is 5.0V. You can get better precision sometimes by lowering the reference. However we’re going to keep this simple for now! Later on, you may want to experiment with it.”

Main loop

Now we’re onto the loop, the loop basically does the following over and over:

  1. Wait until its time for the next reading (say once a second – depends on what we defined)
  2. Ask for the current time and date froom the RTC
  3. Log the time and date to the SD card
  4. Read the photocell and temperature sensor
  5. Log those readings to the SD card
  6. Sync data to the card if its time

“The first important thing is the delay() call, this is what makes the Arduino wait around until its time to take another reading. If you recall we #defined the delay between readings to be 1000 millseconds (1 second). By having more delay between readings we can use less power and not fill the card as fast. Its basically a tradeoff how often you want to read data but for basic long term logging, taking data every second or so will result in plenty of data!

Then we turn the green LED on, this is useful to tell us that yes we’re reading/writing data now.

Next we call millis() to get the ‘time since arduino turned on’ and log that to the card. It can be handy to have – especially if you end up not using the RTC.

Then the familiar RTC.now() call to get a snapshot of the time. Once we have that, we write a timestamp (seconods since 2000) as well as the date in YY/MM/DD HH:MM:SS time format which can easily be recognized by a spreadsheet. We have both because the nice thing about a timestamp is that its going to montonically increase and the nice thing about printed out date is its human readable.”

https://learn.adafruit.com/adafruit-data-logger-shield?view=all :

Plotting with a spreadsheet

adafruit_products_dataselect.gifGambar 4.

Gambar 5.

https://learn.adafruit.com/adafruit-data-logger-shield?view=all :

Using Gnuplot



adafruit_products_gnuplotcmd.gifGambar 6.

adafruit_products_gnuplotted.gifGambar 7.

https://learn.adafruit.com/adafruit-data-logger-shield?view=all :

adafruit_products_adafruitlogshieldsch.pngGambar 8.

Gambar 9.

Gambar 10.

Gambar 11.

Gambar 12.