Change sketch to access point
Posted: Tue Sep 19, 2017 11:35 am
Hi there,
For some reason I can't find out how to edit a sketch so the ESP01 that I use behaves like an access point.
I found a sketch that works fine when connected to my router.
But I want this ESP project to work for a long time, and don't want it to edit when something on my router changes.
My idea was to make the ESP an access point so it will work for a long time without interference..
I will cut a piece of the sketch, my only question is what do I have to edit to accomplish what I want.
For some reason I can't find out how to edit a sketch so the ESP01 that I use behaves like an access point.
I found a sketch that works fine when connected to my router.
But I want this ESP project to work for a long time, and don't want it to edit when something on my router changes.
My idea was to make the ESP an access point so it will work for a long time without interference..
I will cut a piece of the sketch, my only question is what do I have to edit to accomplish what I want.
Code: Select all
#include <DHT.h>
#include <DHT_U.h>
#include <ESP8266WiFi.h>
#include "espipswitchtoggle.h"
const char* ssid = "MySSID";
const char* password = "MyPass";
// 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.hostname("verw");
WiFi.begin(ssid, password);
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);