mDNS non funziona :S

salve a tutti

sto cercando di realizzare un propagatore su base esp-01, come gia accennato qui

la parte “hardware” sembra funzionare e ora sto scrivendo la parte software partendo da questo esempio

il programma in sè funziona, ma avendo tutti i piedini dell’ESP impegnati non posso accedere alla seriale per ottenere l’IP della pagina

ho provato allora con mDNS ma con scarsi risultati(da seriale dice che mDNS è partito ma non sono mai riuscito raggiungere la pagina dell’ESP)

ho provato allora settando l’ IP manualmente ( anche disabilitando il DHCP del router e in questo caso non collega proprio al rete) e si collega alla rete ma non con i miei parametri :S

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
 #include <OneWire.h>
#include <DallasTemperature.h>

// differisce leggermente dallo schema elettrico allegato
#define ONE_WIRE_BUS 0
#define Riscaldatore 1
// #define Pompa 2
#define LED 1  //On board LED

#include "index.h" //HTML PAGE
 

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);


IPAddress staticIP(192, 168, 1, 90); //ESP static ip
IPAddress gateway(192, 168, 1, 1);   //IP Address of your WiFi Router (Gateway)
IPAddress subnet(255, 255, 255, 0);  //Subnet mask
IPAddress dns(8, 8, 8, 8);  //DNS
 
 
const char* deviceName = "germinatoio";
//SSID and Password of your WiFi router
const char* ssid = "XDXDXDXD";
const char* password = "XDXDXDXDXD";
 
ESP8266WebServer server(80); //Server on port 80
 
//===============================================================
// This routine is executed when you open its IP in browser
//===============================================================
void handleRoot() {
 
 String s = MAIN_page; //Read HTML contents
 server.send(200, "text/html", s); //Send web page
 
}

void readT() {
  
  sensors.requestTemperatures();
  
  float tempC = sensors.getTempCByIndex(0);

  if (tempC == -127.00) {
   // Serial.println("Failed to read from DS18B20 sensor");
    //return "--";
  } else {
   // Serial.print("Temperature Celsius: ");
    //Serial.println(tempC);
  }
//  return String(tempC);
  server.send(200, "text/plane", String(tempC));
}
 

 
void handleLED() {
 String ledState = "OFF";
 String t_state = server.arg("LEDstate"); //Refer  xhttp.open("GET", "setLED?LEDstate="+led, true);
 Serial.println(t_state);
 if(t_state == "1")
 {
  digitalWrite(LED,LOW); //LED ON
  ledState = "ON"; //Feedback parameter
 }
 else
 {
  digitalWrite(LED,HIGH); //LED OFF
  ledState = "OFF"; //Feedback parameter  
 }
 
 server.send(200, "text/plane", ledState); //Send web page
}
//==============================================================
//                  SETUP
//==============================================================
void setup(void){
  Serial.begin(115200);
  sensors.begin();
  
  WiFi.begin(ssid, password); 
  
  //Onboard LED port Direction output
  pinMode(LED,OUTPUT); 
  
 
  Serial.println("");
  WiFi.disconnect(); 
  
  WiFi.hostname(deviceName);      // DHCP Hostname (useful for finding device for static lease)
  WiFi.config(staticIP, subnet, gateway, dns);
  WiFi.begin(ssid, password);
 
  WiFi.mode(WIFI_STA);     //Connect to your WiFi router
  Serial.println("");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
 
  //If connection successful show IP address in serial monitor
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());  //IP address assigned to your ESP

  if(WiFi.status() == WL_CONNECTED) //If WiFi connected to hot spot then start mDNS
  {
    if (MDNS.begin("esp8266")) {  //Start mDNS with name esp8266
      Serial.println("MDNS started");
    }
  }
  server.on("/", handleRoot);      //Which routine to handle at root location. This is display page
  server.on("/setLED", handleLED);
  server.on("/readT", readT);
 
  server.begin();                  //Start server
  Serial.println("HTTP server started");
}
//==============================================================
//                     LOOP
//==============================================================
void loop(void){
  server.handleClient();          //Handle client requests
}

e il codice HTML

const char MAIN_page[] PROGMEM = R"=====(
<!DOCTYPE html>
<html>
<body>
 
<div id="demo">
<h1>Germinatoio V 1.0</h1>
	<button type="button" onclick="sendData(1)">Pompa ON</button>
	<button type="button" onclick="sendData(0)">Pompa OFF</button>

</div>
 
<div>
	La Temperatura è: <span id="ADCValue">0</span>C

    la pompa é: <span id="LEDState">NA</span>
</div>
<script>
function sendData(led) {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("LEDState").innerHTML =
      this.responseText;
    }
  };
  xhttp.open("GET", "setLED?LEDstate="+led, true);
  xhttp.send();
}
 
setInterval(function() {
  // Call a function repetatively with 2 Second interval
  readT();
}, 2000); //2000mSeconds update rate
 
function readT() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("ADCValue").innerHTML =
      this.responseText;
    }
  };
  xhttp.open("GET", "readT", true);
  xhttp.send();
}
</script>

</body>
</html>
)=====";

idee???

in allegato lo schema elettrico

germiV2ele.pdf (13.8 KB)