How to add USB pen drive data logging

If you want to add USB pen drive data logging to your system the Vinculum VDIP1 USB host controller works really well.

There are a couple of places you can get the board, farnell stock them for £13.94.

There are some good guides on using the board with an Arduino. I found these two most useful. I recommend reading these to get an idea of how it all works. I've added a couple of things to increase the functionality and get rid of write errors, which are documented below.

Guide 1 - Writing data to Usb Memory Stick – by Nick on the Arduino playground.

Guide 2 – Usb Storage and Arduino – by Sven Steinbauer

Additions

Wait for 'ok' response

The Vinculum board is controlled using DOS commands. Every time you send a command, if the command is executed successfully, the board sends a “D:\> ” response that indicates it's ready for the next command. Commands sent faster than the board can execute them, and not waiting for the “D:\> ”response resulted in stored data errors and sometimes a crash.

To solve this, the Arduino sketch listens for a response from the board after it sends each command, if it receives “D:\> ” then it can send the next command. If it receives “No disk” it stops trying to write to a non existent disk and waits until a disk is inserted and the start write button is pressed.

Start/stop write button and led indicator

Just a simple start/stop write button. To start writing hold the button down for 2 seconds. The LED illuminates to indicate writing. To stop writing, hold it down again for 2s, and the led turns off. If the Arduino receives a 'no disk' response. The LED is automatically turned off.

Hardware

Vinculum VDIP1 wiring diagram:

Start/stop push button and LED indicator circuit diagram:

Layout suggestions

A piece of stripboard to mount the Vinculum VDIP1.

Start/stop push button and LED indicator

Installation example in the home energy monitor main unit

Arduino software:

The Arduino sketch works with the board independently of any other energy monitor hardware and code. It writes the values set in the variable declaration, to the board as an example.

  1. Download the Data logger Arduino sketch
  2. Compile and upload the Arduino sketch. For a guide on compiling and uploading the sketch, have a look here.
  3. Check your Arduino serial monitor for write status. Once you have pressed the button you should see the following output if it's working correctly:

Started
O D:\>
W D:\>
C D:\>
O D:\>
W D:\>
C D:\> 

If you see the correct responses (as above), press the button again to stop writing. You should see "stopped" on the serial monitor. Check the USB pen to verify the data is there.

Dawn's picture

Re: USB Data Logger

Just changed the amount of spaces from 7 to 4 in Datalogger before program could work correctly.

 

Guest's picture

Re: USB Data Logger

could you estimate wrining data transfer speed?

Guest's picture

Re: USB Data Logger

so if i can understand correctly, than you should use the same arduino used in the measurement board with the same supply. however the two codes have to be programmed to work together.
THanks a lot

TrystanLea's picture

Re: USB Data Logger

 are you refering to joining the code of mains ac v3 with usb datalogging? if so and I have understood your question then yes

Guest's picture

Re: USB Data Logger

hello,
how fast are you able to write to the usb? I want to use it in another project with quite big data transfer.
have you experienced the problem with the buffer loosing data cause of the bridge hack in cts and rts lines to control flow ??
do you know how big this buffer is?

thanks a lot !!

TrystanLea's picture

Re: USB Data Logger

Im not sure, it was a while back when I did this. It wasnt super fast if I remember. Roughly about 1-10 times a second rather than hundreds of times. The code I wrote checks for an ready reply from the VDIP to make sure data is not lost and this does take more time, Although stability is very much affected without it. It would be good to do a proper analysis of performance wouldnt it!

Paul's picture

Re: USB Data Logger

Trystan,

I am a little confused on how to wire the Vinculum VDIP1 to the Ardruino and energy monitor. Isn't the energy monitor already using the 5v in the Ardruino? Are you using two Arduinos?

Thanks,

Paul.

TrystanLea's picture

Re: USB Data Logger

 Hello Paul, I just broke out the 5V wire into two ends one for the VDIP and the other for the energy monitor, using just the one arduino.

 

Guest's picture

Re: USB Data Logger

hello, thanks a lot for this information!!

I have build your power monitor 3.0, would it be possible for you to upload the sketch of power monitoring with USB storage all the code working together?

I have my arduino connected with the ethernet shield to internet to upload values to mysql database each 10 seconds, but sometimes it crashes and it goes offline, i loose all the data for that time. I would like to save that data to the usb so that later i can update the mysql database with the missing data.

thanks a lot !!!

TrystanLea's picture

Re: USB Data Logger

Hey, Can I challenge you to have a go at bringing both pieces of code together? They should fit together without too much trouble. If you have a go and it doesnt work, send me your code and I will have a look.