Hey All,
I’ve been trying to configure code that will place my WiFi module to sleep but continue running the code that I have put in place. In order to achieve this I have needed to use a software timer library. I have coded it so that it would keep the WiFi module off for a period of time, but as soon as I try to use my pulse sensor the WiFi does not turn on anymore. At least from my understanding, it seems to have to do with the software timer that is in the Pulse sensor library and it disrupting the timer from my main code. I’m not entirely sure what to do, since I’m still very new to all of this.
Since i’m using an Argon, I had to use this code from a different thread that I found
https://go.particle.io/shared_apps/5c94423c5893c4000ab8a158
Not sure if this will be to confusing or not but this is my code that I have:
// Where the Magic Happens
void loop(){
Serial.println("Start of code");
if (QS == true){ // A Heartbeat Was Found
digitalWrite(blinkPin,HIGH);
fadeRate = 255;
bpm_latest = BPM; // this is storin the current BPM from the sensors code
QS = false; // reset the Quantified Self flag for next time
}
else {
digitalWrite(blinkPin,LOW); // There is not beat, turn off pin 13 LED
}
Hum = dht.getHumidity(); // Humidity
temp_sensor = dht.getTempCelcius(); // Temperature
if(timer.expired()||setting_up == true){
//energy_saving_mode();
Serial.println("entered the if statement");
if(wifi_check()==false){
energy_saving_mode();
}
}
Serial.println("End Of Code");
}
//------------------------------------------------------------\
///////// Sending data to the SQL server
bool wifi_check(){
//WiFi.connect();
boolean wifi = WiFi.ready();
Serial.println("checked Wifi");
if (wifi == false ){
Serial.println("WIFI was off");
setting_up = true;
}
else{
setting_up = false;
}
return setting_up;
}
void energy_saving_mode(){
Serial.println("sendin data");
send_data();//Send Data
Serial.println("goingg it too sleep mode");
System.sleep(30);//Place the sleep module into sleep
Serial.println("after sleep mode");
timer.start();// Start the timer
Serial.println("starting timer");
return;
}
void send_data(){
Serial.println("1sr");
sprintf(thedata, "%s%s%d%s%d%s%d", thepath, var, bpm_latest, temp_var, temp_sensor, hum_var, Hum);
Serial.println("2nd");
request.path = thedata;
Serial.println("3rd");
// Get request
http.get(request, response, headers);
}