Hi!
I am using the analog device ad8232, an arduino uno, a (Waveshare) Micro Sd Card module and a 9V battery. I want to write the voltage data on the sd card without using the usb cable and then just insert the sd card to the computer and process the data from the file that has been created. I have connected both the ad8232 and the Micro Sd Card module to 3.3V with the use of a breadboard.
When I am doing a recording using the battery and then insert the sd card to the pc, a data file has been created but it is empty. What is wrong?
This is the code that I have uploaded:
Ignore the lines concerning Bluetooth connection, I am not using it for this trial.
#include <SPI.h>
#include <SD.h>
#include <SoftwareSerial.h>
File dataFile;
SoftwareSerial MyBlue(2, 3); // RX | TX
int flag = 0;
void setup() {
// initialize the serial communication:
Serial.begin(9600);
MyBlue.begin(9600);
SD.begin(4);
pinMode(9, INPUT); // Setup for leads off detection LO +
pinMode(10, INPUT); // Setup for leads off detection LO -
dataFile = SD.open("data.txt", FILE_WRITE);
}
void loop() {
if ((digitalRead(9) == 1) || (digitalRead(10) == 1)) {
Serial.println('!');
}
else {
// send the value of analog input 0:
int value = analogRead(A0);
float voltage = value * 0.00322;
Serial.println(voltage);
MyBlue.println(voltage);
dataFile.println(voltage);
if (analogRead(A0) < 1)
{
dataFile.close();
while (1) {}
}
}
//Wait for a bit to keep serial data from saturating
delay(1);
}