The main idea of this module is that a mote with this SD "expansion" is able to store a big amount of data from sensors when there is not available wireless communication with the Wireless Sensor Network, later we can get the card from the mote and plug into the computer to check / store the information.
For this application we'll use an example created by Ingo Korb (ingo [@] akana [dot] de) adapted by David Cuartielles. See the link below.
The SD card is connected to Arduino SPI port and analog pins, digital (0-7) pins and UART are available.
Powering the module. In the image below we see the module and the jumper to select the power for the card.
The connection is very easy, the module can be connected to Arduino in two places:
- MicroSD module connected to Arduino => Digital pins 8 - 13 (Power (5V) is taken from pin 8 set as HIGH output).
- Micros SD module connected to SquidBee => The SD module needs an extensor for the pin connector.
Software: First of all we need to create a text file in the microSD card called hola.txt, in this file we write 32 characters, for example '0'.
Then we plug the card into the slot and we connect the module to arduino and arduino to a PC via USB.
The program we use for arduino is very simple, we connect to arduino with a serial port terminal (115200 bps) and we can read / write data in the microSD card. The basic commands are:
- 'R' => for reading the file (hola.txt)
- 'W' => for writing data in the file
We get the characters in the file typing 'R' and we can write new characters typing 'W' and later the 32 characters we want
The advanced code is an example of code for integrating the SD module to SquidBee, data read from sensors are stored in a 512 characters txt file (the file hola.txt with 512 charcaters has to be created in the card previously).
This first example code shows how to read / write data in a txt file with arduino connected to a PC using a serial port terminal.
In the second example code an autonomous SquidBee with the SD module is storing data from the sensors.