Describe the bug
Loom 2.5 but may still be bug in Loom3 - please test and fix if needed - or close with reply if not a bug in Loom3.
Using this function to pull time from Manager returns time in UTC:
myHour = Loom.DS3231().now().hour();
But intended use to to modify behavior of the device within the context of local time. This function ought to return local time.
Hardware in Use
Feather M0, Stemma soil sensor, Relay to turn sensor power on and off
To Reproduce
Steps to reproduce the behavior:
Compile and open Serial Monitor
You may comment out soil sensor and relay things.
Expected behavior
Should return Local time, but returns UTC
Code
///////////////////////////////////////////////////////////////////////////////
// This example uses an RTC DS3231 Alarm to wake up and sample i2c sensors
// at a user defined interval (see config.h).
// It also uses pins A4 and A5 to control a latched relay to turn the
// power to the i2c sensor on and off (if hooked up as prescribed in the
// associated Pin-out diagram
void loop()
{
LPrintln("Powering up sensor");
relayOn(); // Power up sensor via Relay
// Flash pattern to visually indicate processor has turned on
digitalWrite(LED_BUILTIN, HIGH);
delay(250);
digitalWrite(LED_BUILTIN, LOW);
delay(250);
Loom.measure(); // Sample attached sensors
Loom.package(); // Format data for display and SD
Loom.display_data(); // display printed JSON formatted data on serial monitor
// Example of condition to test if time is between 9AM and 9PM:
myHour = Loom.DS3231().now().hour();
Serial.print("My Hour: "); Serial.println(myHour);
if(9 <= myHour <= 21)
{
// if moistureVal is under 800, too dry, chirp buzzer!
if(moistureVal < moistureThresh)
{
digitalWrite(LED_BUILTIN, HIGH); // optional set LED high
tone(buzzPin, 1000); // 500ms chirp
delay(500);
noTone(buzzPin);
digitalWrite(LED_BUILTIN, LOW);
}
} // end challenge if statement
// Log using default filename as provided in configuration
// in this case, 'datafile.csv'
Loom.SDCARD().log();
// Or log to a specific file (does not change what default file is set to)
//Loom.SDCARD().log("BEETest1.csv");
Loom.InterruptManager().RTC_alarm_duration(0,0,0,30); // Wakes up the sensors every 5 seconds
Loom.InterruptManager().reconnect_interrupt(AlarmPin); // Important, make interrupt pin sensitive to alarm signal again
LPrintln("Powering down sensor");
relayOff(); // Power down sensor via Relay
LPrintln("Going to sleep");
Loom.pause();
//Loom.SleepManager().sleep(); // rest in low power sleep mode
LPrintln("Awake");
}
// subroutine to set A4 and A5 pins to turn relay on
void relayOn()
{
// Set relay signal pins to known state, both low
digitalWrite(theUnsetPin, LOW); // turn the LED on (LOW is the voltage level)
digitalWrite(theSetPin, LOW); // turn the LED on (LOW is the voltage level)
// To turn relay on, set theSetPin High for 20ms, then set low again
digitalWrite(theSetPin, HIGH);
delay(20);
}
// subroutine to set A4 and A5 pins to turn relay off
void relayOff()
{
// Set relay signal pins to known state, both low
digitalWrite(theUnsetPin, LOW); // turn the LED on (LOW is the voltage level)
digitalWrite(theSetPin, LOW); // turn the LED on (LOW is the voltage level)
// To turn relay on, set theSetPin High for 20ms, then set low again
digitalWrite(theUnsetPin, HIGH);
delay(20);
digitalWrite(theUnsetPin, LOW); // Turn off the UnsetPin LED to save battery
}
// Subroutine that is executed when the RTC timer signal triggers the
// wake up interrupt service routine
void wakeISR() {
detachInterrupt(AlarmPin);
LPrintln("Alarm went off");
}
Config
"{\
'general':\
{\
'name':'Device',\
'instance':1,\
'interval':30000\
},\
'components':[\
{\
'name':'SD',\
'params':[true,1000,4,'SmtPtdata',true]\
},\
{\
'name':'Sleep_Manager',\
'params':[true,false,1]\
},\
{\
'name':'Interrupt_Manager',\
'params':[0]\
},\
{\
'name':'DS3231',\
'params':[10, true,false]\
},\
{\
'name':'STEMMA',\
'params':'default'\
}\
]\
}"
Additional context
Add any other context about the problem here.
Describe the bug Loom 2.5 but may still be bug in Loom3 - please test and fix if needed - or close with reply if not a bug in Loom3. Using this function to pull time from Manager returns time in UTC: myHour = Loom.DS3231().now().hour(); But intended use to to modify behavior of the device within the context of local time. This function ought to return local time.
Hardware in Use Feather M0, Stemma soil sensor, Relay to turn sensor power on and off
To Reproduce Steps to reproduce the behavior: Compile and open Serial Monitor You may comment out soil sensor and relay things.
Expected behavior Should return Local time, but returns UTC Code ///////////////////////////////////////////////////////////////////////////////
// This example uses an RTC DS3231 Alarm to wake up and sample i2c sensors // at a user defined interval (see config.h). // It also uses pins A4 and A5 to control a latched relay to turn the // power to the i2c sensor on and off (if hooked up as prescribed in the // associated Pin-out diagram
///////////////////////////////////////////////////////////////////////////////
include
// Include configuration const char* json_config =
include "config.h"
;
// Set enabled modules LoomFactory< Enable::Internet::Disabled, Enable::Sensors::Enabled, Enable::Radios::Disabled, Enable::Actuators::Disabled, Enable::Max::Disabled
LoomManager Loom{ &ModuleFactory };
const int theSetPin = A4; const int theUnsetPin = A5; const int AlarmPin = 10; // Pin DS3231 INT pin is physically connected to
int moistureVal = 404; // initialize to a bogus but known value so we know if data is being refreshed
const int buzzPin = A0;
const int moistureThresh = 800; // Moisture threshold
int myHour = 0; // place to save hour value from DS3231 for challenge assignment
void setup() {
pinMode(theSetPin, OUTPUT); // Set pin, output pinMode(theUnsetPin, OUTPUT); // Unset pin, output
// Set Buzzer pin A0 to function as an output pinMode(buzzPin, OUTPUT);
relayOn(); // Power on attached sensor for setup!
Loom.begin_LED(); digitalWrite(LED_BUILTIN, HIGH);
// while(!Serial) {}
Loom.begin_serial(false); Loom.parse_config(json_config); Loom.print_config();
Loom.InterruptManager().register_ISR(AlarmPin, wakeISR, LOW, ISR_Type::IMMEDIATE);
digitalWrite(LED_BUILTIN, LOW);
LPrintln("\n Setup Complete ");
}
void loop() { LPrintln("Powering up sensor"); relayOn(); // Power up sensor via Relay
// Flash pattern to visually indicate processor has turned on digitalWrite(LED_BUILTIN, HIGH); delay(250); digitalWrite(LED_BUILTIN, LOW); delay(250);
Loom.measure(); // Sample attached sensors Loom.package(); // Format data for display and SD Loom.display_data(); // display printed JSON formatted data on serial monitor
// Pull Soil Moisture data moistureVal = Loom.get_data_as("STEMMA", "capactive");
LPrintln("Moisture Value: ", moistureVal);
// Example of condition to test if time is between 9AM and 9PM: myHour = Loom.DS3231().now().hour(); Serial.print("My Hour: "); Serial.println(myHour); if(9 <= myHour <= 21) { // if moistureVal is under 800, too dry, chirp buzzer! if(moistureVal < moistureThresh) { digitalWrite(LED_BUILTIN, HIGH); // optional set LED high tone(buzzPin, 1000); // 500ms chirp delay(500); noTone(buzzPin); digitalWrite(LED_BUILTIN, LOW); } } // end challenge if statement
// Log using default filename as provided in configuration // in this case, 'datafile.csv' Loom.SDCARD().log();
// Or log to a specific file (does not change what default file is set to)
//Loom.SDCARD().log("BEETest1.csv");
Loom.InterruptManager().RTC_alarm_duration(0,0,0,30); // Wakes up the sensors every 5 seconds Loom.InterruptManager().reconnect_interrupt(AlarmPin); // Important, make interrupt pin sensitive to alarm signal again
LPrintln("Powering down sensor"); relayOff(); // Power down sensor via Relay
LPrintln("Going to sleep"); Loom.pause(); //Loom.SleepManager().sleep(); // rest in low power sleep mode
LPrintln("Awake"); }
// subroutine to set A4 and A5 pins to turn relay on void relayOn() { // Set relay signal pins to known state, both low digitalWrite(theUnsetPin, LOW); // turn the LED on (LOW is the voltage level) digitalWrite(theSetPin, LOW); // turn the LED on (LOW is the voltage level)
// To turn relay on, set theSetPin High for 20ms, then set low again digitalWrite(theSetPin, HIGH); delay(20);
}
// subroutine to set A4 and A5 pins to turn relay off void relayOff() { // Set relay signal pins to known state, both low digitalWrite(theUnsetPin, LOW); // turn the LED on (LOW is the voltage level) digitalWrite(theSetPin, LOW); // turn the LED on (LOW is the voltage level)
// To turn relay on, set theSetPin High for 20ms, then set low again digitalWrite(theUnsetPin, HIGH); delay(20); digitalWrite(theUnsetPin, LOW); // Turn off the UnsetPin LED to save battery }
// Subroutine that is executed when the RTC timer signal triggers the // wake up interrupt service routine void wakeISR() {
detachInterrupt(AlarmPin); LPrintln("Alarm went off");
} Config "{\ 'general':\ {\ 'name':'Device',\ 'instance':1,\ 'interval':30000\ },\ 'components':[\ {\ 'name':'SD',\ 'params':[true,1000,4,'SmtPtdata',true]\ },\ {\ 'name':'Sleep_Manager',\ 'params':[true,false,1]\ },\ {\ 'name':'Interrupt_Manager',\ 'params':[0]\ },\ {\ 'name':'DS3231',\ 'params':[10, true,false]\ },\ {\ 'name':'STEMMA',\ 'params':'default'\ }\ ]\ }" Additional context Add any other context about the problem here.