From 068b61e389993f01986b7d5c6f63c529792b9f5a Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Fri, 19 Jul 2019 12:33:30 +0200 Subject: [PATCH] add WiFi --- src/main.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1b1c30f..3641542 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,24 +5,34 @@ */ #include +#include +#include -// Set LED_BUILTIN if it is not defined by Arduino framework -// #define LED_BUILTIN 2 +WiFiMulti wifiMulti; void setup() { + Serial.begin(115200); + // initialize LED digital pin as an output. pinMode(LED_BUILTIN, OUTPUT); + + wifiMulti.addAP(WIFI_SSID, WIFI_PASSWD); + wifiMulti.addAP(WIFI_SSID2, WIFI_PASSWD2); + + Serial.println("Connecting Wifi..."); + if(wifiMulti.run() == WL_CONNECTED) { + Serial.println(""); + Serial.println("WiFi connected"); + Serial.println("IP address: "); + Serial.println(WiFi.localIP()); + } } void loop() { - // turn the LED on (HIGH is the voltage level) - digitalWrite(LED_BUILTIN, HIGH); - // wait for a second - delay(1000); - // turn the LED off by making the voltage LOW - digitalWrite(LED_BUILTIN, LOW); - // wait for a second - delay(1000); + if(wifiMulti.run() != WL_CONNECTED) { + Serial.println("WiFi not connected!"); + delay(1000); + } }