![]() I give some examples in the following sections. You can use the I2C SD-Card Module with the Arduino Wire library, but it works best with my TinyI2C library see Tiny I2C Routines for all AVR Microcontrollers. There is no need to explicitly close the file when you're finished it is closed automatically after the last transmission. ![]() The Size command can be called before reading a file if you don't know its size. Writes data to the file, overwriting if necessary.Īppends data to the end of the file, if it already exists. To make it easy to remember them I made each command a single letter representing its action: Command CommandsĮach I2C transaction is prefixed by a command byte, to indicate what function is being performed. The I2C address is 0x55, but if this clashes with anything else you're using you can easily change it in the program. It's a useful module to have lying around, so I plan to design a PCB for it if I do I'll publish it here. To use it just connect it to your 3.3V or 5V microcontroller via the following pins: The whole circuit fitted on a mini breadboard. You could connect this to a spare I/O line defined with INPUT_PULLUP to allow you to detect when a card is present. The SD card module includes a CD pin which is connected to GND when a card is not inserted. Alternatively you could use two separate LEDs. I connected a bicolour red/green LED to two spare I/O lines, PB2 and PB3, to allow me to show errors (red) and when the SD card is being read or written (green). I mounted the chip on a SOIC-14 breakout board to make it breadboard friendly. ![]() I'm pretty sure an ATtiny1624 should work, but I haven't tried it. I also tried an ATtiny1604, but that didn't work, presumably because the 1 Kbytes of RAM doesn't leave enough room for the stack. The SD library uses a lot of RAM so you need about 830 bytes, and the ATtiny804 or ATtiny814 aren't suitable as they only have 512 bytes. The circuitĬircuit of the I2C SD-Card Module, based on an ATtiny1614.įor the SD card interface I used the Adafruit MicroSD board as it's easy to use on a breadboard, and it includes a logic-level shifter so you can use it with 3.3V or 5V.įor the controller I used an ATtiny1614. I therefore switched to the 1‑series ATtiny1614 which provides 2 Kbytes. I initially thought of basing the circuit on the ATtiny841, like my earlier I2C GPS Module, but I underestimated the amount of RAM needed by the SD library, and the ATtiny814 only provides 512 bytes. The ideal solution seemed to be an SD module with an I2C interface, but despite much searching on the web I couldn't find one, so I decided to build one myself. I've frequently had a project where I wanted to write data to an SD card, or read from an SD card, but didn't have enough I/O lines available to wire up the SPI SD card interface, or else the SPI lines were already in use, or else the processor I was using didn't have enough RAM to run the SD library. It's based on an ATtiny1614 and a few other components, and it's compact enough to fit on a mini-breadboard.įor a PCB version of this project see I2C SD-Card Module PCB. Also I'm sorry if I'm omitting some important info.This is an SD-card module that allows you to write to and read from files on an SD card using a two-wire I2C interface:Īn I2C SD-Card Module that allows you to write to and read from SD cards via I2C. I'm not expecting a quick fix, just would like to learn more and systematically test the system to figure out what I'm doing wrong or what component might be faulty. In particular the Quick Start Example sketch from the SDfat library gives an error that might be of help? It has a txt file in it that was written by the uno.Īll example sketches from libraries that I tried fail to initialise the sd card. The SD card itself is probably good as I use it on a previous prototype for the same purpose using an Uno and keyes datalogging shield and works well. I have checked with a multimeter and the wiring seems good. I also wasn't happy with my wiring on the breadboard as I think my breadboard/leads isn't very good and the connections aren't very "positive" so I've manually made cables as short as possible to connect the SD card module to the due pins as short as possible and with good connections. I also used a number of libraries such as SD.h, SDfat.h, etc CS/SS I'm using pin 10 but I've tried many others such as 4, 6, 7, 53. I'm using 3.3V for VCC and Ground for Ground. I'm using the SPI pins in the middle of the board for MISO, MOSI, and SCK. Ok so, my ultimate objective is to be able to use the SD card as a datalogger, but so far I'm yet to be able to initialise the SD card. Can't seem to find another way forward other than asking for help. I've been battling with this problem for 2 days straight and tried many many things that I found in this forum and others from people that seem to have similar problems.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |