I am working on a project where I need to log data, but I was wondering if it is possible to log that data to a thumb drive? I know that I can log data to an SD card, but I thought a thumb drive would be more accessible to users who wish to obtain the data. And if it is possible to log to a thumb drive, could it be done in CSV format? The data is just sensor data.
2 Answers
In principle you can log to a thumb drive any data you want, binary and text (thus also CSV).
However, the Arduino Uno does not support connecting a USB stick directly. If you want to connect a USB stick, you need a so called USB Host shield (for Arduino).
More information can be read on the Arduino site at this page:
https://docs.arduino.cc/retired/shields/arduino-usb-host-shield
[Updated]
As an alternative to a Uno host shield, changing to a different Arduino MCU may also assist. USB host capabilty is needed for communicating with thumb drives.
Some Arduino models have a native USB port (e.g., Arduino Due, Arduino Leonardo, Arduino Micro, Arduino Nano 33 IOT, Arduino Zero, Arduino MKR Zero, Arduino MKR1000 ... ) which will work as a USB client device role.
A smaller set of MCU can act as either a USB client or host (e.g., Arduino Due, Arduino Portenta, ...). There is a USBHost library for Arduino Due listed in the Arduino Reference. Documentation for Arduino Portenta in USB host mode is here.
Here is a discussion (and reference to an alternative library) regarding using a Due to write files to a thumb drive.
Of course an adapter cable or a thumb drive with a physical connector matching the native USB port on the selected MCU is required. Both are commonly available.
See also Can the Arduino interface with USB devices without the USB host shield?
-
For the Micro and Leonardo, the datasheet of the ATmega32U4 says its USB controller “Supports full-speed and low-speed Device role”. I see no mention of support for the host role. Are you sure they can act as a host? Commented Jul 2, 2022 at 22:28
-
Hi Edgar, no my experience has been with the Due, and so I relied on the linked discussion for the list of other MCU with native USB. I’ll edit my answer. Thanks. Do you know of a list of MCU with host capable native USB?– RowanPCommented Jul 3, 2022 at 0:24
-
No, sorry. My experience with USB-capable Arduinos is limited to playing with the Keyboard library on a Micro. I just learned that the Due is host-capable, thanks to your answer. Commented Jul 3, 2022 at 8:00
-