Hi all! I am trying to power an Arduino Uno via a battery that is charged by a solar panel and now i want to increase the battery discharging time by putting the Arduino Uno to sleep mode. I have also connected a NRF24L01+ module and an MQ-7 Gas sensor to the arduino board.
I would love if i could put the Arduino Uno to sleep for 1 hour, then wake it up, read and trasmit data for 250 seconds and then put it to sleep for 1 hour etc. I downloaded the Low Power Library from
and here is my code:
[spoiler]
#include <SPI.h>
#include "RF24.h"
#include "LowPower.h"
RF24 myRadio (7, 8);
byte addresses[][6] = {"0"};
int sensorPin = A0; // select the input pin for the CO sensor
// initialize digital pin ledPin as an output
int ledPin = 2;
struct package
{
int id=1;
char text[100] = "CO Level:";
public: int sensorValue = 0; // variable to store the value coming from the sensor
};
typedef struct package Package;
Package data;
void setup()
{
Serial.begin(9600);
delay(1000);
myRadio.begin();
myRadio.setChannel(115);
myRadio.setPALevel(RF24_PA_MAX);
myRadio.setDataRate( RF24_250KBPS ) ;
myRadio.openWritingPipe( addresses[0]);
delay(1000);
pinMode(ledPin, OUTPUT);
}
void loop()
{
for (int i=0; i<=250; i++)
{
analogWrite(ledPin, 255); // "HIGH" state - 5V
delay(60000); // HIGH" state lasts 60 seconds
// After heating it's time to go to "LOW" state
analogWrite(ledPin, 72); // "LOW" state - 1.4V
delay(90000); // "LOW" state lasts for 90 seconds
// Waiting 90 more seconds
digitalWrite(ledPin, HIGH);
delay (50); //small delay so that the sensor does not heat too much
// Reading Sensor
data.sensorValue = analogRead(sensorPin);
myRadio.write(&data, sizeof(data));
Serial.print("\nPackage:");
Serial.print(data.id);
Serial.print("\n");
Serial.println(data.text);
Serial.println(data.sensorValue);
data.id = data.id + 1;
delay(1000);
}
LowPower.powerDown(SLEEP_3600S, ADC_OFF, BOD_OFF) ;
}
[/spoiler]
I keep getting an "exit status 1
'SLEEP_3600S' was not declared on this scope" error and i do not know what to do.
So, i would appreciate your help. Thanks!