The use of the ESP8266 in the world of IoT

User avatar
By DrBwts
#82112 Hi I have a Wemos R1 board & am trying to connect to it from an Android tablet via the WiFi router.

Both the tablet & the Wemos can see the WiFi.

The Wemos echoes its IP via the serial monitor - 192.168.1.84

I then enter this into the Android app & attempt to send a series of stings to turn an LED on or off but keep getting the following exception: W/System.err: java.net.ConnectException: failed to connect to /192.168.1.84 (port 80): connect failed: EHOSTUNREACH (No route to host)

I then tried to ping the Wemos but there is a 0 success rate.

Both devices show up as connected when I check he router's homepage

My Arduino code,

Code: Select all#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

const char* ssid = "SKYNET";
const char* password = "nohonestlythisreallyismypasswrd";

ESP8266WebServer server(80);

void offLED(){
  String message = "Off LED";
  server.send(200, "text/plain", message);
  digitalWrite(BUILTIN_LED, LOW);  // turn on LED with voltage HIGH
  Serial.print("off\n");
}

void onLED(){
  String message = {"On LED"};
  server.send(200, "text/plain", message);
  digitalWrite(BUILTIN_LED, HIGH);  // turn on LED with voltage HIGH
  Serial.print("on\n");
}

void connection(){
  String message = {"On LED"};
  server.send(200, "text/plain", message);
  digitalWrite(BUILTIN_LED, HIGH);  // turn on LED with voltage HIGH
}

void setup(void){ 
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  Serial.println("");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  Serial.print("MAC address: ");
  Serial.println(WiFi.macAddress());
 
  pinMode(BUILTIN_LED, OUTPUT); // Onboard LED
  server.on("/offLED", offLED);
  server.on("/onLED", onLED);
  server.on("/", connection);

  server.begin();
  Serial.println("HTTP server started");
}

void loop(void){
  server.handleClient();


Is there something obvious I'm missing?