Last active
November 18, 2019 19:38
-
-
Save vlazar-/5352ba72b87c4159c56459f7e09b4486 to your computer and use it in GitHub Desktop.
MKR1000 / WiFIi01 Utils
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <WiFi101.h> | |
void handleWifiConnection() { | |
while ( WiFi.status() != WL_CONNECTED) { | |
Serial.print("### Wifi Connection - Attempt SSID: "); | |
Serial.println(ssid); | |
WiFi.begin(ssid, pass); | |
delay(5000); | |
} | |
Serial.print("### SSID: "); | |
Serial.println(WiFi.SSID()); | |
Serial.print("### IP Address: "); | |
IPAddress ip = WiFi.localIP(); | |
Serial.println(ip); | |
Serial.print("### signal strength (RSSI):"); | |
Serial.print(WiFi.RSSI()); | |
Serial.println(" dBm"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SPI.h> | |
#include <WiFi101.h> | |
#include "secrets.h" | |
IPAddress google(172, 217, 23, 68); | |
WiFiClient client; | |
void setup() { | |
Serial.begin(9600); | |
handleWifiConnection(); | |
if (client.connect(google, 80)) { | |
Serial.println("### Connected to Google Server"); | |
client.println("GET /search?q=mik+cakovec HTTP/1.0"); | |
client.println("Host: www.google.com"); | |
client.println("Connection: close"); | |
client.println(); | |
} | |
Serial.println("### Response from Google"); | |
} | |
void loop() { | |
while (client.available()) { | |
char c = client.read(); | |
Serial.write(c); | |
} | |
if (!client.connected()) { | |
Serial.println(); | |
while (true); | |
} | |
} | |
void handleWifiConnection() { | |
while ( WiFi.status() != WL_CONNECTED) { | |
Serial.print("### Wifi Connection - Attempt SSID: "); | |
Serial.println(ssid); | |
WiFi.begin(ssid, pass); | |
delay(5000); | |
} | |
Serial.print("### SSID: "); | |
Serial.println(WiFi.SSID()); | |
Serial.print("### IP Address: "); | |
IPAddress ip = WiFi.localIP(); | |
Serial.println(ip); | |
Serial.print("### signal strength (RSSI):"); | |
Serial.print(WiFi.RSSI()); | |
Serial.println(" dBm"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment