OPEnSLab-OSU / Loom-V4

Open Source Internet Of Things Rapid Prototyping Framework For Environmental Sensing Applications
5 stars 1 forks source link

Adalogger Log to SD freezes! #105

Closed udellc closed 7 months ago

udellc commented 7 months ago

Describe the bug When trying to log to SD using the Adalogger version of hypnos, the program freezes. It does not freeze when you remove the hypnos.logToSD(); function. Hang is critical in that I have to hit the reset button twice to put M0 into bootloader mode to program again. Not needed when log sd function removed.

Data is NOT saved to SD card, no new files are made.

Also, including these in setup to log prints wont even work!: // This will log all LOG, ERROR, WARNING and any other logging calls to a file on the SD card ENABLE_SD_LOGGING;

// Enables debug memory usage function summaries that will be logged to the SD card
ENABLE_FUNC_SUMMARIES;

Hardware in Use Adalogger M0

To Reproduce Upload the following code. Run it on the Adalogger with the STEMMA sensor plugged in, or comment it out and just log analog or something.

Expected behavior Device should log sensor data to SD and keep doing so at 5 second intervals. No sleep

Code

/**
 * STEMMA Example code
 * 
 * MANAGER MUST BE INCLUDED FIRST IN ALL CODE
 */

#include <Loom_Manager.h>

#include <Sensors/I2C/Loom_STEMMA/Loom_STEMMA.h>

Manager manager("Device", 1);

// Create a new Hypnos object setting the version to determine the SD Chip select pin, and starting without the SD card functionality
//Loom_Hypnos(Manager& man, HYPNOS_VERSION version, TIME_ZONE zone, bool use_custom_time = false, bool useSD = true)
Loom_Hypnos hypnos(manager, HYPNOS_VERSION::ADALOGGER, TIME_ZONE::PST);

// Reads the battery voltage
Loom_STEMMA stemma(manager);

void setup() {

  // Start the serial interface
  manager.beginSerial();

  // Enable the hypnos rails
  hypnos.enable();

  // Initialize the manager
  manager.initialize();
}

void loop() {
  // put your main code here, to run repeatedly:

  // Measure the data from the sensors
  manager.measure();

  // Package the data into JSON
  manager.package();

  // Print the JSON document to the Serial monitor
  manager.display_data();

  // Log to the SD card twice and then lay dormant
  hypnos.logToSD();

  // Wait for 5 seconds
  manager.pause(5000);
}

Output ``` ``` 09:17:05.015 -> [SD Manager] Initializing SD Card... 09:17:05.015 -> [SD Manager] Successfully initialized SD Card! 09:17:05.015 -> [SD Manager] Data will be logged to Device0.csv 09:17:05.015 -> [DEBUG] [:initializeRTC:177] Initializing DS3231.... 09:17:05.015 -> [WARNING] [:initializeRTC:187] RTC lost power, let's set the time! 09:17:05.015 -> [DEBUG] [:initializeRTC:205] DS3231 Real-Time Clock Initialized Successfully! 09:17:05.015 -> [2005.05.05 05:05:85] [DEBUG] [:initialize:217] Initializing Modules 09:17:05.025 -> [2005.05.05 05:05:85] [DEBUG] [:initialize:28] Successfully initialized STEMMA Version: 263858063 09:17:05.025 -> [2005.05.05 05:05:85] [DEBUG] [:initialize:223] Setup Complete 09:17:05.025 -> [2005.05.05 05:05:85] [DEBUG] [:measure:68] Measuring 09:17:05.025 -> [2005.05.05 05:05:85] [DEBUG] [:measure:85] Measuring Complete 09:17:05.025 -> [2005.05.05 05:05:85] [DEBUG] [:package:95] Packaging 09:17:05.025 -> [2005.05.05 05:05:85] [DEBUG] [:package:125] Packaging Complete 09:17:05.025 -> [2005.05.05 05:05:85] [DEBUG] [:display_data:198] Data Json: 09:17:05.025 -> 09:17:05.025 -> { 09:17:05.025 -> "type": "data", 09:17:05.025 -> "id": { 09:17:05.025 -> "name": "Device", 09:17:05.025 -> "instance": 1 09:17:05.025 -> }, 09:17:05.025 -> "contents": [ 09:17:05.025 -> { 09:17:05.025 -> "module": "Packet", 09:17:05.025 -> "data": { 09:17:05.025 -> "Number": 1 09:17:05.025 -> } 09:17:05.025 -> }, 09:17:05.025 -> { 09:17:05.025 -> "module": "STEMMA", 09:17:05.025 -> "data": { 09:17:05.025 -> "Temperature": 28.94985962, 09:17:05.025 -> "Capacitive": 598 09:17:05.025 -> } 09:17:05.025 -> } 09:17:05.025 -> ], 09:17:05.025 -> "timestamp": { 09:17:05.025 -> "time_utc": "2023-01-11T7:46:25Z", 09:17:05.025 -> "time_local": "2165-165-165T165:165" 09:17:05.025 -> } 09:17:05.025 -> } ``` ```

Additional context Add any other context about the problem here.

udellc commented 7 months ago

To be more clear, a new file with the file name is made on the SD, but never filled with data.

udellc commented 7 months ago

DIAGNOSED: You need to have the external DS3231 Featherwing attached and in place in order for even the SD logging functions to work!