I am using Airport Extreme Base Station as a WLAN router. I wanted to add my Arduino Uno WiFi rev 2 units to this local area network. When the router is connected to internet via ethernet cable to router from the wall, the Arduinos using WiFiNINA establish connection reliably.
However, when the router is disconnected from the internet to create a WLAN, my Arduinos keep repeating "Attempting to connect to SSID: XXXXXX", and never establishes connection. I am using WiFiUdpSendReceiveString example. I want to have Arduinos communicating in local network environment, so that latencies are faster and more reliable.
I am a noob in networking, and searched a lot of information. Things I have tried:
I tested the local area connection using two computers, and they successfully send and receive udp messages, so the WLAN itself isn't the problem.
The computers get self-assigned ip when it's connected to WLAN, so I suspected maybe WiFiNINA had trouble retrieving an IP address? So I tried assigning static ip, using WiFi.config(ip), but unsuccessful.
I tried putting WiFi.disconnect(); before WiFi.config(ip), since apparently this is a work-around for some people, but unsuccessful.
Please help! This is very important to me.
#include <SPI.h>
#include <WiFiNINA.h>
#include <WiFiUdp.h>
int status = WL_IDLE_STATUS;
#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)
unsigned int localPort = 2390; // local port to listen on
unsigned int sendPort = 2391; // local port to send msg
char packetBuffer[255]; //buffer to hold incoming packet
char ReplyBuffer[] = "acknowledged"; // a string to send back
IPAddress ip(192, 168, 0, 177);
WiFiUDP Udp;
void setup() {
//Initialize serial and wait for port to open:
Serial.begin(9600);
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();
if (fv < "1.0.0") {
Serial.println("Please upgrade the firmware");
}
//WiFi.end();
//WiFi.disconnect();
WiFi.config(ip);
// attempt to connect to Wifi network:
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
//Serial.println(status);
// wait 10 seconds for connection:
delay(10000);
}
Serial.println("Connected to wifi");
printWifiStatus();
Serial.println("\nStarting connection to server...");
// if you get a connection, report back via serial:
Udp.begin(localPort);
// These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
// Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
clock_prescale_set(clock_div_1);
#endif
// END of Trinket-specific code.
pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
blinkLights();
}
void loop() {
...
}
I am using Airport Extreme Base Station as a WLAN router. I wanted to add my Arduino Uno WiFi rev 2 units to this local area network. When the router is connected to internet via ethernet cable to router from the wall, the Arduinos using WiFiNINA establish connection reliably.
However, when the router is disconnected from the internet to create a WLAN, my Arduinos keep repeating "Attempting to connect to SSID: XXXXXX", and never establishes connection. I am using WiFiUdpSendReceiveString example. I want to have Arduinos communicating in local network environment, so that latencies are faster and more reliable.
I am a noob in networking, and searched a lot of information. Things I have tried:
WiFi.config(ip)
, but unsuccessful.WiFi.disconnect();
beforeWiFi.config(ip)
, since apparently this is a work-around for some people, but unsuccessful.Please help! This is very important to me.