I have a heart signal ( mp3 file) which I imported into Matlab, extracted the data points and stored in a text file. I copied the text file onto an 8 Gig SD Card
I modified the SD card file dump example in Arduino and combined with a Bluetooth transfer example. I am unable to receive the data on the android phone when I try the code (See Below). But the Bluetooth program and the SD card file dump examples work when tested independently.
Please, can anyone help to successfully load the data from SD on Arduino, and transfer to Android via Bluetooth.
I used Arduino Uno, HC-05 (cz-hc-05 Gomoku ) and SD Shield 3.0.
I also used the android application BlueTerm 2.
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11); // RX | TX
//SoftwareSerial BTserial(2, 3); // RX | TX
// Connect the HC-05 TX to Arduino pin 2 RX.
// Connect the HC-05 RX to Arduino pin 3 TX through a voltage divider.
//
void setup()
{
Serial.begin(9600);
Serial.println("Enter AT commands:");
// HC-06 default serial speed for communcation mode is 9600
BTSerial.begin(9600);
}
void loop()
{
BTSerial.begin(38400); // HC-05 default speed in AT command more
float sensorValue = analogRead(A0)*5.0/1023.0;
BTSerial.println(sensorValue); //This allows me to simultaneoulsy see the voltage values on the android phone & the Serial monitor
Serial.println(sensorValue); //
delay(1000);
}
#include <SoftwareSerial.h>
#include <SPI.h>
#include <SD.h>
//heart sound files available : HSAPRIL4, DUMMY, HSEDITED
SoftwareSerial BTSerial(10, 11); // RX | TX
File myFile;
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
BTSerial.begin(38400); // HC-05 default speed in AT command more
}
Serial.print("Initializing SD card...");
if (!SD.begin(4)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
myFile = SD.open("HSEDITED", FILE_WRITE);
// re-open the file for reading:
myFile = SD.open("HSEDITED.txt");
if (myFile) {
Serial.println("HSEDITED.txt:");
// read from the file until there's nothing else in it:
while (myFile.available()) {
** Serial.write(myFile.read());**
** BTSerial.println(Serial.write(myFile.read()));**
** // Challenge is getting the data read & shown on the Serial monitor, to be transfered via bluetooth to Android**
}
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening HSApril4.txt");
}
}
void loop() {
}