Hot answers tagged

5

The Arduino SD library, is based on Github: greiman/SdFat, by William Greiman. From SD Created File Attributes: The basic SD.h library doesn't set the attributes. You notice everything has the same creation date? The library doesn't have any way of knowing what the date is. However, you need to use a callback function. The following information is from ...


4

You cannot SD cards cannot be shared between masters in operation, and it is unsafe to disconnect the card from the camera with an electronic switch when the camera is not expecting that. Nor is an ordinary Arduino fast enough to passively snoop the data being written to the card by the camera (while a card will let an Arduino write to it quite slowly, any ...


3

Pin 10 is special. It's the hardware chip select pin for SPI. It is integral to the SPI peripheral in the chip. That pin must be an OUTPUT for SPI to operate as master, or INPUT for it to operate as a slave. It's a stupid design decision by Atmel if you ask me, but there you go. So basically trying to use SPI at the same time as PWM on pin 10 is "...


3

You only need to open the file with FILE_WRITE and use file.seek(EOF) to go to de end of the file. After that you can write whatever you want that will be appended to the end of the file. File outputFile = SD.open(LOG_FILE, FILE_WRITE); outputFile.seek(EOF); outputFile.println("Appended to the EOF");


2

Quite simply FAT16 only supports 1 date, normally Modified Date. FAT32 has (limited) support for 3 dates (but AFAIK there is no Arduino library which supports FAT32). Even then not all OS even support Creation Date. Windows has 2 different interpretations depending on application, Linux natively only supports Change Date, although extensions provide support ...


2

So my question: is 20 ms enough to read like 50 pages of 512 bytes from an SD card which are located on different (but known) file offsets within a 2+ MB file? Let us do the numbers: 50 * 512 = 25 Kbyte in 20 ms is 1.25 Mbyte/s. As the max speed for SPI is 1 Mbyte/s (on Arduino AVR, 16 MHz) we do not have to go any further. The answer is: No. Cheers!


2

Your way of sharing the bits between the three values seems a bit confusing. Your code for saving the bits is correct in the meaning of that you save all relevant information. Your bytes are shared in this way (H means high portion of value, L is the low portion of value): ____HX_____ b1: | 0000 0000 | _LX_ ___HY___ b2: | 00 | 000000 | __HZ__ ...


2

You need to get an SdFile object for your file then use the SdFile::dirEntry method to get the directory entry for the file. The directory entry (struct directoryEntry) has the timestamps.


2

USB Host Shield uses pin 10 as CS. Use pin 4 as CS for the SD module. To set CS pin to SD library, set it as parameter SD.begin: SD.begin(CS_PIN); Note: Level conversion IC on some cheap SD modules disturb the SPI bus and the module can't be used with other SPI devices.


2

Read the values into an array big enough to store them Write the array with the write(const uint8_t *buffer, size_t size) method. Each write then gives you a block of binary data (512 values, 1024 bytes if they're 16-bit integers) written to the SD card. What you do with it then is up to you. Note: an Arduino UNO only has 2kB of memory. If you have 512 ...


2

Unfortunately the DFPlayer cant write that data to the SD card. The Arduino has some non volatile memory of its own built in though. Theres 1K of EEPROM for the UNO. Notes on how to use it here: https://www.arduino.cc/en/Reference/EEPROM If you can get what you need to done in 1K and its not important to your project that you be able to unplug the SD card ...


2

If you look in this library, you see: File SDClass::open(const char *filepath, uint8_t mode) { ... if ((mode & (O_APPEND | O_WRITE)) == (O_APPEND | O_WRITE)) { So you can use all these mode combinations (e.g. O_CREATE, O_APPEND, O_WRITE).


2

Not with an ATTiny85, and not with so few pins, no. However, all is not lost. The ATTint85 has 512 bytes of EEPROM inside it where you can store your login details. All you need is some way of telling setting that data in your sketch from the PC - and the simplest way is probably through a USB serial connection. If you don't have a serial connection ...


2

Is this a sensible solution to the problem? No, unfortunately not. The size of the buffer is limited by the available RAM on your chip. Jumping between multiple buffers or cores will not change that, since it is a hardware limitation. I am hesitant to implement anything that simply relies on an improvement in SD write speed, as I will likely need to ...


1

f.read((uint8_t *)infoheader, sizeof(infoheader)); should be f.read((uint8_t *)infoheader, sizeof(biheader)); the size of the variable (pointer) is only 2. you want to read 40 bytes of biheader struct and f.read((uint8_t *)data, sizeof(uint8_t)*size) should be f.read((uint8_t *)data, sizeof(pixel)*size) The next problem is %d and %x in sprintf. %d ...


1

In the FAT filesystem the timestamps and other attributes are stored in the directory, not in the file. So you need to read the "file" that is the directory that contains the file you're interested in. That "file" contains entries in a pre-defined structure. Reading each block of data using that structure gives you the information for each file in turn. ...


1

You can use the adapter because: the adapter uses an AMS1117 to generate 3.3V to supply the SD card and the level shifter the level shifter is a 74LVC125 which uses 3.3V and works with 3.3V (and accepts up to 5V as input level) The adapter works for 3.3V and 5V systems as long as 5V power is available.


1

Catalex Micro SD Card Adapter has built-in level converter in a form of 74LVC125A 3-state buffer. This buffer chip needs 1.65 to 3.6V voltage supply. The +5V from your Arduino is lowered to 3.3V by the adapter (as seen in the schematics, just change 74ABT125 to 74LVC125A). Link to 74LVC125A Link to Catalex Adapter schematic To operate the adapter you would ...


1

The SD card is a 3.3 V device. The 5 V module with SD card adapter steps down the voltage for powering the card and has logic level conversion for card's SPI pins. If you want to connect SD card to a 3.3 V board it is better to use a simple breakout board without power and signal conversion. I do not recommend you to connect a 5 V SPI device to MKR SPI ...


1

There is a mismatch in the code. The Arduino loop function assumes that readPMSdata needs to be called just once for valid data but the function readPMSdata itself assumes that it will be called over and over again until a enough bytes are received and are valid. The solution is to let the Arduino loop call readPMSdata over and over again, until it has ...


1

The millis() function is based on a counter which is incremented by the Timer 0 overflow interrupt. Since you reconfigured that timer to never overflow, that counter is not incremented anymore. If you want to configure an Arduino timer for your own purposes, you have to either: use any timer other than Timer 0, or loose the Arduino standard timekeeping ...


1

As a temporary workaround I have come to the following procedure: I inserted a function that writes a certain amount of bytes into a dummy file, closes it and finally deletes it, all during setup(). This does indeed seem to cure the freezes if (in my scenario) I write at least 6 blocks (512 bytes each, i.e. total 3072 Bytes). Remarkably there were always ...


1

The TMRpcm library is non-blocking. That means, when you start playing it keeps playing in the background. If you put the play function in a loop it will just keep restarting what you are playing over and over again and you won't get to hear anything. As Michel says, you can get it to loop automatically (tmrpcm.loop(1);), in which case you just leave it in ...


1

The library has a built in loop function: audio.loop(1); 0 or 1. Can be changed during playback for full control of looping. See WIKI page of the library. Btw, it is unclear if you mean by 'a loop' a while(true) loop or the void loop() function. Although it should not make a difference.


1

What you can do is: opening a file (to read) opening a new file (to write) since a line can be long (more than arduino's memory), it's best to read it character by character, thus: use a boolean to denote when to start removing a line (set to e.g. Remove = TRUE) For every character you read: If Remove is TRUE, don't write to the output file, otherwise ...


1

If you're not specifically trying to make the arduino itself do the decoding and playback, you can get something like the Mini DFPlayer which would let you do essentially what you're asking for and offloads the decoding and playback so your arduino can do something else while the audio is playing.


1

For people having similar problems with creating multiple files on an SD card, it may be a memory issue. You need to have a certain amount of unused dynamic memory (about 300 bytes of free space, in my experience) in order to write to an SD card - and more if you are writing multiple files. Following the instructions on this page may help.


1

There are several variations of the SD library - some support multiple files, others do not. Try calling .begin (and .end) on each write loop, and add in .flush - see below. If that works with your library then take the (.begin / .end) out of the loop and try again. #define FILENAME "myfile.txt" void writeToFile() { File f; // begin and end on ...


1

If RunFat is an instance of SdFile you can just cast it: SdFile& RunRoot = dynamic_cast<SdFile&>(RunFat); RunRoot and RunFat are now the exact same file in the exact same state (no need to open it or anything) but seen as an SdFile not a FatFile.


1

File.print() stops printing at a NULL character (ASCII 0) not a new line. You can stick as many new lines as you like in a string and it will print. Try this example void loop () { Serial.print ("Hello\nMultiline\nPrint\n"); Serial.print ("Hello\0Multiline\0Print\n"); } File.write() writes binary data to a file, it will write BUFLEN bytes, even if ...


Only top voted, non community-wiki answers of a minimum length are eligible