Too many times in the past I wanted to save my sensors’ readings in a file for future analysis, and I didn’t find an easy way till the data logger shields came up. One of the most reliable shields in the market is the Sparkfun data logger shield, and today I will make a detailed comparison between it and our 1Sheeld data logger shield.
Now let’s go in a step by step tutorials for each shield till we can log an LDR sensor readings in a .csv file.
1- SparkFun Data Logger Shield
This Data logger shield gives you the ability to log any text data you want to an SD card in any text format you like.
The shield comes unsoldered so you should solder it after buying R3 stackable headers, it also comes without SD card so you should get one with an adaptor.
This SD card is communicating with the Arduino board through SPI protocol so there are 4 reserved pins in the shield for the SD card communication which are (8, 11, 12 and 13).
After getting the needed materials to run the shield now we are ready to go with our step by step tutorial.
Step 1: Adjust the shield
As I said before that the shield comes unsoldered so it’ the time to solder it and of course you will need a soldering iron and a solder.
Voila! Here it is after soldering the headers.
Step 2: Mount the shield over the Arduino board
In my case I’m using the Arduino UNO board so please while mounting the shield don’t push it hard to the Arduino board cause it will hit the USB interface and may break the board.
Step 3: Get an SD card
Get an SD card like we mentioned above and format it in any FAT format, it’s a default for the SD cards to be formatted in FAT but you should reformat it cause if you don’t the SD card won’t work probably with the shield.
Step 4: Get the libraries
The shield needs 2 main libraries to run which are:
SPI: It’s the library used to configure the SPI port of the Arduino to communicate with the SD card module and it is also embedded in the Arduino IDE.
SD: This library is used to configure the SD card module itself and also comes by default with the Arduino IDE.
Step 5: Write the code
This code actually is an example from the SD library, you can find it at File >> Examples >> SD >> Data logger
But I made some simple changes like the chip select which was on pin 4 and now I made it on pin 8 cause the chip select on the shield is configured on this pin.
The LDR is configured on pin A0 and am only taking that reading once the system powered on and start logging it in a .csv file named readings on the SD card.
SD card datalogger
This example shows how to log data from analog sensor
to an SD card using the SD library.
* LDR on analog pin 0.
* SD card attached to SPI bus as follows:
** MOSI - pin 11
** MISO - pin 12
** CLK - pin 13
** CS - pin 8
created 24 Nov 2010
modified 20 Dec 2016
by Tom Igoe and some modifications from Ahmed Ismail
to be suitable for Sparkfun data logger shield
This example code is in the public domain.
// Open serial communications and wait for port to open:
;// wait for serial port to connect. Needed for native USB port only
Serial.print("Initializing SD card...");
// see if the card is present and can be initialized:
Serial.println("Card failed, or not present");
// don't do anything more:
// make a string for assembling the data to log:
// read three sensors and append to the string:
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
// if the file is available, write to it:
// print to the serial port too:
// if the file isn't open, pop up an error:
Serial.println("error opening Readings.csv");
Step 6: Build the hardware
The hardware consists of:
SparkFun Data logger shield
5 jumper wires
2- 1Sheeld Data Logger Shield
And now it’s our Data logger shield time!
For anyone who does not know about 1Sheeld, it is a board that connects your smartphone’s sensors and peripherals to the Arduino, allowing your smartphone to control Arduino and Arduino to control anything on your phone.
The most important thing in 1Sheeld is that you can make a lot of amazing things with only 1 line of code!
So, here we are going to use the data logger shield of the 1Sheeld to log a sensor’s readings that collected for an hour and repeat the same operation every new hour begin.
This code briefly is using two shields from the 1Sheeld, the data logger shield and the Clock shield cause am using this code to
open a new file to log the readings in every hour in a file named LDR values and log the readings in a column named Brightness.
/* Include 1Sheeld library. */
/* Define the ldr on pin A0. */
#define LDR A0
/* Define some variables for the time and ldr. */
/* Boolean to start logging. */
/* Start communication. */
/* Save any previous logged values. */
/* Start the clock shield. */
/* Always get the time. */
/* check If the seconds reaches zero. */
/* First insure to save previous logged values. */
/* Set a delay. */
/* Start logging in a new CSV file. */
/* Set startFlag. */
/* Check logging started. */
/* Add brightness level values as a column in the CSV file. */
/* Delay for 2 seconds. */
After writing the code, make sure to set 1Sheeld UART switch to the upload mode before you upload your code on Arduino.
After uploading the code, the 1Sheeld is not ready to work until you switch it back to the operating mode.
Operating mode is turned on when the UART switch is pushed towards 1Sheeld logo.
Step 6: Use the 1Sheeld application
Open 1Sheeld application on your Android phone or iOS device.
The application will first scan over bluetooth for your 1Sheeld, it will take a few seconds and the phone will find it.
Once it appears on your screen as 1Sheeld #xxxx, you will be required to enter the pairing code (the default pairing code is 1234) and connect to 1Sheeld via Bluetooth.
Step 7: Access the shield
Select the shields you would like to use in your Arduino sketch and press on the multiple shields icon at the top right of the app.
In this case, use data logger shield and the clock shield.
Our YouTube channel is full of tutorials and you can find the Data Logger Shield full tutorial right there also the 1Sheeld website has lots of amazing Arduino projects that can gives you great ideas.
Step 8: Setup the hardware
If you noticed you will find that it’s slightly the same hardware as we made for the Sparkfun shield except that we don’t need to get an SD card, I only add my smartphone to log the readings into it.
And now let’s summarize these comparison briefly in this table
SparkFun Data logger shield
1Sheeld Data logger shield
Creating all txt file
Just .csv files
Observing data remotely
Adding columns with names
Showing the time of data logged
The file name could be long
No (Just 8 characters)
At the end of this comparison I hope that i had covered all the needed points and of course, if you have any comments it’s a pleasure to leave it here just under the blog :).
Arduino makers …. you can connect your Arduino to MQTT brokers(servers) and launch your IoT with Arduino IoT Shield! It’s the 1Sheeld IoT shield that will do the job for you. It’s one of the most important but recent Arduino shields in 1Sheeld. Simply, it turns your Arduino into MQTT client where you can publish and …
Monitor my home environmental parameters remotely is one of the most desirable things I have ever wanted to make. It’s not about purchasing such a system that can get the job done for me. But, passion to create it myself. So, today, I am going to connect the popular DHT sensor to an online MQTT …
“Oh God! … It seems like I have forgotten the door lock open, again” … the normal saying whenever I am in hurry to go out! Have you encountered this problem before? It always confuses me since I may even think that I have left the door lock opened, and once I go back, …
Here I am with another IoT-based home automation project; Arduino IoT Fan Control. Every day, I get back from work tired and feeling hot. No air conditioner here and the fan takes much time to start cooling the room, sadly! So, I was thinking why not controlling the fan from outside my home with my …
Have you ever forgotten to turn your home lights off when you got outside? Sadly, it happens to me all the time. And this causes confusion once I get my bills! Furthermore, here is one secret about me; I am a lazy man. I always want to control my room lamp from my sweet bed. …
Welcome to our home automation hacks series #3, for so many times I had problems with watering my plants while traveling abroad and I have always needed a way to control it remotely, then I decided to do it with one of the fanciest ways you may ever hear off, cause I’m gonna water my …