Arduino Uno with WiFi Basic Setup

Arduino Uno WiFi Rev 2 Board allows you to communicate with an Arduino over TCP/IP 4 WiFi networks.

Note: Make sure to select the Arduino Uno WiFi Rev2 board under Tools -> Board

Arduino WiFi Rev 2 – https://store.arduino.cc/usa/arduino-uno-wifi-rev2

#include <SPI.h>
#include <WiFiNINA.h>

char ssid[] = "test";
char pass[] = "";
int keyIndex = 0;

int status = WL_IDLE_STATUS;
WiFiServer server(80);

void setup() {
  Serial.begin(9600);

  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to Network named: ");
    Serial.println(ssid);
    status = WiFi.begin(ssid, pass);
    delay(10000);
  }
  server.begin();

  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);
}

void loop() {
  WiFiClient client = server.available();   
  if (client) {                             
    Serial.println("new client");           
    String currentLine = "";                
    while (client.connected()) {            
      if (client.available()) {             
        char c = client.read();             
        Serial.write(c);                    
        if (c == '\n') {                    

          if (currentLine.length() == 0) {

            client.println("Hello World");

            break;
          } else {
            currentLine = "";
          }
        } else if (c != '\r') {
          currentLine += c;
        }
      }
    }

    client.stop();
    Serial.println("client disonnected");
  }
}

2 Comments

  1. I am getting a “Site cannot be reached.”

    Serial Monitor shows:

    14:47:02.016 -> Attempting to connect to Network named: UWGuest
    14:47:14.421 -> SSID: UWGuest
    14:47:14.421 -> IP Address: 172.27.137.171

    When I type in a browser 172.27.137.171 I get this error
    Site cannot be reached

Leave a Reply