Skip to content

Instantly share code, notes, and snippets.

@pudelosha
Created June 26, 2017 18:50
Show Gist options
  • Save pudelosha/f84de35698b59b3526483f60a1fb2be7 to your computer and use it in GitHub Desktop.
Save pudelosha/f84de35698b59b3526483f60a1fb2be7 to your computer and use it in GitHub Desktop.
Wemos D1 R2 WiFi directly controlled from Android application
// based on YouTube tutorial posted by Youtechnoid
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
const char *ssid = "ArduinoGreen";
const char *pass = "LGBTQWERTY";
String command;
ESP8266WebServer server(80);
void respond(){
server.send(200,"text/html","<h1>Hello ArduinoGreen</h1>");
}
void setup() {
Serial.begin(9600);
pinMode(BUILTIN_LED,OUTPUT);
Serial.println(" Initialising");
WiFi.softAP(ssid,pass);
IPAddress IPserver = WiFi.softAPIP();
Serial.println(" IP address server : ");
Serial.println(IPserver);
server.on("/",respond);
server.begin();
server.onNotFound([](){
command=server.uri();
server.send(200,"text/plain",command);
});
}
void loop() {
server.handleClient();
if(command.equals("/turnoff")){
digitalWrite(BUILTIN_LED,HIGH);
}
if(command.equals("/turnon")){
digitalWrite(BUILTIN_LED,LOW);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment