OPEnSLab-OSU / Loom-V4

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

Adalogger with Hypnos, Does not set local time correctly #104

Closed udellc closed 7 months ago

udellc commented 7 months ago

Describe the bug When setting custom time or lost power and manually setting time using the ADALOGGER version of hypnos library, UTC time appears to be set correctly, but time is set to the strange things!

Hardware in Use Adalogger M0 and Hypnos loom libraries. Also using a STEMMA soil sensor just to test i2c data logging, but sensor works on its own using the i2c STEMMA example.

To Reproduce Upload the following code I am using to test logging a STEMMA soil moisture sensor to SD using Adalogger, no sleep. Check out initialize messages, and timestamps

Expected behavior Should have correct ttimestamps

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, true);

// 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();

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

Output ``` ``` 09:06:07.643 -> [WARNING] [:initializeRTC:187] RTC lost power, let's set the time! 09:06:07.681 -> [DEBUG] [:set_custom_time:278] Please use your local time, not UTC! 09:06:07.681 -> [DEBUG] [:set_custom_time:281] Enter the Year (Four digits, e.g. 2020) 09:06:22.420 -> [DEBUG] [:set_custom_time:288] Year Entered: 2023 09:06:22.420 -> [DEBUG] [:set_custom_time:291] Enter the Month (1 ~ 12) 09:06:27.326 -> [DEBUG] [:set_custom_time:297] Month Entered: 11 09:06:27.326 -> [DEBUG] [:set_custom_time:300] Enter the Day (1 ~ 31) 09:06:33.130 -> [DEBUG] [:set_custom_time:306] Day Entered: 9 09:06:33.130 -> [DEBUG] [:set_custom_time:310] Enter the Hour (0 ~ 23) 09:06:37.655 -> [DEBUG] [:set_custom_time:317] Hour Entered: 9 09:06:37.689 -> [DEBUG] [:set_custom_time:320] Enter the Minute (0 ~ 59) 09:06:41.315 -> [DEBUG] [:set_custom_time:326] Minute Entered: 6 09:06:41.315 -> [DEBUG] [:set_custom_time:329] Enter the Second (0 ~ 59) 09:06:44.740 -> [2005.05.05 05:05:85] [DEBUG] [:set_custom_time:340] Custom time successfully set to: 2005.05.05 05:05:85 09:06:44.740 -> [2005.05.05 05:05:85] [DEBUG] [:initializeRTC:205] DS3231 Real-Time Clock Initialized Successfully! 09:06:44.740 -> [2005.05.05 05:05:85] [DEBUG] [:initialize:217] Initializing Modules 09:06:44.740 -> [2005.05.05 05:05:85] [DEBUG] [:initialize:28] Successfully initialized STEMMA Version: 263858063 09:06:44.772 -> [2005.05.05 05:05:85] [DEBUG] [:initialize:223] Setup Complete 09:06:44.772 -> [2005.05.05 05:05:85] [DEBUG] [:measure:68] Measuring 09:06:44.772 -> [2005.05.05 05:05:85] [DEBUG] [:measure:85] Measuring Complete 09:06:44.772 -> [2005.05.05 05:05:85] [DEBUG] [:package:95] Packaging 09:06:44.772 -> [2005.05.05 05:05:85] [DEBUG] [:package:125] Packaging Complete 09:06:44.772 -> [2005.05.05 05:05:85] [DEBUG] [:display_data:198] Data Json: 09:06:44.772 -> 09:06:44.772 -> { 09:06:44.772 -> "type": "data", 09:06:44.772 -> "id": { 09:06:44.772 -> "name": "Device", 09:06:44.772 -> "instance": 1 09:06:44.772 -> }, 09:06:44.772 -> "contents": [ 09:06:44.772 -> { 09:06:44.772 -> "module": "Packet", 09:06:44.772 -> "data": { 09:06:44.772 -> "Number": 1 09:06:44.772 -> } 09:06:44.772 -> }, 09:06:44.772 -> { 09:06:44.772 -> "module": "STEMMA", 09:06:44.772 -> "data": { 09:06:44.772 -> "Temperature": 27.27577209, 09:06:44.772 -> "Capacitive": 373 09:06:44.772 -> } 09:06:44.772 -> } 09:06:44.772 -> ], 09:06:44.772 -> "timestamp": { 09:06:44.772 -> "time_utc": "2023-01-11T7:46:25Z", 09:06:44.772 -> "time_local": "2165-165-165T165:165" 09:06:44.772 -> } 09:06:44.772 -> } ``` ```

Additional context Add any other context about the problem here.

udellc commented 7 months ago

I'm not even trying to log to SD here.

udellc commented 7 months ago

You need to have the external DS3231 featherwing also attached to get the functions to work! If the Hypnos library for Adalogger Requires Both the Adalogger AND the DS3231 - can we put a check function somewhere in there to throw an error and print it saying DS3231 Required for proper functionality?