NEED HELP WITH VOID LOOP

I am working on a project in which i use the strength of wifi signal for the relay to turn on and off .
But there is a issue when i want a relay to turn on for a few seconds and then just turn off .
Getting error cause loop is repeating and it goes on turning on and off .
The codei have done is below…

#include <ESP8266WiFi.h>

//Name of the wifi network whom we are supposed to track
const char *SSID = “mr_lazy_boei”;
const char *pass = “usalusal”;

WiFiClient client;

// Relay pin number
int relay=2;
int relay3=0;

// Return RSSI(Received Signal Strength Indicator) or 0 if target SSID not found
int32_t getRSSI(const char* target_ssid) {
byte available_networks = WiFi.scanNetworks();

for (int network = 0; network < available_networks; network++) {
if (WiFi.SSID(network).compareTo(target_ssid) == 0) { //stringOne.compareTo(stringTwo) < 0
return WiFi.RSSI(network);
}

}
return 0;
}

void setup() {
Serial.begin(115200);
delay(10);

Serial.println("Connecting to ");
Serial.println(SSID);

WiFi.begin(SSID,pass);
while(WiFi.status() !=WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println(“WiFi connected”);
int32_t rssi = getRSSI(SSID);

// For debugging purpose only
Serial.print("Signal strength: ");
Serial.print(rssi);
Serial.println(“dBm”);

pinMode(relay, OUTPUT); // Initialize the relay pin as an output.
pinMode(relay3,OUTPUT);

if (rssi > (-55) && rssi != 0)
digitalWrite(relay,LOW);
delay(750);
digitalWrite(relay,HIGH);
Serial.println(“SELF ON”);
}
void loop(){

int32_t rssi = getRSSI(SSID);

// For debugging purpose only
Serial.print("Signal strength: ");
Serial.print(rssi);
Serial.println(“dBm”);

if (rssi > (-55) && rssi != 0) // if rssi is greater then -70 dbm or it’s 0 dbm, then the light will turn
{
digitalWrite(relay3, LOW);
Serial.println(“ON”);
}
if (rssi < (-55) && rssi != 0)

{
digitalWrite(relay3,HIGH);
Serial.println(“OFF”);
}
if(rssi > (-55) && rssi !=0)
{
digitalWrite(relay,LOW);
Serial.println(“RELAY ON”);
delay(750);
digitalWrite(relay,HIGH);
Serial.println(“RELAY OFF”);
}
}

ABOVE IS THE CODE I HAVE USED .
I want the relay3 to be on when the signal is strong .
And it works.
whereas i want (relay) to be on for not even a second and turn off .
But its repeating turning off and on .
Can anyone please sort me out this issue .

I am working on a project in which i use the strength of wifi signal for the relay to turn on and off .
But there is a issue when i want a relay to turn on for a few seconds and then just turn off .
Getting error cause loop is repeating and it goes on turning on and off .
The codei have done is below…

#include <ESP8266WiFi.h>

//Name of the wifi network whom we are supposed to track
const char *SSID = “mr_lazy_boei”;
const char *pass = “usalusal”;

WiFiClient client;

// Relay pin number
int relay=2;
int relay3=0;

// Return RSSI(Received Signal Strength Indicator) or 0 if target SSID not found
int32_t getRSSI(const char* target_ssid) {
byte available_networks = WiFi.scanNetworks();

for (int network = 0; network < available_networks; network++) {
if (WiFi.SSID(network).compareTo(target_ssid) == 0) { //stringOne.compareTo(stringTwo) < 0
return WiFi.RSSI(network);
}

}
return 0;
}

void setup() {
Serial.begin(115200);
delay(10);

Serial.println("Connecting to ");
Serial.println(SSID);

WiFi.begin(SSID,pass);
while(WiFi.status() !=WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println(“WiFi connected”);
int32_t rssi = getRSSI(SSID);

// For debugging purpose only
Serial.print("Signal strength: ");
Serial.print(rssi);
Serial.println(“dBm”);

pinMode(relay, OUTPUT); // Initialize the relay pin as an output.
pinMode(relay3,OUTPUT);

if (rssi > (-55) && rssi != 0)
digitalWrite(relay,LOW);
delay(750);
digitalWrite(relay,HIGH);
Serial.println(“SELF ON”);
}
void loop(){

int32_t rssi = getRSSI(SSID);

// For debugging purpose only
Serial.print("Signal strength: ");
Serial.print(rssi);
Serial.println(“dBm”);

if (rssi > (-55) && rssi != 0) // if rssi is greater then -70 dbm or it’s 0 dbm, then the light will turn
{
digitalWrite(relay3, LOW);
Serial.println(“ON”);
}
if (rssi < (-55) && rssi != 0)

{
digitalWrite(relay3,HIGH);
Serial.println(“OFF”);
}
if(rssi > (-55) && rssi !=0)
{
digitalWrite(relay,LOW);
Serial.println(“RELAY ON”);
delay(750);
digitalWrite(relay,HIGH);
Serial.println(“RELAY OFF”);
}
}

ABOVE IS THE CODE I HAVE USED .
I want the relay3 to be on when the signal is strong .
And it works.
whereas i want (relay) to be on for not even a second and turn off .
But its repeating turning off and on .
Can anyone please sort me out this issue .
Relay3 and relay are two diffrent outputs defined above in program .

if (rssi > (-55) && rssi != 0)
 digitalWrite(relay,LOW);
    delay(750);
    digitalWrite(relay,HIGH);
    Serial.println("SELF ON");

Are you maybe missing some of these {} ?

You’re certainly missing code tags.

Duplicate - reported

Oops. That code was just a test one… i am so sorry for that…!!

#include <ESP8266WiFi.h>

//Name of the wifi network whom we are supposed to track
const char *SSID = “mr_lazy_boei”;
const char *pass = “usalusal”;

WiFiClient client;

// Relay pin number
int ignition=2;
int self=0;

// Return RSSI(Received Signal Strength Indicator) or 0 if target SSID not found
int32_t getRSSI(const char* target_ssid) {
byte available_networks = WiFi.scanNetworks();

for (int network = 0; network < available_networks; network++) {
if (WiFi.SSID(network).compareTo(target_ssid) == 0) { //stringOne.compareTo(stringTwo) < 0
return WiFi.RSSI(network);
}

}
return 0;
}

void setup() {
Serial.begin(115200);
delay(10);

Serial.println("Connecting to ");
Serial.println(SSID);

WiFi.begin(SSID,pass);
while(WiFi.status() !=WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println(“WiFi connected”);

pinMode(ignition,OUTPUT);
pinMode(self,OUTPUT);
}

void loop(){

int32_t rssi = getRSSI(SSID);

// For debugging purpose only
Serial.print("Signal strength: ");
Serial.print(rssi);
Serial.println(“dBm”);

if (rssi > (-55) && rssi != 0) // if rssi is greater then -55 dbm or it’s 0 dbm, then the light will turn
{
digitalWrite(ignition, LOW);
Serial.println(“ON”);
}
else

{
digitalWrite(ignition,HIGH);
Serial.println(“OFF”);
}
if (rssi > (-55) &&rssi !=0)
{
digitalWrite(self,LOW);
delay(750);
digitalWrite(self,HIGH);
Serial.println(“SELF OFF”);

}

}

The [ relay3 ] works perfectly as i wish .
But considering the [ relay ] i dont want it to repeat again and again . i just want it to work once when the signal shows " ON " and then stop . But it keeps on repeating because of void loop .
Do you have any idea regarding this please say .

Duplicate topics merged

Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a timeout from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Sorry for that . Thank you . I am new to this so i dint know about that . Really sorry . Thankyou for your info .

Is there anyone who can look into my issue?

What do you want it to do instead of repeating?

I dont want it to repeat . I just want it tu turn on and off . Thats all… It shouldnt again get turned on and off . To make you better understand i have used ignition and self . The ignition will stay on if the wifi strength is strong . And it will turn off when wifi signal is weak .
Whereas in self when the signal is strong the self should turn on and within a second it should turn off back .
When the signal gets weak the ignition will turn off and then again when the signal gets strong self should turn on and turn off within a second… This is what i want .
If you can spare your precious time and look in my issue it would be a great favour upon me .

I just user test :
int rssi = analogRead(A0);
rssi = map(rssi, 0, 1023, -100,0);

So,don’t know is can working.

int stp;


 if (rssi > (-55) && rssi != 0) // if rssi is greater then -55 dbm or it's 0 dbm, then the light will turn  
 {
   digitalWrite(ledState, LOW);  
   Serial.println("ON"); ;
}
else

{
 digitalWrite(ledState,HIGH);
 Serial.println("OFF");
stp=0;
}
if (rssi > (-55)  &&  rssi != 0 && stp<=0)
{
  digitalWrite(led,LOW);
 delay(750);
 digitalWrite(led,HIGH);
 Serial.print("SELF OFF   ");
stp+=1;
}
}