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.


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.


  • B4J_FileTransfer.zip
    3.2 KB · Views: 1,108
  • B4R_FileTransfer.zip
    1.6 KB · Views: 1,183
Last edited:


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?


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