MicroSD Cards are a cheap and easy data storage medium, and they are very convenient for storing Arduino sensor data. There are also a number of cheap readily available MicroSD Card Modules for Arduino, and I already made a tutorial on how to log Ultrasonic Ranger distance to MicroSD Card. I also made a tutorial on how to display Location Information from GPS Module to LCD. Almost immediately somebody asked for Tutorial on logging GPS Information to a MicroSD.
Logging data to the MicroSD is easy, but file system management takes memory, and can easily overwhelm small controllers like Arduino Uno or Nano. Indeed, after the MicroSD support is added, Nano and Uno will have almost no memory available for anything else. We can use a controller with more memory such as the Mega or Teensy, however if we just record the serial data from the GPS Module to the MicroSD Card, we will have enough memory on the Arduino Nano, and we can process the data from the MicroSD later on another computer.
Step 1: Components
- One Arduino compatible board (I use Arduino Nano because I have one, but any other will be just fine)
- One GPS module
- One MicroSD Card Module
- One MicroSD Card
- One small Breadboard (Any breadboard can be used, or any other way to connect 3 wires together)
- 7 Female-Female jumper wires
- 3 Female-Male (Red) jumper wires
Step 2: Start Visuino, and select the Arduino Board type
Since the Arduino Nano has only one Serial port, and it is needed to program the Arduino, you will need to program the Arduino Nano before the GPS is connected.
To start programming the Arduino, you will need to have the Arduino IDE installed from here: http://www.arduino.cc/ .
- Start Visuino as shown in the first picture.
- Click on the "Tools" button on the Arduino component (Picture 1) in Visuino.
- When the dialog appears, select Arduino Nano as shown in Picture 2.
Step 3: In Visuino: Add and connect Micro SD Card Module component
First we need to add and connect MicroSD component in Visuino to control the MicroSD Module:
- Type "sd" in the Filter box of the Component Toolbox then select the "Micro SD Card Module" component (Picture 1), and drop it in the design area.
- Connect the "Out" pin of the SDCard1 component to the to the "In" pin of the "SPI" channel of the Arduino component (Picture 2).
- Connect the "ChipSelect" output pin of the SDCard1 component to the "Digital" input pin of the "Digital[ 10 ]" channel of the Arduino component (Picture 3).
Step 4: In Visuino: Add and configure File element to the MicroSD Card component
To record the data we need to add File element to the MicroSD component and specify its file name:
- Click on the "Tools" button of the SDCard1 component (Picture 1).
- In the "Elements" editor select the “File” element in the right window, and then click on the "" button on the left (Picture 2) to add File element.
- In the Object Inspector set the value of the "Path Name" property of the File1Element to "GPSLog.txt" (Picture 3).
Step 5: In Visuino: Connect the Serial Port to the File Element
Connect the "Out" pin of the "Serial[ 0 ]" channel of the Arduino component (Picture 1) to the "In" input pin of the "Elements.File1" of the SDCard1 component (Picture 2).
Step 6: Generate, Compile, and Upload the Arduino code
- In Visuino, Press F9 or click on the button shown on Picture 1 to generate the Arduino code, and open the Arduino IDE.
- In the Arduino IDE, click on the Upload button, to compile and upload the code (Picture 2).
Step 7: Connect the MicroSD Module to Arduino
- Connect Female-Female CS (Gray Wire), SCK (Orange wire), MOSI (Blue wire), MISO (Purple wire), and Ground (Black wire) to the MicroSD Module.
- Connect the Female end of a Female-Male Power (Red) wire to the VCC/Powerpin of the MicroSD Module (Picture 1), and leave the Male end unconnected.
- Connect another Female-Male Power wire (Red wire) to the 5V Power pin of the Arduino board(Picture 2), and leave the Male end unconnected.
- Connect the other end of the Ground wire (Black wire) to Ground pin of the Arduino board(Picture 2).
- Connect the other end of the SCK (Orange wire) to Digital pin 13 of the Arduino board(Picture 3).
- Connect the other end of the MISO (Purple wire) to Digital pin 12 of the Arduino board(Picture 4).
- Connect the other end of the MOSI (Blue wire) to Digital pin 11 of the Arduino board(Picture 4)
- Connect the other end of the CS (Gray wire) to Digital pin 10 of the Arduino board(Picture 4).
- Picture 5 shows in Red where are the Ground, 5V Power, Digital 10, Digital 11, Digital 12, and Digital 13 pins of the Arduino Nano.
Step 8: Connect the GPS Module to the Arduino
- Connect the Female end Female-Male Power (Red) wire to the GPS Module and leave the Male end unconnected.
- Connect Female-Female Ground (Black wire), and TX (Yellow wire) to the GPS Module.
- Connect the other end of the Ground wire (Black wire) to Ground pin of the Arduino board (Picture 2).
- Connect the other end of the TX (Yellow wire) to RX pin of the Arduino board (Picture 2).
- Picture 3 shows in Red where are the Ground, and RX pins of the Arduino Nano(In Blue are shown the connections made in the previous step).
Step 9: Connect the Power Wires together, and plug the MicroSD Card in the module
- Connect the Male ends of the 3 Power wires (Red wires) - from the MicroSD Module, the GPS Module, and the Arduino together as example with the help of a Breadboard (Picture 2) - In my case I used a small Breadboard.
- Insert the MicroSD Card into the MicroSD Card Module (Picture 2).
Step 10: And play...
Congratulations! You have completed the project.
Picture 1 and the Video show the connected and powered up project. The LED on Digital Pin 13 of the Arduino will start flashing from time to time when new data from the GPS is recorded to the MicroSD Card.
In Picture 2 you can see example of the data recorded on the MicroSD Card.
On Picture 3 you can see the complete Visuino diagram. Also attached is the Visuino project, that I created for this Tutorial. You can download and open it in Visuino: https://www.visuino.com.
Comments
Post a Comment