Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By derek bernsen
#38730 It's working now as far as I have tested.

Code: Select all#include <ESP8266WiFi.h>
#include <SPI.h> //Not sure if needed for serial printing.
const char* ssid     = "dd-wrt_vap";
const char* password = "";

void setup(){
     Serial.begin(115200);
     pinMode(2, OUTPUT);
     digitalWrite(2, HIGH);
     Serial.println("OPTO OFF");
     WiFi.mode(WIFI_STA);
     WiFi.begin(ssid, password);
}

 void loop() {
   
    if (WiFi.status() != WL_CONNECTED) {
    Serial.println("Couldn't get a wifi connection");
    digitalWrite(2, HIGH);
    Serial.println("OPTO OFF");
   
    }
  else {

  long rssi = WiFi.RSSI();
  Serial.print(rssi);
   
  if (rssi > -80 && rssi < 0) {
   digitalWrite(2, LOW);
   Serial.println("OPTO ON");
   }
   
  if (rssi < -80) {
   digitalWrite(2, HIGH);
   Serial.println("OPTO OFF");
   
  }
  }
 }