Can't get simple GET request working on Wifi Rev2


I hope I’m missing something dumb and simple here. I used the Wifinina Wifiwebclient example to post a GET request on the local network. Basically just modified the server address and GET request. However, even though it seems to connect (“connected to server”), the GET request doesn’t seem to get through (the software on the target machine is not responding to it). Using the same URL in a browser works fine.

Here’s the code:

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

#include "arduino_secrets.h" 
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID;        // your network SSID (name)
char pass[] = SECRET_PASS;    // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;            // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
IPAddress server(192,168,1,93);  // numeric IP for Google (no DNS)
//char server[] = "";    // name address for Google (using DNS)

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
WiFiClient client;

void setup() {
  //Initialize serial and wait for port to open:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only

  // check for the WiFi module:
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);

  String fv = WiFi.firmwareVersion();
    Serial.println("Please upgrade the firmware");

  // attempt to connect to Wifi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
  Serial.println("Connected to wifi");

  Serial.println("\nStarting connection to server...");
  // if you get a connection, report back via serial:
  if (client.connect(server, 80)) {
    Serial.println("connected to server");
    // Make a HTTP request:
    client.println("GET /JSON?request=runevent&group=SECURITY&name=PerimeterHeartbeat HTTP/1.1");
    client.println("Host: localhost");
    client.println("Connection: close");

void loop() {
  // if there are incoming bytes available
  // from the server, read them and print them:
  while (client.available()) {
    char c =;

  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println("disconnecting from server.");

    // do nothing forevermore:
    while (true);

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");

  // print your board's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.println(" dBm");

What stupid mistake am I making?


Hey! I'm taking a look at your code and can't seem to connect to that IP...where did you get it? From a quick google it doesn't look like that is in range of any of the IP addresses that uses.

(source: The IP Addresses Used by Google)

A few more thoughts:

  1. Move your connection to the client and sending of the message to the loop instead of the setup

  2. Your host when connecting using client.connect should be the same host you include in your GET message string

  3. If like it is said in the comments you're trying to use as the host, you can just use the string "" instead of trying to use any sort of IP