Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of WikiWatershed, a web toolkit designed to help citizens, conservation practitioners, municipal decision-makers, researchers, educators, and students advance knowledge and stewardship of fresh water. New to EnviroDIY? Start here

Transfer file from SD card to iOS/Android via bluetooth

Home Forums Infrastructure and Equipment Transfer file from SD card to iOS/Android via bluetooth


Viewing 1 reply thread
  • Author
    • #14998

      Newbie question here…I successfully setup the Mayfly to measure and record temperature and dissolved oxygen to the SD card. Access to the loggers will require someone to paddle out in a canoe or kayak. Rather than have them risk dropping the SD card in the water while transferring data to a laptop, I’d like to have a simple file transfer via bluetooth to their smartphone.

      I’m using a HM-10 bluetooth module wired to the TXD and RXD ports (5 volt). I can connect to the bluetooth and send/receive text strings through the serial port but I can’t figure out how to transfer the file from the SD card to the smartphone through the bluetooth device. An internet search suggests using the DumpFile script in  SoftwareSerial.h (see below)

      #include <SPI.h>
      #include <SD.h>
      #include <SoftwareSerial.h>
      const int chipSelect = 12;
      SoftwareSerial BTSerial(3, 2); // RX | TX[/b]

      void setup() {
      // Open serial communications and wait for port to open:
      while (!Serial) {
      ; // wait for serial port to connect. Needed for native USB port only

      Serial.print(“Initializing SD card…”);

      // see if the card is present and can be initialized:
      if (!SD.begin(chipSelect)) {
      Serial.println(“Card failed, or not present”);
      // don’t do anything more:
      while (1);
      Serial.println(“card initialized.”);

      // open the file. note that only one file can be open at a time,
      // so you have to close this one before opening another.
      File dataFile = SD.open(“test.txt”);

      // if the file is available, write to it:
      if (dataFile) {
      while (dataFile.available()) {
      // if the file isn’t open, pop up an error:
      else {
      Serial.println(“error opening test.txt”);

      This works but it only spits out the data from the file on the SD card to the serial COM port on my laptop but not the bluetooth terminal on my smartphone. What am I missing?

    • #15061
      Sara Damiano

      I’m sorry, I’ve never tried anything with Bluetooth, so I’m only guessing here.

      If the Bluetooth chip is that simple, and you have it connected to TXD and RXD on your Mayfly, you should print to the bluetooth using just Serial.print and not do anything with SoftwareSerial.  Serial is the TXD and RXD on the Mayfly.  You could also connect it to TX1 and RX1 and use Serial1instead of sharing with the FTDI/PC output.

      The range of Bluetooth is very short under water (a few inches) so your users wouldn’t be able to do a float-by download.  They would most likely still need to pull the logger out of the water, and then initiate the Bluetooth connection.  Once it’s out of the water, though, you hopefully could get the data without actually opening the sealed box.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.