Hello,
I was using the minimal project from github to create my own project. I have been flashed Audiomoth several times using Audiomoth Flash App. But the last time I did this, Audiomoth didn't work.
(the project maintains the flashing of the LEDs when switch is in CUSTOM or DEFAULT mode, and they don't blink when I switch is in those positions).
It is not found by the Flash App either. I tried in another computer but it didn't work.
Using flash application, when I run flash.exe I obtain "No serial ports found".
The difference between the last version that I flashed (that worked) and the one that failed were these added lines (I don't include the whole program for a better readability):
char STR[12300] = "";
for (int i = 0; i <NUMBER_OF_SAMPLES_IN_BUFFERS_DATA; i+= 1){
char str[12];
sprintf(str, "%f, ", var0[i]);
strncat(STR, str, 12);
}
RETURN_BOOL_ON_ERROR(AudioMoth_openFile("data.txt"));
RETURN_BOOL_ON_ERROR(AudioMoth_writeToFile(STR, sizeof(STR)));
RETURN_BOOL_ON_ERROR(AudioMoth_closeFile());
I don't know if the problem is related to this.
I am using windows 10.
What can I do?
Thanks in advance.
Perfect! I recovered the device. I was afraid of having damaged the device.
Thank you for your advise!
Hi, I'm glad you've jumped in and a programming your AudioMoth. It's hard to tell the full story without seeing all the code. However: 1) You should make sure that you call AudioMoth_enableFileSystem() before using the file system as this switches on the SD card and initialises the file system. 2) You STR string is very large and seems to be allocated on the stack. You should either move it to the global space (take it outside the main function) or add a static keyword to it so that the compiler does this automatically. That way the compiler will add it into the BSS area and you can see from the compiler summary how much RAM you are using. Same with var0 - I'm not sure how big this array is. The micro-controller has 32KB internally. There is also another 256KB of RAM in an external chip which is mapped to the normal memory space, but you need to set a pointer to it to access it. Check the normal firmware code for this - we use it for the RAM buffers. 3) For the Flash App to recognise the device there needs to be a path through the code to the AudioMoth_handleUSB() function. Make sure that close to the start of the main function you add the code below so that you can power up the device in USB/OFF mode and access it through the Flash App.
AM_switchPosition_t switchPosition = AudioMoth_getSwitchPosition();
if (switchPosition == AM_SWITCH_USB) { AudioMoth_handleUSB();
}
4) You aren't updating the destination pointer for the strncat function so you will end up writing all the strings on top of each other. To recover the device, remove the batteries and follow the instructions under 'Show Manual Switch Instructions' in the Flash App. This will put it straight into bootloader mode on power-up without entering your code.