wlswjd
February 24, 2022, 5:55am
1
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
LarryD
February 24, 2022, 6:02am
2
Show us your current sketch.
Make a 60 second TIMER, when it expires send your data.
wlswjd
February 24, 2022, 6:06am
3
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);
}
wlswjd
February 24, 2022, 6:07am
4
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?
LarryD
February 24, 2022, 6:17am
5
If you wrote that sketch, how do you not know how to make a 60 second TIMER ?
noiasca
February 24, 2022, 6:21am
6
@ 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
system
Closed
August 23, 2022, 7:29am
8
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.