Moderator: igrr
#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");
}
}
}