Skip to content

Instantly share code, notes, and snippets.

@M4GNV5
Created February 11, 2018 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save M4GNV5/d7dd6d920a1439c1de056540e58dcac9 to your computer and use it in GitHub Desktop.
Save M4GNV5/d7dd6d920a1439c1de056540e58dcac9 to your computer and use it in GitHub Desktop.
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266mDNS.h>
#define WIFI_SSID "<removed>"
#define WIFI_PSK "<removed>"
#define GPIO_LED 13
#define GPIO_RELAY 12
uint8_t lamp = LOW;
uint8_t relais = LOW;
void switchLed()
{
if(lamp == LOW)
{
digitalWrite(GPIO_LED, HIGH);
lamp = HIGH;
}
else
{
digitalWrite(GPIO_LED, LOW);
lamp = LOW;
}
}
void setup(void)
{
Serial.begin(115200);
delay(5000);
Serial.println("");
Serial.setDebugOutput(true);
WiFi.persistent(false);
WiFi.mode(WIFI_OFF);
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PSK);
WiFi.printDiag(Serial);
pinMode(GPIO_LED, OUTPUT);
digitalWrite(GPIO_LED, LOW);
pinMode(GPIO_RELAY, OUTPUT);
digitalWrite(GPIO_RELAY, LOW);
Serial.print("MAC-Address: ");
Serial.println(WiFi.macAddress());
Serial.print("\nConnecting to WiFi ");
Serial.println(WIFI_SSID);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
switchLed();
Serial.print(".");
}
Serial.println("Connected");
Serial.print("IP-Address: ");
Serial.println(WiFi.localIP());
}
void loop(void)
{
if(Serial.available())
{
if(Serial.find("\n"))
switchLed();
}
delay(50);
}
bcn 0
del if1
usl
mode : null
mode : sta(<removed>)
add if0
Mode: STA
PHY mode: N
Channel: 1
AP id: 0
Status: 1
Auto connect: 1
SSID (6): <removed>
Passphrase (11): <removed>
BSSID set: 0
MAC-Address: <removed>
Connecting to WiFi <removed>
....scandone
state: 0 -> 2 (b0)
.state: 2 -> 0 (0)
..reconnect
....scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (0)
..reconnect
....scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (0)
..reconnect
....scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (0)
..reconnect
.....scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (0)
..reconnect
....scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (0)
..reconnect
....scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (0)
..reconnect
....scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (0)
..reconnect
.....scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (0)
..reconnect
....scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (0)
..reconnect
....scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (0)
..reconnect
.....scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (0)
..reconnect
....scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (0)
..reconnect
....scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (0)
..reconnect
....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment