I set the ssid and password on the phone by WiFi manager and I want to control the servo by blink app.
The code that combines the two does not work properly.
WiFi Manager Basic example (autoConnect) works properly.
The blink code (servo motor control) also works properly.
But it does not work out.
I think the connection is done in ap mode through the value input from the phone.
It seems that it does not change to station mode after connection.
The Blink app will not change online.
Upload code with each code combined. Please help me.
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Servo.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h>
#include <EEPROM.h>
char auth[] = "00000000000";
Servo servo;
int sw = 13;
int degree = 140;
BLYNK_WRITE(V3)
{
servo.write(param.asInt());
delay(300);
servo.write(140);
degree = param.asInt();
}
BLYNK_WRITE(V4)
{
servo.write(param.asInt());
delay(300);
servo.write(140);
degree = param.asInt();
}
void setup()
{
// Debug console
EEPROM.begin(512);
Serial.begin(115200);
pinMode(sw, INPUT_PULLUP);
WiFiManager wifiManager;
wifiManager.resetSettings();
wifiManager.autoConnect("NodeMCU");
Serial.println("connected...yeey :)");
Serial.printf("SSID: %s\n", WiFi.SSID().c_str()); **//Exact ssid and pass values are displayed in the serial window**
Serial.printf("PSK: %s\n", WiFi.psk().c_str());
Blynk.begin(auth, WiFi.SSID().c_str(), WiFi.psk().c_str()); **//This code seems to not work well**
servo.attach(15);
servo.write(degree);
}
void loop()
{
Blynk.run();
if (digitalRead(sw) == LOW && degree == 170) {
servo.write(110);
delay(300);
servo.write(140);
degree = 110;
delay(500);
}
else if (digitalRead(sw) == LOW && degree == 110 || degree == 140) {
servo.write(170);
delay(300);
servo.write(140);
degree = 170;
delay(500);
}
}