0

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:
 
asked Nov 11, 2024 at 17:17
5
  • If your MCU is in sleep mode, it won't execute the 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. Commented Nov 12, 2024 at 13:24
  • Also posted in forum.arduino.cc/t/… Commented Nov 12, 2024 at 13:29
  • your sketch has a lot of irrelevant code lines Commented Nov 12, 2024 at 22:05
  • I guess my first priority is to figure out how to get it in and out of sleep mode. Then I can look into what runs or doesn't when its asleep. I certainly expect that to be a hurdle. Commented Nov 14, 2024 at 2:09
  • I see three closing brackets are missing from the code that you shared. The setup function has no closing bracket. So don't the loop function and the last if loop. Commented Jan 18 at 14:12

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.