**Can someone please help me? I've been struggling for days**

I have an arduino Host shield (see picture below). Can someone share the code or tell me how I can use it to save data on the USB flash drive. I want to be able to directly save data on it without using a computer.
I know I can save data on the computer, then use a USB flash drive to retrieve data from the computer. But this is not the approach I want to take. I want to be to save data directly to the USB flash using the arduino host shield.
USB Host Shield

Looks like you have to put your USB Host Shield 2 on an Arduino MEGA 2560 to read/write USB thumb drives. The library example needs more RAM than the UNO has.

I recommend you get an SD Card module for your Arduino. That will give you mass storage without the USB Host Shield and the SD Card can be put in a USB card reader for reading on a PC.

1 Like

I've no experience of your shield, but maybe this will help you:

The author says:

This is a preview of UsbFat, an Arduino library for USB flash drives
and USB hard drives.

The library has been tested with Arduino Uno, Mega, and Due boards using
the Circuits@Home USB Host Shield 2.0. Teensy 3.1 will be supported using
the USB Host Shield for Arduino Pro Mini.

1 Like

Hi Mr. Johnwasser,

Thank you for responding. I have an arduino. Do you think it will work? Also, can your refer me to or share with me an example that I can use? And see how it works.

What model Arduino?

I meant Arduino Due. Sorry.
Also, Do you have a sample that I can try?

If you have an Arduino Due you don't need a USB Host Shield.

Read this old post: Usb Host (Due) support for mass storage devices (thumbdrives)

Thank you Mr. Johnwasswer. I have read the post and I installed USB host library as suggested by someone (shown below). I found only 3 examples from that library as shown below. The library does not have an example on how to save data on USB flash drive. The library only has examples on how to control keyboard, a mouse, and ADKTerminal.

I am really stuck. I don't know what to do from here. I apologize for my ignorance, one way for me to learn is by asking questions. I'm a baby when it comes to arduino programming. I am still learning.

Usb Host installed
image

Did you not get as far as Reply #2?

The main goal of the project is to collect data from turbine flow meter and save these data directly on the flash drive. The code I have below is using EEPROM.h library and there is no EEPROM support on Arduino Due according to this forum (EEPROM) . So I guess Arduino Due shouldn't be an option for trying to save my data on the USB drive. Do you have another suggestions by any chance? A different route maybe?

Code:
#include <GravityTDS.h>
#include <EEPROM.h>

#define TdsSensorPin1 A3
GravityTDS gravityTds1;
/#define TdsSensorPin2 A4
GravityTDS gravityTds2;
/

float temperature1 = 25,tdsValue1 = 0;
/float temperature2 = 25,tdsValue2 = 0;/

void setup()
{
Serial.begin(9600);
gravityTds1.setPin(TdsSensorPin1);
gravityTds1.setAref(5.0); //reference voltage on ADC, default 5.0V on Arduino UNO
gravityTds1.setAdcRange(1024); //1024 for 10bit ADC;4096 for 12bit ADC
gravityTds1.begin(); //initialization

/*gravityTds2.setPin(TdsSensorPin2);
gravityTds2.setAref(5.0);  //reference voltage on ADC, default 5.0V on Arduino UNO
gravityTds2.setAdcRange(1024);  //1024 for 10bit ADC;4096 for 12bit ADC
gravityTds2.begin();  //initialization*/

}

void loop()
{
//temperature = readTemperature(); //add your temperature sensor and read it
gravityTds1.setTemperature(temperature1); // set the temperature and execute temperature compensation
gravityTds1.update(); //sample and calculate
tdsValue1 = gravityTds1.getTdsValue(); // then get the value
/gravityTds2.setTemperature(temperature2); // set the temperature and execute temperature compensation
gravityTds2.update(); //sample and calculate
tdsValue2 = gravityTds2.getTdsValue(); // then get the value
/
Serial.print(tdsValue1,0);
/Serial.print(" ");
Serial.print(tdsValue2,0);
/
Serial.println("ppm");
delay(1000);
}

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.