Hot answers tagged

3

You can't. There is no "software" reset. When you upload new code a hardware reset is triggered by the DTR pin of the USB interface chip. Instead I would suggest maintaining a "data version number" on the SD card. Read it on startup and, if it differs from the expected version number (which you update in your code manually) it creates the ...


3

It is quite likely you're out of memory. To know, really you need to keep track of the stack pointer and heap structure. There's enough going on in your code, that I'm not reasonably going to be able to set up an identical scenario to prove it. Display Library The greatest use of SRAM in your project comes from the Adafruit SSD1306 library. It's allocating ...


3

You can write the file in chunks. As suggested by ocrdu in a comment, writing line by line is a good strategy. In order to keep the complexity of the code manageable, I would put the logic of deciding the color of a pixel in its own function, and use another function for managing writing the bitmap. For example: struct Pixel { uint8_t r, g, b; }; // ...


2

#include <SPI.h> #include <SD.h> File file; int const pinCS = 2; void setup() { SD.begin(pinCS); file = SD.open("Test.txt", FILE_WRITE); file.println("anything"); file.close();} ...


2

For anyone who has a similar issue with the SPI Bus, SdFat library has a Software SPI option built in (example here). You need to modify your SdFat/SdFatConfig.h file, but that is minimal. Once you have the microSD card module on a separate bus, it will not corrupt the main SPI Bus. Switching the SD Card module to it's own bus rectified the issue. Keep in ...


2

So, sorry for late response, i figured it out. Because it took lots of time for me and it might be a prevalent issue, i think it worth to contribute my experience for further similar issues. As mentioned buffering can do the job, here are some constraints that should be satisfied to have right buffering mechanism; Writing to SD card SHOULD NOT be handled in ...


2

Despite the "the library example must be correct, It's work for other people before you", I'm not sure a lot of people make it works. I've seen that even when the mcp2551 don't receive anything on can bus, the SPI bus is saturated by the mcp2551. The solution was to use a simplest library make for 8MHz cristal chip. Modify it to works with standard ...


2

recvRetCommandFinished err means something is wrong with the serial communication between the Arduino and the Nextion display; it is what recvRetCommandFinished() prints when there is an error. Check if you are using the right pins (TX1 and RX1 for Serial1) for the serial connection to the display, the actual connections you made (RX1 to TX, TX1 to RX), the ...


2

You should not need to save the position, the file knows where you last read from. You'd only need to manually save such information if you close the file and re-open it again, which unless you have a good reason is actually a very wasteful operation. If you really do need to you can use the .position() and .seek() functions: Save the location: uint32_t pos =...


2

I see three problems with your code: It doesn't make much sense to begin the SD card again and again in loop(). Please move that part to setup() or somewhere, where it isn't called on every loop iteration. You shouldn't call tmrpcm.play() in every loop() iteration. It doesn't wait for the song to be finished. It just starts the playing (which is controlled ...


1

Solved, I changed the method a little. In a loop, I read a portion of the file and write it to the opened FTP remote file, then I close both at the end of the cycle // open FTP connection ftp.OpenConnection(); // open local file fileUpload = fopen("/sdcard/img.png", "r+"); // initialize file type ftp.InitFile("Type I"); // ...


1

File myFile = SD.open("test.txt", O_RDWR); if (myFile) { while (myFile.available()) { int i = 0; while (i < myFile.size()) { inputString = myFile.readStringUntil('\n'); //Serial.print(inputString); if (myFile.readStringUntil('\n')) { I have set a size for the loop, every time it returns "I want it to ...


1

timestamp in rtcReadTime() is a local variable. When you return from that function it ceases to exist - so what you have returned is nothing. You can't print nothing, so the Arduino crashes. You either need to make the timestamp variable static so that it's not lost when you leave the function, make it a global variable, which has a similar effect, or pass a ...


1

According to the schematic and pin notes, I don't think you can use GPIO4 as an ADC input (it can be used as a GPIO pin and technically it can be configured as an ADC pin), but it has a 47k pull-up resistor on it, making it not possible to be used as an ADC input. Depend on your hardware wiring skill, one alternative is to use an external ADC chip with i2c ...


1

Normally I'd write this a differently, but I've kept in relatively simple just to illustrate the basic idea: struct point { int x; int y; }; const point points_of_interest[] = { { 7, 11}, {23, 17}, {13, 19}, { 3, 5}, {17, 3}, }; void setup() { Serial.begin(9600); } void loop() { delay(4000); Serial.println("\n\n\n"); ...


1

I had accidentally commented out the SD initialization along with the serial initialization. After uncommenting it it works correctly


1

I think a "small" capacitor here is not going to do the job as you need to keep power stable until the write is completed. You need to determine: How much power am I using? How quickly can I detect a power outage? How much time do I need to keep power on the Arduino to complete the write operation(s) I want to complete. Then you will be in a ...


1

Feel free to take a look at my YouTube videos. They are not monetized so I'm not self-promoting. You can even skip the videos and checkout my GitHub repo with the Master and Slave sketches. https://youtu.be/A9oSX_dwJKQ https://youtu.be/PSUzhCtNRRQ https://github.com/linhartr22/Arduino_SPI_Master_Slave_Demo


1

BOUNCE 2 Basically, the mechanical part of buttons and switches vibrate slightly when closed or opened causing multiple undesired false states (similar to noise). This library filters out these undesired state changes. More about debouncing: John Errington's Experiments with an Arduino : Using digital inputs: Switch bounce and solutions to it Wikipedia ...


1

I wanted to write to 2 SD cards simultaniously with one Arduino Mega. Used all the relevant pins including CS on 53 for the first SD card and 13 for the second SD card. Can be any digital pin I think but this one makes the LED blink too). Before the SD.begin(13) of the second SD card I do a digitalWrite(53,HIGH). That de-selects the first SD card. and ...


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