Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By MrMU
#70120
martinayotte wrote:The example above is pretty straight forward.
Instead of doing WiFi.begin() and WiFi.status(), simply do the following as in the example :
Code: Select allWiFi.softAP(ssid, password);
IPAddress myIP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(myIP);


Thank you again,

Now I have following, but there doesn't seem to appear an SSID with the name "MySSID" to be around:

Code: Select all#include <DHT.h>
#include <DHT_U.h>

#include <ESP8266WiFi.h>
#include "espipswitchtoggle.h"

const char* ssid = "MySSID";
const char* password = "Pass";

// Create an instance of the server
// specify the port to listen on as an argument
WiFiServer server(80);

unsigned long timer = 0;
unsigned long firstMillis = 0;
void setup() {
  Serial.begin(115200);
  delay(10);
  pinMode(0, OUTPUT);
  pinMode(2,INPUT);
  pinMode(2, INPUT_PULLUP);   
 
  // Connect to WiFi network
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.softAP(ssid, password);
  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);
 
 
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
   
  }
  Serial.println("");
  Serial.println("WiFi connected");
 
  // Start the server
  server.begin();
  Serial.println("Server started");

  // Print the IP address
  Serial.println(WiFi.localIP());
}

void loop() {
unsigned long currentMillis = millis();
if(currentMillis - firstMillis > (timer*60000)) { 
  digitalWrite(0, 0);
  firstMillis = currentMillis;
}
  // Check if a client has connected
  WiFiClient client = server.available();
  if (!client) {
    return;
  }
 
  // Wait until the client sends some data
  Serial.println("new client");
  while(!client.available()){
    delay(1);
  }

  // Read the first line of the request
  String command1 = client.readStringUntil('/');
  String command = client.readStringUntil('/');
  Serial.println(command);

if (command == "12") {
  if(digitalRead(0))
  {
    digitalWrite(0, 0);
    client.print(F("0,0"));
  }
  else
  {
    digitalWrite(0, 1);
    client.print(F("0,1"));
User avatar
By MrMU
#70159
martinayotte wrote:
const char* password = "Pass";

Valid password can only be minimum of 8 characters and maximum 64 ...


Thank you this works!!

Can I ask one more thing?
Now I have the server running on 192.168.4.1 but is there a way to "name" this page (for instance: "ESPserver1"), so I can enter this in the URL bar of a browser, OR choose on which IP address the page is showed? (let's say to run on 192.168.100.100)?

This because I don't want to change the sketch everytime something in the neighbourhood changes.
Again thanks a lot!!
User avatar
By martinayotte
#70200 You can add a mDNS service to your sketch, then you can use http://myesp1.local for the URL in browser.
Check the example there : https://github.com/esp8266/Arduino/tree ... SP8266mDNS
Beware that on Linux you need to have avahi-utils installed, and on Windows there is Bonjour that need to be installed, but the l've never use Windows ...
If you wish to change the ESP address, that could be done using the WiFi.softAPConfig()