About Access Point Application

Hello,
I'm using Mega ADK+WiFi Shield for my application. You know, this programming including this codes;

char ssid[] = "Network_name";
char pass[] = "password";
int keyIndex = 0;

In this way, Arduino boards can be connect to my home WiFi network. It's taking automatic IP from my network. But I don't want this. Iwant, this system must be work like Access Point. So, I can write any IP to the codes. Is that possible? If yes, can you send any example codes please? Thanks.

notrino:
I'm using Mega ADK+WiFi Shield

Which WiFi Shield is it. You can post a link to the product page.

notrino:
Iwant, this system must be work like Access Point. So, I can write any IP to the codes.

It's not clear what you mean by that. Are you wanting the Arduino to provide an access point (AP) initially, which serves a configuration web page where the user can set the IP address for connection to the network, or are you wanting to always run the Arduino as an AP and never connect to the external network?

Hello Thank you,

I'm using this WiFi Shield; https://store.arduino.cc/usa/arduino-wifi-shield

I want to both of them: Sometimes I can use option-1, sometimes I can use option-2

  1. Run the Arduino as an AP and never connect to the external network.
  2. Serves a configuration web page where the user can set the IP address for connection to the network.

For example, my system codes like this; (temperature monitoring)

#include <SPI.h>                                     
#include <WiFi.h>

float sicaklik;                                     
const int sicaklik_pin=A0;

char ssid[] = "Network_name";                
char pass[] = "password";   
int keyIndex = 0;     

 int status = WL_IDLE_STATUS;                     

WiFiServer server(80);                               

void setup() {
Serial.begin(9600);                                  
  while (!Serial) {
    ; 
  }
  
if (WiFi.status() == WL_NO_SHIELD) {                
    Serial.println("WiFi shield not present");      
    while (true);
  }

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

  
  server.begin(); 
printWifiStatus();
}

void olcum()                                            
{
sicaklik=analogRead(sicaklik_pin);
sicaklik=sicaklik*0.48828125;
delay(1000);
}

void loop() {

  olcum();
                                            
   
WiFiClient client = server.available();               
  if (client) {
    Serial.println("new client");
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        if (c == '\n' && currentLineIsBlank) {       
          client.println("HTTP/1.1 200 OK");          
          client.println("Content-Type: text/html");
          client.println("Connection: close"); 
          client.println("Refresh: 10");               
          client.println();
          client.println("<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>");
          client.println("<html xmlns=http://www.w3.org/1999/xhtml lang=tr-TR>");
          client.println("<head profile=http://gmpg.org/xfn/11>");
          

client.println("<head>");
client.println("<meta http-equiv=Content-Type content=text/html; charset=UTF-8 />");
client.println("</head>");

client.println("<body>");
client.println("<div>");
client.println("<span>Ortam Sicaklik Degeri (*C)</span></div>");
client.println("<div><span>");
client.println(sicaklik);
client.println("</span></div>");
client.println("</body></html>");
   
          break;
        }
        if (c == '\n') {
         
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
       
          currentLineIsBlank = false;
        }
      }
    }
    
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disconnected");
  }
}
void printWifiStatus() {                             
 
  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");
}

Wow, we don't see the OG Arduino WiFi Shield much anymore. I'm not familiar with that hardware so I can't answer your question. Hopefully, someone else here has experience with it.

There is a popular library for ESP8266 that does (2). Although you won't be able to use it directly with your WiFi Shield, the code might provide a helpful reference:

The ESP8266WiFi library is based loosely on the API of the Arduino WiFi library, but with some necessary differences. So your code is likely to look fairly similar.

Ok,
Thanks a lot for your support.

You're welcome. I hope I was able to be of some assistance.