0

I want to turn my Arduino MKR1000 into an Access Point. My code is the following:

#include <SPI.h>
#include <WiFi101.h>
#define PubNub_BASE_CLIENT WiFiClient
#include <PubNub.h>
WiFiServer server(80);
char ssid[] = "MKR1000";
int status = WL_IDLE_STATUS;
void setup() {
 delay(1000);
 Serial.begin(9600);
 Serial.print("Creating access point named: ");
 Serial.println(ssid);
 if (WiFi.beginAP(ssid) != WL_CONNECTED) {
 Serial.println("Creating access point failed");
 while (true);
 }
 server.begin();
 printStatus();
}
void loop() {
}
void printStatus() {
 Serial.print("SSID: ");
 Serial.println(WiFi.SSID());
 IPAddress ip = WiFi.localIP();
 Serial.print("IP Address: ");
 Serial.println(ip);
 long rssi = WiFi.RSSI();
 Serial.print("signal strength (RSSI):");
 Serial.print(rssi);
 Serial.println(" dBm");
 Serial.print("To connect, join the network and open a browser to http://");
 Serial.println(ip);
}

After uploading this, in the serial monitor I get this:

Creating access point named: MKR1000
Creating access point failed

I'm new to this so I really don't know what's the problem. I hope someone knows what's going on.
Thank you in advance.

asked Apr 4, 2018 at 16:14
2
  • Hopefully you mean you want the board to function in AP mode for connected clients to exchange messages specifically with it. Trying to actually make it a wifi access point in the sense of a wifi router is not a viable idea. Commented Apr 4, 2018 at 16:58
  • Yeah sorry, that's what I meant. Commented Apr 6, 2018 at 14:50

1 Answer 1

0

I found this reference for Wifi.beginAP() in the Wifi101 library, which I hope is the correct one - apologies if it's not.

It says that beginAP() returns either WL_AP_LISTENING or WL_CONNECT_FAILED, so checking for WL_CONNECTED is not sensible.

Try this:

if (WiFi.beginAP(ssid) != WL_AP_LISTENING) {
 Serial.println("Creating access point failed");
 while (true);
}
answered Apr 4, 2018 at 16:41
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.