Sandeep Dwivedi
Published

Log Data on SD Card Using the LightBlue Bean

This is tutorial on how to log Data on LightBlue Bean.

BeginnerFull instructions provided1 hour261
Log Data on SD Card Using the LightBlue Bean

Things used in this project

Hardware components

LightBlue Bean
Punch Through LightBlue Bean
×1
microSD card with microSD to SD adapter
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Male Header 40 Position 1 Row (0.1")
Male Header 40 Position 1 Row (0.1")
×1
AA Batteries
AA Batteries
×1
4xAA battery holder
4xAA battery holder
×1

Software apps and online services

Punch Through Bean Loader for any platform

Story

Read more

Schematics

circuit connections

connect all connections according to figure

Code

LightBlue

C/C++
Code to uplad on LightBlue Bean
/* 
 This example shows how to get the ambient temperature
 in degrees Celsius from the Bean's built-in temperature sensor 
 and log it on an SD card using the SD library.

 Please note that you have to modify the SD library to use 
 it with the Bean.

 In Sd2PinMap.h, line 278-281, change the pins to the following:
 SS_PIN = 2;
 MOSI_PIN = 3;
 MISO_PIN = 4;
 SCK_PIN= 5;

 This example code is in the public domain. 
 */

#include <SD.h>

const int chipSelect = 2;
uint8_t temp;

void setup()
{
  Serial.begin();
 // Check if the card is present and can be initialized
 if (!SD.begin(chipSelect)) {
    Serial.println("SD fail");
    return;
  }
}

void loop()
{
  // Get the ambient temperature with a range of -40C to 87.5C
  temp = Bean.getTemperature();

  // Open the data file
  File dataFile = SD.open("datalog.txt", FILE_WRITE);

  // If the file is available, write to it:
  if (dataFile) {
    dataFile.println(String(temp));
    dataFile.close();
  }

  // If the file isn't open, send an error message over serial
  else {
    Serial.println("error opening datalog.txt");
  }

  // Sleep for a minute before we read the temperature again
  Bean.sleep(60000);
}

Credits

Sandeep Dwivedi

Sandeep Dwivedi

7 projects • 9 followers
just a learner curious about things

Comments

Add projectSign up / Login