Home › Forums › Mayfly Data Logger › Low power project › Reply To: Low power project
2017-01-09 at 4:57 AM
#1925
I tested the SDI12_Mod.h solely and the microcontroller will restart after begin the library 🙁
Problem solved(7 Feb 2017)
I am now using hardware interrupts D10 (you need to cut the trace solder a jumper to D10 at SJ1 on the back of the board)
Now you don’t need the pin change interrupt library(conflict with SDI library)
Below is the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
//Sleep mode setting #include <avr/sleep.h> //RTC Setting #include <Wire.h> #include <Sodaq_DS3231.h> char time_stamp[20]; void setup(){ //Start Serial Serial.begin(57600); //Begin RTC Serial.println("Begin RTC"); if (!rtc.begin()){ Serial.println("Couldn't find RTC");} //rtc.setDateTime(DateTime(__DATE__, __TIME__)); //Begin sleep mode pinMode(10, INPUT_PULLUP); attachInterrupt(2, wakeISR, FALLING); rtc.enableInterrupts(EveryMinute); //RTC interrupt mode set_sleep_mode(SLEEP_MODE_PWR_DOWN); //Set the sleep mode Serial.println("Setup completed!!!"); } void loop() { Serial.print("logging at: "); sprintf(time_stamp, "%02d:%02d:%02d",rtc.now().hour(),rtc.now().minute(),rtc.now().second()); Serial.println(time_stamp); //delay(10000); //Sleep systemSleep(); } void wakeISR(){ //Leave this blank } void systemSleep(){ //Wait until the serial ports have finished transmitting Serial.flush(); //Serial1.flush(); //The next timed interrupt will not be sent until this is cleared rtc.clearINTStatus(); //Disable ADC ADCSRA &= ~_BV(ADEN); //Sleep time noInterrupts(); sleep_enable(); interrupts(); sleep_cpu(); //wake up here sleep_disable(); //Enbale ADC ADCSRA |= _BV(ADEN); } |