I'm Using ESP32 and PIR sensor for HTTP GET. I can successfully HTTP GET but i want to GET only once for the first time. So i int a 'requested = false;' at the loop and 'requested = true;' at the end of the loop's if. But this code still bring not the first time. How can i do?
(sorry for short english;;; it's my best)
The Code #include <WiFi.h> #include <HTTPClient.h>
Please follow the advice given in the link below when posting code , use code tags and post the code here to make it easier to read and copy for examination
void loop()
{
int pir_stat = digitalRead(pir);
int requested = false;
if (pir_stat == HIGH && !requested )
{
if ((millis() - lastTime) > timerDelay)
{
if (WiFi.status() == WL_CONNECTED)
{
requested is set to false at the start of loop() (by the way it should be a boolean, not an int), then you have code that depends on it being true in order to run. Is that what you meant to do ?
um i think so, and i tried with boolean but it still continues to http get...
i want this code to 1)connected to wifi β 2) motion detects(http get only once for the first time on serial) β 3) motion undetected β 4) motion detects(http get only once)
at the image and the code, this thing continues to http get about 7seconds delay rather it is the first time or not
i want only serial print when movement detected just once! But i cant handle it more from here... i was thinking that if i use requested=false and requested-=true at the end of the if can only sign up once in the screen... can you help to fix the code...??? (i changed it to boolean by the way and it plays the same..)