SD Bee not logging

I followed the example here https://en.docs.sensebox.de/blockly/blockly-sd/ to log CO2 data to an SD Bee. However, I don’t get any data. The SD card is a 64GB FAT formatted.

code is here

#include <SPI.h>
#include <SD.h>
#include "SparkFun_SCD30_Arduino_Library.h"
#include "SenseBoxMCU.h"

int co2;

File dataFiledata;
SCD30 airSensor;

void setup() {
  SD.begin(28);
  dataFiledata = SD.open("data.txt", FILE_WRITE);
dataFiledata.close();

   Wire.begin();
  if (airSensor.begin() == false)
  {
    while (1)
      ;
  }

  co2 = (int)(airSensor.getCO2());

}

void loop() {

dataFiledata = SD.open("data.txt", FILE_WRITE);
    dataFiledata.println(co2);
  dataFiledata.close();

}

Hi Blaise,
you read the the sensor only once in the „setup“ function. In loop you write always this value into the data file. So move the line
co2 = (int)(airSensor.getCO2());
into the loop function and you should get new and different values. You may use delay (https://www.arduino.cc/reference/en/language/functions/time/delay/) to reduce the amount of written sensor data to the SD Card
Bernd

Thanks for your reply Bernd.

However I have set it up in this way

image

but still not getting any file on my SD card.

Hi @blaise,

is the SD-Modul connected to the XBEE2 Port? Could you try to use a different SD-Card? Large SD Cards greater than 32GB could be the problem.

On another post I sent a picture. Yes it is the XBEE2 port.

Where does it say cards over 32GB can’t be used? Over the years I have actually not bought anything less than 64 as there is almost no cost difference between them and smaller ones. My raspberry pi 1 handles a 64GB card fine.

Can you confirm what the maximum size is. Again this is surely something to mention in the shop?

For the code generator in blockly we are using the standard Arduino SD Library which supports SD Cards up to 32GB.

You can use other Libraries like SdFat (https://github.com/greiman/SdFat) which also support propper formatted larger SD-Cards.

So its not really a hardware related problem more related which software one is using and the main purpose for blockly is the use with the senseBox:edu which includes only a 16GB SD-Card, so we didn’t ran into this issue before.

I’ll check if I can easily migrate the code to the SdFat library in blockly, but it might take some time due to other work to do.