I'm trying to figure out how to wake up and put to sleep the Arduino Nano 33 BLE. I have seen a few post about it but absolutely nothing I can understand or implement. I'm attaching a subset of the code below because the whole thing is 20 pages. But the declarations, setup and loop show what I'm trying to do. The first if statement in the loop is where I would like to put the code to wake it up. The second If statement is where I would like to put the Arduino to sleep. I can provide the rest of the code if needed but its really 20 pages of functions that all work without issue.
Any help would be appreciated.
// Note this program uses a watchdog timmer.
// It is required to reset the Arduino by two presses of the reset button and setting available com ports prior to upload.
// After upload the com port needs to be reset.
// Define Global Constants /////////////////////////////////////////////////////////////////
// constants thet are desirable to adjust during debugging.
const bool SerialStatus = true; // Set to true to hold serial printing until the serial printer is started. Set to false to release hold for stand alone use
const bool WDTStatus = false; // Set to true to activate the Watch Dog Timmer, Set to false to deactivate for debugging
const unsigned long WDT = 30; // Watch Dog Timer max time seconds This must be greater than the time requird to complete a cycle
// Constant for voltage sensing
const unsigned long Resistor1 = 33000L; // Voltage divider resistor #1
const unsigned long Resistor2 = 3300L; // Voltage divider resistor #2
const float BoardV = 3.3; // Board operating voltage
const float VMult = BoardV*((Resistor1 + Resistor2)/Resistor2)/1023L; // Voltage multiplier to get voltage from analogread pin "VsnPin"
const float EngineOnVoltage = 13.2; // Voltage at which the engine is considered to be running
const float KeyOnVoltage = 12; // Voltage at which the key is considered to be on
const long PostRunInterval = 30; // Time the fan will run after engine shut down
// Constanst for program control
const int frequency = 10.0; // Set fan frequency
const int NumberOfSamples = 20; // Sent number of data samples for averaging.
const int BlinkTimeOnTest = 2000; // Blink time on period for initial circuit test
const int BlinkTimeOn = 500; // Blink time on period
const int BlinkTimeOff = 500; // Blink time off period
// Constants for Arduino board configuration
const int VsnPin = A0; // Circuite 15 Voltage level sensing pin
const int RadPin = A1; // Radiator Input Thermister
const int CndPin = A2; // Condenser Input Thermister
const int AuxPin = A3; // Auxilary Input
const int FanPin = D9; // Set Fan pin
const int LED1Pin = D4; // Set Cooling Fan LED
const int LED2Pin = D3; // Set Condenser Fan LED
const int LED3Pin = D2; // Set Aux Fan LED
////////////////////////////////////////////////////////////////////////////////////
void setup()
{
// put your setup code here, to run once:
pinMode(VsnPin, INPUT);
pinMode(RadPin, INPUT);
pinMode(CndPin, INPUT);
pinMode(AuxPin, INPUT);
pinMode(LED1Pin, OUTPUT);
pinMode(LED2Pin, OUTPUT);
pinMode(LED3Pin, OUTPUT);
pinMode(FanPin, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
////////////////////////////////////////////////////////////////////////////////////
void loop()
{
if (VMult*analogRead(VsnPin) > EngineOnVoltage)
{
// Wake Nano 33 BLE
}
if (RunFan() == false)
{
//Put Nano 33 BLE to sleep
}
if (RunFan() == true) // Run the fan if apropriate
{
// wait for a Bluetooth® Low Energy central
BLEDevice central = BLE.central();
// if a central is connected to the peripheral:
if
statement to read the analog input. You need to either set up a timer to wake up periodically or with a hardware comparator with the analog input as the input and compare to a threshold reference voltage to generate a trigger signal to wake up the MCU.