Skip to content

Instantly share code, notes, and snippets.

@vlazar-
Last active November 18, 2019 19:38
Show Gist options
  • Save vlazar-/5352ba72b87c4159c56459f7e09b4486 to your computer and use it in GitHub Desktop.
Save vlazar-/5352ba72b87c4159c56459f7e09b4486 to your computer and use it in GitHub Desktop.
MKR1000 / WiFIi01 Utils
#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");
}
#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