0

I would like to transfer files from Raspberry Pi Zero W to PC over USB interface. Is it possible? My idea is to first use Pi Zero standalone to run an application, which generates some files on the microSD card. Later, I want to be able to transfer those files to the PC without taking out the micro SD card on sending a command from PC, perhaps through a custom GUI on Qt or VB.

P.S. I am aware of WinSCP program, that can serve this purpose. But, the IP changes every time Pi is connected. I find it a bit cumbersome to everytime scan for the IP and use it in the WinSCP program.

Raghavan K
  • 31
  • 1
  • 8
  • have you tried SCP to "raspberrypi" instead of IP? DNS should map to the new DHCP IP for you. – OyaMist Jul 22 '18 at 14:33
  • Who controls the network you use? By that, I mean is it a "private home network" with a modem or router that you can configure, and using private IP addresses? Having information on your network will help us help you. – Seamus Jul 22 '18 at 15:44
  • @OyaMistAeroponics I am not aware how to work with SCP. New to Pi world. – Raghavan K Jul 22 '18 at 18:06

2 Answers2

3

Here's how I do it:

  1. Configure your network services properly. You're using your PiZero as a server of sorts, so you'll want to set your PiZero's IP address to a fixed value. Once you've accomplished this, and assuming you have a DHCP server + router combo box on your network that you control: update your DHCP server (and local network DNS server) to reflect the fixed IP assignment on your PiZero. Of course you'll need to follow the procedures outlined for your DHCP/DNS software as this is not a Raspberry Pi issue. Once completed correctly, this network configuration will ensure that: a) your PiZero is always at the same IP address, and b) your DNS knows where that is. You'll be able to find your PiZero easily from your PC afterwards.

  2. Install Samba on your PiZero, and configure your SD card as a "share" (alternatively, use a separate USB drive of some type in lieu of your SD card). There are many guides available to help you do this if you don't already know how. Here's one I prepared on my GitHub site that may be of some use to you.

  3. You can now write files to the Samba share using the standalone programs you referenced in your question, and once your PiZero is connected to the network you configured in Step 1, these files will be available for use/transfer on your PC.

Seamus
  • 18,728
  • 2
  • 27
  • 57
  • Thanks for the response. I will try to follow your procedure. But, is there a simpler way to do this instead of going the network-way? – Raghavan K Jul 22 '18 at 18:07
  • The "network-way" seems simple to me, and I don't know of another way that allows you to avoid having to scan your network each time you need the IP. Once you've done it a few times, it will seem simple to you as well! And the added benefit to you is that you learn something new - something you can build on and use in other projects. – Seamus Jul 22 '18 at 18:24
  • Sure. I will try it out. Would post here if I face any issues. Thanks. – Raghavan K Jul 23 '18 at 04:51
  • As I understand, my PC and the Pi Zero should be on the same network to be able to use this solution. I thought that it would be possible to just connect the Pi Zero to PC and transfer files. Would post here if I face any issues. Thanks for your help. – Raghavan K Jul 23 '18 at 04:58
  • Ummm... well, yes, in a manner of speaking they should be on the same network - actually on the same [`subnet`](https://en.wikipedia.org/wiki/Subnetwork). Don't be intimidated by all of the technical jargon. Keep drinking in small sips, and you will be fine. If you care to edit your question, and include some details on your network, that would help us help you. – Seamus Jul 23 '18 at 15:28
  • In my application, I do not intend to connect my PC or Pi Zero to any router. The only connection shall be between the PC and the Pi Zero & I want a mechanism to transfer the files on Pi Zero's SD to my PC in an easy way. I hope I am clear to you now. – Raghavan K Jul 25 '18 at 05:33
0

Trying to use USB is possible, but overly complex. Use your network!

There is NO NEED to know the IP, you can address the Pi with hostname.local See Connecting a Computer to the Pi in How to set up networking/WiFi

Milliways
  • 54,718
  • 26
  • 92
  • 182
  • I am unable to get into the Pi using the "raspberrypi.local" login in Putty..Hence I had to scan for the IP everytime and login with the same. I use Windows x64 based PC.. – Raghavan K Jul 23 '18 at 04:52