B4R Tutorial Arduino - PC File Transfer

In this example the Arduino board acts as a server. Clients can list the available files and can download files stored on the SD card, which is part of the Ethernet shield.

SS-2016-06-08_11.24.37.png


To make the solution more reliable, the communication is stateless, similar to HTTP requests. The client sends a request, the server (Arduino) sends the response and closes the connection.

The client verifies that that the response is complete and then analyzes the response.

The SD and the ethernet features cannot be used at the same time as both work with the same SPI lines. We need to select which SPI peripheral is active. This is done with the SetSD sub.

Note the usage of the large buffer in the client program. It simplifies the client solution.

I've tested it with files of several mega bytes and the files were transferred successfully.

The size of the compiled program is 35kb which means that you need a larger board such as the Arduino Mega.

During the tests I've found a bug in SD.ListFiles which can cause some of the files to be omitted.
 

Attachments

  • B4J_FileTransfer.zip
    3.2 KB · Views: 1,209
  • B4R_FileTransfer.zip
    1.6 KB · Views: 1,284
Last edited:

rbghongade

Active Member
Licensed User
Longtime User
Dear friends,
Can we transfer files stored on SD card connected to WEMOS mini D1, to Android device, with similar code?
 

Cableguy

Expert
Licensed User
Longtime User
My answer would be yes, but not with an ethernet connection.

There's already a simple WiFi server example, for esp8266, so the rest should be straight forward
 
Top