Need Guidance : Fetch a file from SD card and transmit it using NRF24L01.

Hi, I have this task of fetching a .txt file from an SD card and send that .txt file using NRF module. Right now, I am only planning of a .txt file of size few Kb (10kb is enough). So, that should be easy. Isn't it ?

What I figured out so far :

I have looked at the SdFat library and found that it has functions to list out the files, open a file and print out the contents in that file. And I hope that's enough.(Right ?)

I also looked at the RF24 library. It also has few easy to use functions such as radio.write(msg,strlen(msg)) to send a string of 32bytes at once that is stored in a char variable msg.

And in order to do that I will have to send the returned data by SD functions to radio.write() as a char array.

What I don't have idea on is :

Because, the SD card reader and the NRF module works on SPI protocol (Sharing MOSI, MISO and SCK pins). Do I have to store the fetched data (file name and its content) in EEPROM or something before I disable the CS pin of SD card and enable the CS pin of NRF ? Is there any other way I can do it without storing ? I don't know if I have to use some kind of buffer !!

Thanks.

Read (next) N bytes from file Switch Send N bytes Back to read

You read as long as there is data in the file.

N can be 10 bytes, 100 bytes, ...; it will not be the full file. The number of bytes that you can read in one go depends on the amount of ram.

Thanks for replying.

sterretje: Read (next) N bytes from file Switch

Yep. After reading N bytes. And lets say I have few seconds of delay before I switch to the NRF. Now, where will it be stored in this mean time. ?

sterretje: The number of bytes that you can read in one go depends on the amount of ram.

Is that gonna still be in RAM.? If so, wouldn't I need another function in order to read from RAM ? Or Is it that the read characters can be assigned to an array to store.? And the address of the very same array can be passed as parameter to radio.write() ?

I think I don't understand some basic concept here.

You need to create a byte array with at least 32 bytes. Then read 32 bytes into it from the SD Card. Then send those 32 bytes using the nRF24.

The array will be in the Arduino's SRAM and its contents will remain there (unless you change them) as long as the Arduino is powered up - potentially for years.

Actually I think you usually read from and write to the SD Card in 512 byte chunks so you could send that as 16 successive wireless messages.

You sent me a PM about my DIY SD Card device. The lines SS, MOSI and SCK carry 5v from the Arduino to the SD Card so on each of those I have a voltage divider wired like this

Arduino ----> 470 ohms --+---> 1000 ohms ---> GND
                         |
                         v
                     SD Card

The MISO line carries 3.3v from the SD Card to the Arduino so that is coupled directly.

...R

Thank you very much. I will soon get it working and will post again if any doubts (or my success story) And I will next on ask the doubts on forum instead of PM-ing.

Did you ever manage to do this setup to work? I m interested in making this setup.

alkuentrus: Did you ever manage to do this setup to work? I m interested in making this setup.

You should start a new thread, btw its not that difficult to make NRF24L01 work.

jackthom41: You should start a new thread, btw its not that difficult to make NRF24L01 work.

I was planning to do so. However before doing that, I took a shot asking before :)

It is not difficult to make RF24 work is many ways, except this one. Reading / Writing files from / to sd card. That's my goal now. Thanks for your answer :)

jackthom41: You should start a new thread

One can always ask.

jackthom41: btw its not that difficult to make NRF24L01 work.

I still haven't managed ;) Tried, possibly blew up two units ( :( ), tried again with different units and they don't communicate. On the todo list :)

sterretje: One can always ask. I still haven't managed ;) Tried, possibly blew up two units ( :( ), tried again with different units and they don't communicate. On the todo list :)

See this Simple nRF24L01+ Tutorial

The examples are as simple as I could make them and they have worked for other Forum members.

...R

Robin2: See this Simple nRF24L01+ Tutorial

The examples are as simple as I could make them and they have worked for other Forum members.

...R

I did try them ;) As well as some that came with the library if I'm not mistaken.

Guess there is some hardware problem somewhere :( As said, on the todo list :)