Write data on a SD card with Arduino (MicroSD module and Ethernet Shield)

Today I have been testing a module for Arduino that I had bought on Ebay and I also tried the Micro SD reader located in Arduino’s Ethernet Shield. To do this I made a simple code that writes every 5s the value of a potentiometer connected to the Arduino board in a file called “VALORPOT.TXT” (If this file doesn’t exist It is created and if It already exist the data is added after the existing one).

Escribir datos en SD

The modules I used were the following:

Depending on the module and the type of Arduino board that we use we have to make some connections or other:

· For the ethernet module is only necessary to fit it correctly on the Arduino board and connect the potentiometer to the analog Pin 0.

· In the case of the MICRO SD CARD Adapter module is required to make the following connections:

- MOSI –> Pin 11 (Most Arduino boards), for Arduino Mega: 51
- MISO –> Pin 12 (Most Arduino boards), for Arduino Mega: 50
- CLK —-> Pin 13 (Most Arduino boards), for Arduino Mega: 52
- CS ——> Pin 4
- 5V ——> 5V
- GND –> GND
- Potentiometer connected to analog Pin 0

More information in http://arduino.cc/en/Reference/SPI

The program with corresponding explanations (comments in the code) is the following:

In the SD card a file called VALORPOT.TXT will be created whose content will look like this:

POT: 443
—–5s—–
POT: 478
—–5s—–
POT: 892
—–5s—–

In the next post I will explain how to read data from a SD with Arduino.



Source : Arduino SD Library

Licencia Creative Commons
Write data on a SD card with Arduino (MicroSD module and Ethernet Shield) por Zygzax | Proyectos y tutoriales, electrónica y diseño 3D, a excepción del contenido de terceros y de que se indique lo contrario, se encuentra bajo una Licencia Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported Licencia.

2 thoughts on “Write data on a SD card with Arduino (MicroSD module and Ethernet Shield)

  1. Pingback: Leer datos en SD con Arduino (Módulo MicroSD y Ethernet Shield)Zygzax | Proyectos y tutoriales, electrónica y diseño 3D | Zygzax | Proyectos y tutoriales, electrónica y diseño 3D

  2. dopler

    Hola buenos dias.. pese a que no te conozco quería pedirte un favor..
    Estamos construyendo una antena de seguimiento de codigo libre para drones fpv en aeromodelismovirtual.

    Es posible modificar el codigo que arriba has expuesto.. para que lea la entrada rx (coordenadas gps) y las guarde en la tarjeta sd..?

    La idea es presionar un boton para realizar el inicio de la grabacion(se encienda un led) y y volver a presionar para terminar.. al igual que no sobre escriba el archivo anterior. En cada grabacion.. genere un archivo nuevo..

    Igualmente.. un cordial saludo

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>