ghostrider513
Posts: 35
Joined: Tue Mar 28, 2017 6:03 am

How to save data to usb in Raspberry Pi

Wed Jun 27, 2018 9:43 pm

I have a RPI 3B+ and the SHT31D sensor connected. I have a directory that I created for my thumb drive called usbdrv. I want to do two things:
set the sensor file to repeat the datalogging every 5 seconds and
save that data to a file in the usb directory. The directory file in my drive is called data.

I have created a file: data_log.csv but it can't be read by Excel. It isn't even visible on my thumb drive but I can read the file in pi??? not sure why?


I'd really like the data to be saved as a CSV file so I can upload it to my website MYSQL. I'd have to do that manually but better than trying to get this to automatically do it for me.

Here's my code for the sensor: www.parapsych.us/img/code.png
Here's a copy of my directory:
Image

User avatar
Paeryn
Posts: 2633
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: How to save data to usb in Raspberry Pi

Thu Jun 28, 2018 12:01 am

You've created the usbdrv directory in your home directory, have you actually mounted the usb drive there? If you are relying on the usb automounter then usually it gets mounted to /media/pi/name_of_disk

BTW, I think you need to prefix the address of the image with http:// otherwise the forum will think the image is local to the forum, hence why it isn't showing it.
She who travels light — forgot something.

User avatar
HawaiianPi
Posts: 4530
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: How to save data to usb in Raspberry Pi

Thu Jun 28, 2018 1:59 am

From your picture it looks like the file is being saved to the /home/pi directory.

If you want the file to be saved to a "data" folder on your USB drive, and your USB drive to be accessed in the "usbdrv" folder in your home directory, you must mount the USB drive to /home/pi/usbdrv, and then save the file to /home/pi/usbdrv/data.

Mounting is usually done in the /etc/fstab file (which must be edited with sudo). You'd need to add something similar to this:

Code: Select all

PARTUUID=12345678-01     /home/pi/usbdrv     vfat     defaults,nofail     0     0
With the PARTUUID of your USB drive partition (and the correct filesystem specified if you're not using FAT/16/32).

You could probably also use /dev/sda1, assuming you're booting from SD card, and you only have a single USB drive attached. But that's the problem with doing it that way, too many assumptions (UUID or PARTUUID is more precise).
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

ghostrider513
Posts: 35
Joined: Tue Mar 28, 2017 6:03 am

Re: How to save data to usb in Raspberry Pi

Thu Jun 28, 2018 3:30 am

Paeryn wrote:
Thu Jun 28, 2018 12:01 am
You've created the usbdrv directory in your home directory, have you actually mounted the usb drive there? If you are relying on the usb automounter then usually it gets mounted to /media/pi/name_of_disk

BTW, I think you need to prefix the address of the image with http:// otherwise the forum will think the image is local to the forum, hence why it isn't showing it.
Thanks for telling me about the link. I don't think I mounted it correctly and the tutorials I've found have been terrible to learn from. It is showing up under usbdrv / data so it isn't correctly mounted. I haven't been able to figure out how to mount it correctly and I don't know how to save the data to a file and how to retrieve that data. When I put my usb drive in my pc, nothing is showing up on the drive. The Pi says the file is there but my computer can't see it. I really could use help mounting the drive or, making the data saved to MySQL on my website. The thumbdrive is for manually pulling the data off and entering it by hand.

Honestly, I'm totally lost.

I appreciate your help with this. I'm not a coder or programmer. I am doing research and couldn't afford the scientific instruments for my research data collection. A friend suggested I try the RPi or Arduino. I have one of each. I don't know how to do this stuff though... but at least I'm trying. I'd rather be doing my research and experiments than trying to figure out programming. At 59 years old, that wasn't a direction I wanted to go. lol. I'm learning but I need to work on my research instead. All help is greatly appreciated. Thanks for your time and assistance.
Mike

Return to “Beginners”