Hello,
first off, I'm not a native English speaker, yet I will try my best.
I'm trying to control the on-board LED of the ESP8266 board with the blynk app (Switch, on/off via app-button).
So far I linked the App with my ESP8266 via wifi, using an external wifi.
I also created an Access Point so I could connect my Smartphone with the EspAP-wifi created by the ESP8266.
Now I want to combine these two sketches so the ESP8266 will create an Access Point which my Smartphone can connect to. The Blynk app should be running on the connected smartphone so I can turn the LED (pin D0) on the ESP8266 on and off using the Blynk app connected.
As I tried to combine the two example codes, I got no error message showing, but the EspAP wifi didn't showed as well.
This is my first time using the forum, please ask questions or tell me if you need further information.
Thank you!
I got the below code as example from somewhere, a great example of how to connect your ESP to WiFi, then allow you to connect to it through your browser, and switch on and off an LED connected to, in this case, D5. Fill in your SSID and WiFi password in line 3 and 4, and change ledPin as needed. Set it to 2 (D4 on NodeMCU) for the internal LED.
#include <ESP8266WiFi.h>
const char* ssid = "ssid";
const char* password = "password";
int ledPin = D5;
WiFiServer server(80);
void setup() {
Serial.begin(9600);
delay(10);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
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.print("Use this URL : ");
Serial.print("http://");
Serial.print(WiFi.localIP());
Serial.println("/");
}
void loop() {
// 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 request = client.readStringUntil('\r');
Serial.println(request);
client.flush();
// Match the request
int value = LOW;
if (request.indexOf("/LED=ON") != -1) {
digitalWrite(ledPin, HIGH);
value = HIGH;
}
if (request.indexOf("/LED=OFF") != -1){
digitalWrite(ledPin, LOW);
value = LOW;
}
// Return the response
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println(""); // do not forget this one
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.print("Led pin is now: ");
if(value == HIGH) {
client.print("On");
} else {
client.print("Off");
}
client.println("
");
client.println("Click <a href=\"/LED=ON\">here</a> turn the LED on pin 5 ON
");
client.println("Click <a href=\"/LED=OFF\">here</a> turn the LED on pin 5 OFF
");
client.println("</html>");
delay(1);
Serial.println("Client disconnected");
Serial.println("");
}
Kjay9558:
Hello,
first off, I'm not a native English speaker, yet I will try my best.
I'm trying to control the on-board LED of the ESP8266 board with the blynk app (Switch, on/off via app-button).
So far I linked the App with my ESP8266 via wifi, using an external wifi.
I also created an Access Point so I could connect my Smartphone with the EspAP-wifi created by the ESP8266.
Now I want to combine these two sketches so the ESP8266 will create an Access Point which my Smartphone can connect to. The Blynk app should be running on the connected smartphone so I can turn the LED (pin D0) on the ESP8266 on and off using the Blynk app connected.
As I tried to combine the two example codes, I got no error message showing, but the EspAP wifi didn't showed as well.
This is my first time using the forum, please ask questions or tell me if you need further information.
Thank you!
If you want help you need to post your code. No one is going to help you otherwise. We cannot guess what you did wrong.
Lennyz1988:
If you want help you need to post your code. No one is going to help you otherwise. We cannot guess what you did wrong.
I'm sorry, here is my code:
/*Inclusions: Wifi AP*/
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
/* Set these to your desired credentials.
WIFI AP SETTINGS*/
const char *ssid = "myAP";
//const char *password = "abc213";
/*Test Message AP*/
ESP8266WebServer server(80);
/* Just a little test message. Go to http://192.168.4.1 in a web browser
* connected to this access point to see it.
*/
void handleRoot() {
server.send(200, "text/html", "<h1>You are connected to the Accesspoint</h1>");
}
/*Blynk inclusions*/
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "0c4b918647354a1bb1b8e5fcefed456d";
/*// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";*/
char pass[] = "abc213";
void setup() {
delay(1000);
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
Serial.println();
Serial.print("Configuring access point...");
/* You can remove the password parameter if you want the AP to be open. */
WiFi.softAP(ssid/*, password*/);
IPAddress myIP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(myIP);
server.on("/", handleRoot);
server.begin();
Serial.println("HTTP server started");
}
void loop() {
server.handleClient();
Blynk.run();
}
It looks like you should get an access point called MyAP.
Do you see any access point appear?
What's the exact output on your Serial console?
Kjay9558:
I'm sorry, here is my code:
Here is the manual for using Blynk:
You cannot use "Blynk.begin()" as it will interfere with the code for the AP. You need to use Blynk.config().
Thank you, found another method to get my desired outcome, too easy to think off in the first place actually 
I set up an wifi hotspot via my smartphone and connected the ESP to that.
The Blynk manual will become handy for future projects nonetheless.
Thanks to everyone who replied.
Thread closed I'd say 