Page 1 of 1

### Can't get Thumb Drive to work, can I save data to my PC instead?

Posted: Mon Jul 02, 2018 1:54 am
I can't get my RPi 3B+ to see and mount my thumb drive. I've had enough. Can I just save the data from the SHT31-D directly to my PC? And how do I get the time and date to show up with the data?

I have Win 10. I need to save it as an Excel CSV file so I can upload it to my database on my website. Thanks

Here's my code so far. Feel free to add your code to make it work.

import smbus
import time

# Get I2C bus
bus = smbus.SMBus(1)

bus.write_i2c_block_data(0x44, 0x2C, [0x06])

time.sleep(0.5)

# Read data back from 0x00(00), 6 bytes
# Temp MSB, Temp LSB, Temp CRC, Humididty MSB, Humidity LSB, Humidity CRC

# Convert the data
temp = data[0] * 256 + data[1]
cTemp = -45 + (175 * temp / 65535.0)
fTemp = -49 + (315 * temp / 65535.0)
humidity = 100 * (data[3] * 256 + data[4]) / 65535.0

# Output data to screen
print "Temperature in Celsius is : %.2f C" %cTemp
print "Temperature in Fahrenheit is : %.2f F" %fTemp
print "Relative Humidity is : %.2f %%RH" %humidity

import smbus
import time
bus = smbus.SMBus(1)
while True:
bus.write_i2c_block_data(0x44, 0x2C, [0x06])
time.sleep(0.5)
temp = shtdata[0] * 256 + shtdata[1]
cTemp = -45 + (175 * temp / 65535.0)
humidity = 100 * (shtdata[3] * 256 + shtdata[4]) / 65535.0
print "Temperature in Farenheit is : %.2f F" %fTemp
print "Temperature in Celsius is : %.2f C" %cTemp
print "Relative Humidity is : %.2f %%RH" %humidity
time.sleep(9.5)

### Re: Can't get Thumb Drive to work, can I save data to my PC instead?

Posted: Mon Jul 02, 2018 2:03 am
Have you installed usbmount? sudo apt-get install usbmount

Next question: what file system is your thumb driver formatted in?

Cheers.

### Re: Can't get Thumb Drive to work, can I save data to my PC instead?

Posted: Mon Jul 02, 2018 5:30 am
I am probably wrong, but I don't see you writing your data to a file. (In languages I'm familiar with on *nix, "print" goes to stdout, which is normally the terminal session you're running the process from.) Are you redirecting stdout to a file? Or--possibly something I missed--are you opening a file to write the data to?

As for the question in the thread topic...the answer is trivially, Yes. *How* you go about doing so has any number of possible answers.

### Re: Can't get Thumb Drive to work, can I save data to my PC instead?

Posted: Mon Jul 02, 2018 1:13 pm
The Traveler wrote:
Mon Jul 02, 2018 2:03 am
Have you installed usbmount? sudo apt-get install usbmount

Next question: what file system is your thumb driver formatted in?

Cheers.
I wiped the drive just now, reformatted in FAT32 (before was exFAT). Now to figure out if it's working.
Thank you. Stay tuned. As soon as I figure out if it's working or not, I'll comment again.
Mike

### Re: Can't get Thumb Drive to work, can I save data to my PC instead?

Posted: Mon Jul 02, 2018 1:20 pm
W. H. Heydt wrote:
Mon Jul 02, 2018 5:30 am
I am probably wrong, but I don't see you writing your data to a file. (In languages I'm familiar with on *nix, "print" goes to stdout, which is normally the terminal session you're running the process from.) Are you redirecting stdout to a file? Or--possibly something I missed--are you opening a file to write the data to?

As for the question in the thread topic...the answer is trivially, Yes. *How* you go about doing so has any number of possible answers.
To be honest, I haven't a clue, I know the data shows up on Putty. That's it. Beyond that I haven't been able to get it to save to upload to a mysql dbase. I'm a non-coder. I am doing home based research and can't afford the expensive instruments the universities have access to so I thought I'd give this a try. Unfortunately, I'm no programmer. Though, I did get the SHT31-D to work on an Arduino UNO and RPI. Months to learn to do that instead of my research though. It PRINTS to PUTTY. That's it. I don't know how to get it to print to anything else

### Re: Can't get Thumb Drive to work, can I save data to my PC instead?

Posted: Mon Jul 02, 2018 1:22 pm
I wiped the drive just now, reformatted in FAT32 (before was exFAT). Now to figure out if it's working.
Yep, it won't mount an exFAT so FAT16 or FAT32 work fine.

If you look at this file: /etc/usbmount/usbmount.conf it will give you some particulars on what file formats and mount locations Raspian uses. If everything else is installed and configured, your USB device should be mounted on /media/usb0-7 (first available mount point, usually usb0).

Cheers.

### Re: Can't get Thumb Drive to work, can I save data to my PC instead?

Posted: Mon Jul 02, 2018 7:49 pm
The Traveler wrote:
Mon Jul 02, 2018 1:22 pm
I wiped the drive just now, reformatted in FAT32 (before was exFAT). Now to figure out if it's working.
Yep, it won't mount an exFAT so FAT16 or FAT32 work fine.

If you look at this file: /etc/usbmount/usbmount.conf it will give you some particulars on what file formats and mount locations Raspian uses. If everything else is installed and configured, your USB device should be mounted on /media/usb0-7 (first available mount point, usually usb0).

Cheers.
I get a bash error.

pi@raspberrypi:~ \$ /etc/usbmount/usbmount.conf
bash: /etc/usbmount/usbmount.conf: No such file or directory

But, I can create a file on the drive. It installed automatically and opened a window for it. It never did that before.

### Re: Can't get Thumb Drive to work, can I save data to my PC instead?

Posted: Mon Jul 02, 2018 7:57 pm
ghostrider513 wrote: I get a bash error.

pi@raspberrypi:~ \$ /etc/usbmount/usbmount.conf
bash: /etc/usbmount/usbmount.conf: No such file or directory
That's not a program, it's a configuration file. Use an editor or text viewer to open it

### Re: Can't get Thumb Drive to work, can I save data to my PC instead?

Posted: Mon Jul 02, 2018 8:00 pm
But, I can create a file on the drive. It installed automatically and opened a window for it. It never did that before.
Ok then, it's working as it should.

### Re: Can't get Thumb Drive to work, can I save data to my PC instead?

Posted: Mon Jul 02, 2018 8:05 pm
DirkS wrote:
Mon Jul 02, 2018 7:57 pm
ghostrider513 wrote: I get a bash error.

pi@raspberrypi:~ \$ /etc/usbmount/usbmount.conf
bash: /etc/usbmount/usbmount.conf: No such file or directory
That's not a program, it's a configuration file. Use an editor or text viewer to open it
It's not there. But I can see and access my drive

### Re: Can't get Thumb Drive to work, can I save data to my PC instead?

Posted: Mon Jul 02, 2018 8:12 pm
The Traveler wrote:
Mon Jul 02, 2018 8:00 pm
But, I can create a file on the drive. It installed automatically and opened a window for it. It never did that before.
Ok then, it's working as it should.
I mounted the drive and now can see the config file:

Configuration file for the usbmount package, which mounts removable
# storage devices when they are plugged in and unmounts them when they
# are removed.

# Change to zero to disable usbmount
ENABLED=1

# Mountpoints: These directories are eligible as mointpoints for
# removable storage devices. A newly plugged in device is mounted on
# the first directory in this list that exists and on which nothing is
# mounted yet.
MOUNTPOINTS="/media/usb0 /media/usb1 /media/usb2 /media/usb3
/media/usb4 /media/usb5 /media/usb6 /media/usb7"

# Filesystem types: removable storage devices are only mounted if they
# contain a filesystem type which is in this list.
FILESYSTEMS="vfat ext2 ext3 ext4 hfsplus"

#############################################################################
# WARNING! #
# #
# The "sync" option may not be a good choice to use with flash drives, as #
# it forces a greater amount of writing operating on the drive. This makes #
# the writing speed considerably lower and also leads to a faster wear out #
# of the disk. #
# #
# If you omit it, don't forget to use the command "sync" to synchronize the #
# data on your disk before removing the drive or you may experience data #
# loss. #
# #
# It is highly recommended that you use the pumount command (as a regular #
# user) before unplugging the device. It makes calling the "sync" command #
# and mounting with the sync option unnecessary---this is similar to other #
# operating system's "safely disconnect the device" option. #
#############################################################################
# Mount options: Options passed to the mount command with the -o flag.
# See the warning above regarding removing "sync" from the options.
MOUNTOPTIONS="sync,noexec,nodev,noatime,nodiratime"

# Filesystem type specific mount options: This variable contains a space
# separated list of strings, each which the form "-fstype=TYPE,OPTIONS".
#
# If a filesystem with a type listed here is mounted, the corresponding
# options are appended to those specificed in the MOUNTOPTIONS variable.
#
# is mounted.
FS_MOUNTOPTIONS=""

# If set to "yes", more information will be logged via the syslog
# facility.

I think it's on media/usb01

How would I check that?

### Re: Can't get Thumb Drive to work, can I save data to my PC instead?

Posted: Mon Jul 02, 2018 8:16 pm
W. H. Heydt wrote:
Mon Jul 02, 2018 5:30 am
I am probably wrong, but I don't see you writing your data to a file. (In languages I'm familiar with on *nix, "print" goes to stdout, which is normally the terminal session you're running the process from.) Are you redirecting stdout to a file? Or--possibly something I missed--are you opening a file to write the data to?

As for the question in the thread topic...the answer is trivially, Yes. *How* you go about doing so has any number of possible answers.
Just has PRINT for the terminal window - I don't know how to get the sensor to save the data to a file - preferably csv or doc file for a mysql

### Re: Can't get Thumb Drive to work, can I save data to my PC instead?

Posted: Mon Jul 02, 2018 9:27 pm
ghostrider513 wrote:
Mon Jul 02, 2018 8:16 pm
Just has PRINT for the terminal window - I don't know how to get the sensor to save the data to a file - preferably csv or doc file for a mysql
Time to start learning Python programming, read "Automate the Boring Stuff with Python" and/or How to Think Like a Computer Scientist: Learning with Python 3

### Re: Can't get Thumb Drive to work, can I save data to my PC instead?

Posted: Mon Jul 02, 2018 10:01 pm
Ok, you really don't have to do anything with the file. I mentioned it because it had a list of filesystems it will automatically mount so you could format your thumbdrive properly by choosing one from the list.

Code: Select all

``FILESYSTEMS="vfat ext2 ext3 ext4 hfsplus"``
But as you've got it working, no need to mess with it.

Cheers.

### Re: Can't get Thumb Drive to work, can I save data to my PC instead?

Posted: Tue Jul 03, 2018 1:18 am
ghostrider513 wrote:
Mon Jul 02, 2018 8:16 pm
W. H. Heydt wrote:
Mon Jul 02, 2018 5:30 am
I am probably wrong, but I don't see you writing your data to a file. (In languages I'm familiar with on *nix, "print" goes to stdout, which is normally the terminal session you're running the process from.) Are you redirecting stdout to a file? Or--possibly something I missed--are you opening a file to write the data to?

As for the question in the thread topic...the answer is trivially, Yes. *How* you go about doing so has any number of possible answers.
Just has PRINT for the terminal window - I don't know how to get the sensor to save the data to a file - preferably csv or doc file for a mysql
CSV you can do yourself. Get the values and output them with literal commas separating them. .doc (or .docx) format...don't go there. Not because it's proprietary to Microsoft, but because it is poorly documented, at best. You can check your CSV formatting using the print statements, as that comes back to your PuTTY session (i.e. stdout). You need to find a way to open a file and write to it in whatever language you are going to use.