Alper Erdem
29
Q:

BOD_OFF

for(int j=0;j<112;j++) LowPower.powerDown(SLEEP_8S,ADC_OFF,BOD_OFF);
-1
#include "LowPower.h"

void setup()
{
}

void loop()
{
   LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF); 
}

0
radio.Sleep();var = 0;while(var < 10){  // do something 10 times  var++;  // put the processor to sleep for 8 seconds  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);}
0
    void loop(){
    everything
    if (Delay ==4) {
  delay(180000);//real
  sensorBatValue = analogRead(batteryInPin);
  delay(500);
if(chargeSwitch ==1){
 if(sensorBatValue < batteryNoCharge) {
  }
 else if(sensorBatValue > batteryNoCharge) {
     digitalWrite(10,HIGH);
   delay(1000);
   digitalWrite(10,LOW);
   chargeSwitch = 2;
  }
   }
else if(chargeSwitch ==2){
    if(sensorBatValue > batteryCharge) {
    }
    else if(sensorBatValue < batteryCharge) {
      digitalWrite(13,HIGH);
    delay(1000);
   digitalWrite(13,LOW);
   chargeSwitch = 1;
    }
  }
    //include the checking of the battery inside the lowPower
    void lowPower(){
    LowPower.powerDown(SLEEP_8S,ADC_OFF,BOD_OFF);
    LowPower.powerDown(SLEEP_8S,ADC_OFF,BOD_OFF);
    LowPower.powerDown(SLEEP_8S,ADC_OFF,BOD_OFF);
    LowPower.powerDown(SLEEP_8S,ADC_OFF,BOD_OFF);
    etc.
    LowPower.powerDown(SLEEP_8S,ADC_OFF,BOD_OFF);
    //check battery after 15 min.
    delay(500);
       sensorBatValue = analogRead(batteryInPin);
    delay(500);
    if(chargeSwitch ==1){
     if(sensorBatValue < batteryNoCharge) {
     }
     else if(sensorBatValue > batteryNoCharge) {
         digitalWrite(10,HIGH);
       delay(1000);
       digitalWrite(10,LOW);
       chargeSwitch = 2;
      }
       }
    else if(chargeSwitch ==2){
        if(sensorBatValue > batteryCharge) {
       }
        else if(sensorBatValue < batteryCharge) {
          digitalWrite(13,HIGH);
        delay(1000);
       digitalWrite(13,LOW);
       chargeSwitch = 1;
        }
      }
    //then repeat to two hours
    }
0
#include "LowPower.h"
unsigned int sleepCounter = 0;
unsigned int sleepCounter2 = 0;
unsigned int batteryCounter = 110; // 8 sec X 110 = 15 min approx.
unsigned int sensorCounter = 900;  // 8 sec X 900 = 2 hours approx.
unsigned int voltageReading = 0;

void setup(){

  // Test using pin 13 and Serial Monitor.
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);
  Serial.begin(9600);

}

void loop(){

  // Enter power down state for 8 seconds.
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);  

  // Increment counters. 
  sleepCounter++;
  sleepCounter2++;

  // Check the battery voltage.
  if(sleepCounter == batteryCounter){

    // Reset the counter.
    sleepCounter = 0;

    delay(10);
    voltageReading = analogRead(A0);

    // Turn the built in LED On for 1 second then Off.
    // Send the voltage reading to the Serial Monitor.
    digitalWrite(LED_BUILTIN, HIGH);
    delay(1000);
    digitalWrite(LED_BUILTIN, LOW);
    Serial.print("Voltage=");
    Serial.println(voltageReading);
    Serial.flush();
  }

  // Check the sensors.
  if(sleepCounter2 == sensorCounter){

    // Reset the counter.
    sleepCounter2 = 0;

    // Turn the built in LED On for 2 seconds then Off.
    // Send a message to the Serial Monitor.
    digitalWrite(LED_BUILTIN, HIGH);
    delay(2000);
    digitalWrite(LED_BUILTIN, LOW);
    Serial.println("Checking Sensors.");
    Serial.flush();
  }

}
0
#include "LowPower.h" // import the lowpoer library
int led = 13; 
void setup()
{ 
pinMode(led, OUTPUT); 
}
void loop() 
{ 
digitalWrite(led, HIGH); 
LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF); // instead of delay(1000) ; 
digitalWrite(led, LOW); 
LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF); // instead of delay(1000) ; 
}
0
pinMode(LEDPIN, OUTPUT);digitalWrite(LEDPIN,HIGH);LowPower.powerDown(SLEEP_60MS, ADC_CONTROL_OFF, BOD_OFF);digitalWrite(LEDPIN,LOW);
0
   void loop(){
    //code to run other sensors etc.
    if (Delay ==4) {
  delay(180000);
//check the battery to begin with
sensorBatValue = analogRead(batteryInPin);
  delay(500);
if(chargeSwitch ==1){
 if(sensorBatValue < batteryNoCharge) {
  }
 else if(sensorBatValue > batteryNoCharge) {
     digitalWrite(10,HIGH);
   delay(1000);
   digitalWrite(10,LOW);
   chargeSwitch = 2;
  }
   }
else if(chargeSwitch ==2){
    if(sensorBatValue > batteryCharge) {
    }
    else if(sensorBatValue < batteryCharge) {
      digitalWrite(13,HIGH);
    delay(1000);
   digitalWrite(13,LOW);
   chargeSwitch = 1;
    }
  }
//put to sleep
lowPower();
//check battery again
delay(180000);//real
sensorBatValue = analogRead(batteryInPin);
  delay(500);
if(chargeSwitch ==1){
 if(sensorBatValue < batteryNoCharge) {
  }
 else if(sensorBatValue > batteryNoCharge) {
     digitalWrite(10,HIGH);
   delay(1000);
   digitalWrite(10,LOW);
   chargeSwitch = 2;
  }
   }
else if(chargeSwitch ==2){
    if(sensorBatValue > batteryCharge) {
    }
    else if(sensorBatValue < batteryCharge) {
      digitalWrite(13,HIGH);
    delay(1000);
   digitalWrite(13,LOW);
   chargeSwitch = 1;
    }
  }
// put to sleep
lowPower();
//repeat for total of 2 hours.
}

 void lowPower(){
    LowPower.powerDown(SLEEP_8S,ADC_OFF,BOD_OFF);
    LowPower.powerDown(SLEEP_8S,ADC_OFF,BOD_OFF);
    LowPower.powerDown(SLEEP_8S,ADC_OFF,BOD_OFF);
    LowPower.powerDown(SLEEP_8S,ADC_OFF,BOD_OFF);
    //repeat until 15 minutes is reached
}
0
#include "LowPower.h"
void setup()
{ 
// No setup is required for this library 
} 
void loop() 
{ 
// Sleep for 8 s with ADC module and BOD module off 
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); 
// Do something here 
// Example: read sensor, log data, transmit data 
}
0
radio.Sleep();LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
0

New to Communities?

Join the community