Skip to main content
deleted 6 characters in body
Source Link
Julio
  • 113
  • 2
  • 3
  • 11

Thank you all, guys. I considered your ideas, and then I code this solution. It works fine, right now I'm reading my sensor once every 30 minutes (1,800,000 miliseconds) and whenever I send the magic word. I hope it is useful to you:

void loop(){
if ((millis() - timer < 1800000) && (Serial.available() > 0)){
    magicInput = Serial.readString();
    magicInput.trim(); //Cleans input from \n at the end, otherwise never equals magicInput
    if (magicInput.equals(magicWord)){     //Elegant way toform expressfor "=="
      Serial.println();
      Serial.println("  === Your request ==="); //Shows requested measurement
      Serial.println(millis() - timer); //Time since last measurement
      measure(); //
    }
  }

  if (millis() - timer >= 1800000){
    Serial.println();
    Serial.println("===== Normal mode =====");  //Indicates that measurement was not requested by user
    Serial.println(millis() - timer); //Checks that 30 "exact" minutes have run
    mide();
    timer = millis();
  }
}

Thank you all, guys. I considered your ideas, and then I code this solution. It works fine, right now I'm reading my sensor once every 30 minutes (1,800,000 miliseconds) and whenever I send the magic word. I hope it is useful to you:

void loop(){
if ((millis() - timer < 1800000) && (Serial.available() > 0)){
    magicInput = Serial.readString();
    magicInput.trim(); //Cleans input from \n at the end, otherwise never equals magicInput
    if (magicInput.equals(magicWord)){     //Elegant way to express "=="
      Serial.println();
      Serial.println("  === Your request ==="); //Shows requested measurement
      Serial.println(millis() - timer); //Time since last measurement
      measure(); //
    }
  }

  if (millis() - timer >= 1800000){
    Serial.println();
    Serial.println("===== Normal mode =====");  //Indicates that measurement was not requested by user
    Serial.println(millis() - timer); //Checks that 30 "exact" minutes have run
    mide();
    timer = millis();
  }
}

Thank you all, guys. I considered your ideas, and then I code this solution. It works fine, right now I'm reading my sensor once every 30 minutes (1,800,000 miliseconds) and whenever I send the magic word. I hope it is useful to you:

void loop(){
if ((millis() - timer < 1800000) && (Serial.available() > 0)){
    magicInput = Serial.readString();
    magicInput.trim(); //Cleans input from \n at the end, otherwise never equals magicInput
    if (magicInput.equals(magicWord)){     //Elegant form for "=="
      Serial.println();
      Serial.println("  === Your request ==="); //Shows requested measurement
      Serial.println(millis() - timer); //Time since last measurement
      measure(); //
    }
  }

  if (millis() - timer >= 1800000){
    Serial.println();
    Serial.println("===== Normal mode =====");  //Indicates that measurement was not requested by user
    Serial.println(millis() - timer); //Checks that 30 "exact" minutes have run
    mide();
    timer = millis();
  }
}
Source Link
Julio
  • 113
  • 2
  • 3
  • 11

Thank you all, guys. I considered your ideas, and then I code this solution. It works fine, right now I'm reading my sensor once every 30 minutes (1,800,000 miliseconds) and whenever I send the magic word. I hope it is useful to you:

void loop(){
if ((millis() - timer < 1800000) && (Serial.available() > 0)){
    magicInput = Serial.readString();
    magicInput.trim(); //Cleans input from \n at the end, otherwise never equals magicInput
    if (magicInput.equals(magicWord)){     //Elegant way to express "=="
      Serial.println();
      Serial.println("  === Your request ==="); //Shows requested measurement
      Serial.println(millis() - timer); //Time since last measurement
      measure(); //
    }
  }

  if (millis() - timer >= 1800000){
    Serial.println();
    Serial.println("===== Normal mode =====");  //Indicates that measurement was not requested by user
    Serial.println(millis() - timer); //Checks that 30 "exact" minutes have run
    mide();
    timer = millis();
  }
}