How to send data every 1 minute(60sec)

Hi, i'm new in IR sensor.
I just started a new project, and my sensor works properly.
And Now i want to send my sensor's count data every 60 second to my database server.

Do you guys know how to make it happen ?
It will be great to teach me some codes. Thanks :slight_smile:

Show us your current sketch.


Make a 60 second TIMER, when it expires send your data.

void loop() {
  ApplySensor();
  if (isDatachanged){
  Upload;
}

void Upload() {

  String request = "sensor=" + String(chipId, HEX) + "&count=" + String(IN);

  // LORA --------------------------------------------
  rf95.send((uint8_t *)request.c_str(), 25);

  // NETWORK ----------------------------------------------

  if (isETH) {
    Serial2.println("POST " + serverName + " " + request);
    Serial.println(request);
  }
  else {
    WiFiClient client;
    HTTPClient http;
    http.begin(client, serverName);
    http.addHeader("Content-Type", "application/x-www-form-urlencoded");
    int httpResponseCode = http.POST(request);
    Serial.print("HTTP Resonse code : ");
    Serial.println(httpResponseCode);
    http.end();
  }
  Buzzer_ON();
  isDataChanged = false;
  delay(10);
}

I made the code like this(part of the code) and i'd like to send this data to database every 60seconds can you help me?

If you wrote that sketch, how do you not know how to make a 60 second TIMER ?

@ wlswjd

I'm using a code part like this

if (millis()-previousMillis > 60000UL)
{
  previousMillis=millis();
  sendData(42);
}

I hope this helps.

if not may be you understand now how USELESS some lines of codes are.
Post a full compileable sketch
describe what controller you are using

YMMD :sweat_smile: :rofl: :joy:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.