I recently got into arduino and I want to set up something big. My project will need the arduino to be able to get into a specific directory of a windows (later may change to linux but for now windows) computer which will have some files with values required for the arduino to run.

Is it possible to set it to go to a fixed path and open a file with a specific name and get it's contents?

Ideally I would want those values to be stored to my micro sd so I do not load too many things on memory as my board is a Leonardo and the code is quite extensive already. (The board can be changed if needed)

Any help/ideas are appreciated!

  • 2
    what kind of files are on the windows machine that you wish to retrieve? ..... set up a web server on the windows machine .... the Arduino could get the files as a web client
    – jsotola
    Nov 3, 2018 at 17:22

2 Answers 2


The Arduino has no access to the file system on a PC. All it has is a serial connection with which it can communicate with some program running on the PC. The code that is handling the PC's file system would have to run on the PC itself.

  • Leonardo has USB for HID.
    – Juraj
    Nov 3, 2018 at 16:33
  • @Juraj how would that help?
    – Majenko
    Nov 3, 2018 at 16:34
  • It would not. But it is not true that it has only a 'serial' connection. (and I know that USB is serial communication too)
    – Juraj
    Nov 3, 2018 at 16:35
  • @Juraj Strictly speaking, yes it is true. The "S" in USB stands for Serial. It has a serial connection - over which a number of protocols are layered. One of which itself emulates another serial connection.
    – Majenko
    Nov 3, 2018 at 16:36
  • 1
    But how do you then get the data back to the Arduino? It can't see the screen. You'd basically have HID writing a program on your PC that reads the data and sends it down through the CDC/ACM channel. Quite a task, and really a bit silly. Just write the program for the PC and have it communicate through CDC/ACM alone - that way it doesn't mess with your desktop session and interrupt you. Or use a network connection instead and collect the data from a website / online service.
    – Majenko
    Nov 3, 2018 at 16:42

This could get complicated.

You'll need to develop a USB interface on your Arduino to "talk" to the PC. Then you'll need to write an application (use whatever language you feel comfortable with - that's an entire religious discussion for another place and time) that "listens" for the Arduino's USB connection and does most of the legwork. Think of the PC application as sort of a "script server", allowing the Arduino to make cryptic requests ("FCNT" requests a 'File Count' on your target PC folder, that sort of thing) which the PC application will then return data from, as needed. (In the previous example "FCNT" gets a file count of a predetermined folder - which would return a four-byte [integer] value revealing the results of the file count.) From this point you could add additional scripts and functionality, allowing your Arduino to make abbreviated (sometimes wonky-seeming) calls to the PC, and have the PC do what is necessary to fulfill those requests.

In the example I hastily described above, your Arduino sends "FCNT" and then "listens" to the USB interface, eagerly awaiting the return value that it knows will be a four-byte response. If the PC application were properly programmed, you could get slick with your command calls, sending "XFR #" which asks the PC application to "transfer file [#] to me" at which time the Arduino goes into "paddle board" mode, where it receives data from USB and immediately transfers it to the MicroSD until is "seen" in the data stream, at which point the Arduino returns to normal code operations mode.

Of course, your PC application will need to be extremely fault-tolerant in order to prevent sending your Arduino bad data or worse, sending it into a state that can't be easily recovered, such as if the Arduino "thinks" it's expecting a file and goes into "wait for transfer" state, but the file it requested doesn't exist because it got deleted sometime between the file count request and the transfer request. The Arduino would appear to be "hung up" because it would be in "File Transfer" or "paddle board" mode, and not looking for other messages or awaiting other operator stimulus.

Due to the different architectures, there really is no simple way to interface an Arduino to a PC. Sorry about that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.