Picaxe 08M with 2Gig hard drive


New Member
I posted a thread late last year on the uDrive from 4dsystems. That allowed a picaxe to read and write data from a micro SD card, but it wasn't easy to get the data off the card. 4dsystesm have updated their software (with a simple upgrade to an existing udrive) so it can now read FAT files. This now means files can be transferred to and from a PC easily. You could use a $5 USB to sd card adaptor. Or put the card in a camera and read the files over.

I wrote some code in vb.net as a demonstration http://www.instructables.com/id/Simple-mass-storage-for-your-microcontroller-proje/

Surprisingly, the picaxe code ended up far simpler than the vb.net code! I think credit is due to RevEd for the simple Serin and Serout code structure.

This code demonstrates writing a file, reading a file and erasing a file. With a few additions (shown in the vb.net code) you can read and write huge files, and can append data to existing files.

I believe this may open up some amazing possibilities for the picaxe. Reading animatronics files, large text files and putting them on a display, even ? wav files. For writing, datalogging would be the obvious application (there was a thread recently where someone wanted to store a million data points. Well, this could store a billion!).

' udrive (4dsystems) file demonstration for micro SD card with FAT16 files for easy transfer to and from a PC
' code below uses 152 bytes (less if you want 'write' but not 'read' etc)
' pin 4 to the reset pin of the udrive (leg 1)
' ground to the ground of the udrive (leg 2)
' pin 2 to receive data on the udrive (leg 3)
' pin 3 to transmit data on the udrive (leg 4)
' 5V to 5V on the udrive (leg 5)

main:low 4			' 4 is reset pin
	high 2		' 2 transmits to the udrive (receive on pin 3) high is resting, low is data (T mode)
	pause 100		' startup delay for reset
	high 4		' 4 is reset pin - enable =high
	pause 1000		' short pause after resetting should be at least 500ms
	serout 2,T2400,("U") ' initialise
	serin 3,T2400,b0	' should be a 06 - if no reply then hangs
	' if b0<>6 then goto main ' if a reply but not a 06 then reset - probably not needed
	'gosub erasefile
	gosub writefile
	gosub readfile
readfile: ' read file 10char.txt which has 10 characters
	serout 2,T2400,("@a",0,"10char.txt",0) ' packet size 0 ie send the entire file at once. Bigger files are possible in pieces
	serin 3,T2400,b0,b1,b2,b3 ' size of data file (we know it is 10 for this file)
	serout 2,T2400,(6) ' acknowledge got the file size
	serin 3,T2400,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10 ' get 10 bytes, plus the last byte b10 should be 06
	' perhaps add error checking here if b10 does not equal 6
	' debug
writefile: ' create a file with ABCDEFGHIJ in it. 10 bytes long	
	' this is a very simple demonstration. More advanced code can write files of indefinite length
	' and can append data to the end of an existing file. See the udrive documentation for more details.
	serout 2,T2400,("@t",0,"10char.txt",0,0,0,0,10)
	' @t is write, 0 is packetsize, filename (ends in zero), 4 filesize bytes
	serin 3,T2400,b10 ' should be a 6 to acknowledge
	serout 2,T2400,("ABCDEFGHIJ") ' send the data
	serin 3,T2400,b10 ' should be a 6
	' debug
erasefile:	' erase a filename from the drive
	serout 2,T2400,("@e","10char.txt",0)
	serin 3,T2400,b10 ' should be a 6 to acknowledge
	' debug
dirfile: ' this may be difficult on a small picaxe as the udrive dumps out all the file listing in one go


Last edited:


Senior Member
Good going Dr!

Serial to large data stores was never a real problem as far as I could tell - Vdrive2 has always worked with serial as does uAlfat and now UDrive.

The reason I moved from VDrive2 to uAlfat was that I needed comms other than serial as hser was already being used for another device in the project.

Could never get VDrive2 to work with PICAXE on SPI (and as far as I am aware it still doesn't - apart from some very basic bit bang operations).

uAlfat works with serial, i2c and SPI and does it with short AND long File name support - all fully licensed from Microsoft.

It seems that FAT is not very simple to achieve and has been the main problem area for this class of device.

So we now have 2 devices with large storage proven for use PICAXE with serial comms (VDrive2 and uDrive - both limited to 2Gb?) and 1, (uAlfat) with serial, SPI and i2c to as large a device as is supported by Fat32.
Last edited:


Senior Member
Many thanks for helping to provide a low cost means of storing large amounts of data. A really useful service to the PICAXE community! I notice that you are communicating at a conservative 2400bps and wondered if you had any thoughts about the potential to write at higher speeds, maybe in block mode using the X2’s large scratchpad as a buffer?


New Member
I'm sure it can go higher with a picaxe. The specs say 115k baud, and I've had it working fine at 38k baud via vb.net to a PC. I've not used the x2 chips yet but I think there might even be scope for moving in blocks of program data.