Hello, I am using an Arduino Nano 33 BLE Sense and have it connected to an SPI SD card breakout board. The SD card code works as needed. What I am trying to do is take the text read from the SD card and send it to an Android smartphone via BLE.
We are using MIT App Inventor to create a 'BLE Remote' of sorts that the Arduino talks to. When the user presses the 'receive' button on the app, the app sends an arbitrary integer to the Arduino, which then takes this as a signal to send all of the SD card data. More specifically, the data is parsed from the one-byte-at-a-time from the soilFIle.read() function into strings of a size 20bytes. The sdSend characteristic value is updated.
As per current function, the phone only displays the last String value sent. Can anyone with some background in BLE point out what I'm doing wrong here?
Note: The full code for this is quite long and the BLE stuff is the only thing I am having issues with, so I am omitting everything except the most relevant code here since my issue is definitely not some sort of syntax error.
soilFile = SD.open("SoilFile.txt");
if (soilFile) {
while (soilFile.available()) { // read from the file until there's nothing else in it
holder = soilFile.read();
if (charCount < 20)
{
test += String(holder);
//Serial.println(holder);
charCount++;
}
else
{
if (test != prevStr)
{
sdSend.writeValue(test);
}
prevStr = test;
charCount = 0;
test = "";
}
}
if (charCount > 0)
{
sdSend.writeValue(test);
prevStr = test;
charCount = 0;
test = "";
}
MIT App Inventor