Problem using JeeLib.h

Hello,

I’m trying to utilise the JeeLib.h library to hibernate a UNO to conserve battery power but am having some fundamental problems and have resorted to the original JeeLib Sketch example to start from basics.

Here is the sketch;;;

#include <JeeLib.h> // Low power functions library
int led_pin = 7;
ISR(WDT_vect) { Sleepy::watchdogEvent(); } // Setup the watchdog

void setup()
{
  Serial.begin(9600, SERIAL_8N1);         // Serial interface for for DEPTH data
  Serial.println("\nUNO - Setup....");   pinMode(led_pin, OUTPUT);
} // end of setup

void loop() 
{

 // Turn the LED on and sleep for 5 seconds
 digitalWrite(led_pin, HIGH);
 Serial.println("\nLED On");
 
 Sleepy::loseSomeTime(5000);

 // Turn the LED off and sleep for 5 seconds
 digitalWrite(led_pin, LOW);
 Serial.println("\nLED Off");

 Sleepy::loseSomeTime(5000);
}

When I run the sketch the LED turns on and off as expected but the output to the console looks like this

====

UNO - Set�]⸮...

�⸮⸮On

L�Qz⸮⸮5

�⸮⸮On

L�Qz⸮⸮5

�⸮⸮On

L�Qz⸮⸮5

�⸮⸮On

L�Qz⸮⸮5

�⸮⸮On

L�Qz⸮⸮5

�⸮⸮On

L�Qz⸮⸮5

�⸮⸮On

L�Qz⸮⸮5

�⸮⸮On

L�Qz⸮⸮5

=====

ad infinitum which is preventing me from adding checkpoints in my main program.

It is most likely a simple error on my part but I am unable to see it.

Any help much appreciated.

PS I need to hibernate the UNO for 15 minutes and if there is as an alternative method I might use I would appreciate some info.

Many thanks.

When I run the sketch the LED turns on and off as expected but the output to the console

Output to what "console"?

You MUST flush() the outgoing serial data before snoozing.

Hi Paul,

By ‘console’ I meant the serial monitor.

I included the Serial.flush() instruction and now the output appears as expected.

Thanks for your help!