Hi, I have the code below which doesn't compile due to this error:
/private/var/folders/fr/z593mgld597gjz_k30hwlx8w0000gn/T/.arduinoIDE-unsaved2025128-1803-1x6mkvf.m7wx/sketch_feb28a/sketch_feb28a.ino:26:24: error: 'WL_NO_MODULE' was not declared in this scope
26 | if (WiFi.status() == WL_NO_MODULE) {
#include <WiFi.h>
#define SECRET_SSID ""
#define SECRET_PASS ""
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 status = WL_IDLE_STATUS; // the WiFi radio's status
char server[] = "192.168.1.165";
WiFiClient client;
void setup() {
delay(5000);
Serial.begin(9600);
while (!Serial);
delay(3000);
WiFi.begin(ssid, pass);
if (WiFi.status() == WL_NO_MODULE) {
Serial.println("Communication with WiFi module failed!");
while (true);
}
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to WPA SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network:
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
Serial.print("You're connected to the network");
printWifiData();
}
}
void loop() {
Serial.println("test");
if (client.connect(server, 80)) {
client.println("POST /TEMP");
client.println("Host: 192.168.1.165");
client.println("Connection: close");
client.println("Temp: test");
}
}
void printWifiData() {
// print your board's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
Serial.println(ip);
// print your MAC address:
byte mac[6];
WiFi.macAddress(Mac);
Serial.print("MAC address: ");
printMacAddress(Mac);
}
void printMacAddress(byte mac[]) {
for (int i = 5; i >= 0; i--) {
if (mac[i] < 16) {
Serial.print("0");
}
Serial.print(mac[i], HEX);
if (i > 0) {
Serial.print(":");
}
}
Serial.println();
}
How can I resolve this? Thank you.