D1 Mini / ESP8266 - Toasted ?

Hello Guys,

I just recently started working with arduino and had to get the D1 Mini for a project. Also a KY-190 Relay.
With some simple test and wires everything worked fine. I wanted to test it while mounted on a platine so I got a simple one wired it up and it worked. Then I changed to code to:

/*********
  Rui Santos
  Complete project details at https://randomnerdtutorials.com  
*********/

// Load Wi-Fi library
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h>

// Replace with your network credentials
const char* ssid     = "####";
const char* password = "####";

// Set web server port number to 80
AsyncWebServer  server(80);

// Variable to store the HTTP request
String header;

// Auxiliar variables to store the current output state
String output8State = "off";


// Assign output variables to GPIO pins
//D0  GPIO8
//D1  GPIO5
//D2  GPIO4
//D3  GPIO0
//D4  GPIO2
//D5  GPIO14
//D6  GPIO12
//D7  GPIO13
//D8  GPIO15
const int output8 = 15;   // IO for the mechanical test station

const char* PARAM_INPUT_1 = "output";
const char* PARAM_INPUT_2 = "state";


const char index_html[] PROGMEM = R"rawliteral(
<!DOCTYPE HTML><html>
<head>
  <title>ESP Web Server</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" href="data:,">
  <style>
    html {font-family: Arial; display: inline-block; text-align: center;}
    h2 {font-size: 3.0rem;}
    p {font-size: 3.0rem;}
    body {max-width: 600px; margin:0px auto; padding-bottom: 25px;}
    .switch {position: relative; display: inline-block; width: 120px; height: 68px} 
    .switch input {display: none}
    .slider {position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; border-radius: 6px}
    .slider:before {position: absolute; content: ""; height: 52px; width: 52px; left: 8px; bottom: 8px; background-color: #fff; -webkit-transition: .4s; transition: .4s; border-radius: 3px}
    input:checked+.slider {background-color: #b30000}
    input:checked+.slider:before {-webkit-transform: translateX(52px); -ms-transform: translateX(52px); transform: translateX(52px)}
  </style>
</head>
<body>
  <h2>ESP Web Server</h2>
  %BUTTONPLACEHOLDER%
<script>function toggleCheckbox(element) {
  var xhr = new XMLHttpRequest();
  if(element.checked){ xhr.open("GET", "/update?output="+element.id+"&state=1", true); }
  else { xhr.open("GET", "/update?output="+element.id+"&state=0", true); }
  xhr.send();
}
</script>
</body>
</html>
)rawliteral";


// Replaces placeholder with button section in your web page
String processor(const String& var){
  //Serial.println(var);
  if(var == "BUTTONPLACEHOLDER"){
    String buttons = "";
    buttons += "<h4>Output - GPIO 2</h4><label class=\"switch\"><input type=\"checkbox\" onchange=\"toggleCheckbox(this)\" id=\"2\" " + outputState(output8) + "><span class=\"slider\"></span></label>";
    return buttons;
  }
  return String();
}

String outputState(int output){
  if(digitalRead(output)){
    return "checked";
  }
  else {
    return "";
  }
}


void setup(){
  // Serial port for debugging purposes
  Serial.begin(115200);

  pinMode(output8, OUTPUT);
  digitalWrite(output8, LOW);
  
  // Connect to Wi-Fi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi..");
  }

  // Print ESP Local IP Address
  Serial.println(WiFi.localIP());

  // Route for root / web page
  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send_P(200, "text/html", index_html, processor);
  });

  // Send a GET request to <ESP_IP>/update?output=<inputMessage1>&state=<inputMessage2>
  server.on("/update", HTTP_GET, [] (AsyncWebServerRequest *request) {
    String inputMessage1;
    String inputMessage2;
    // GET input1 value on <ESP_IP>/update?output=<inputMessage1>&state=<inputMessage2>
    if (request->hasParam(PARAM_INPUT_1) && request->hasParam(PARAM_INPUT_2)) {
      inputMessage1 = request->getParam(PARAM_INPUT_1)->value();
      inputMessage2 = request->getParam(PARAM_INPUT_2)->value();
      digitalWrite(inputMessage1.toInt(), inputMessage2.toInt());
    }
    else {
      inputMessage1 = "No message sent";
      inputMessage2 = "No message sent";
    }
    Serial.print("GPIO: ");
    Serial.print(inputMessage1);
    Serial.print(" - Set to: ");
    Serial.println(inputMessage2);
    request->send(200, "text/plain", "OK");
  });

  // Start server
  server.begin();
}

void loop() {

}

The code didnt work even thou the wired pin was the right one ( see picture). Suddenly I got some USB connect/disconnect noise than it stopped working overall. Not even the LED blinks and no computer can find it anymore. I am pretty sure I didnt short wire it which makes me really confused because it worked before the code change without problems.

Where did I make a mistake ?
Can I check if its really dead or may repair it ? - The Board still gets 5V towards the pin which I checked via multimeter. The 3v3 has no voltage.

Thanks and Greetings

Ignore the soldering on the platine it was quick and dirty for testing...

I guess I "solved" it -

It seems the mistake was taking the 5V Pin as power source for the Relay. It worked for a while but after a time the IO Pin that was the Signal got to much because it was basicly just a short wired 5~V towards the IO which was to much for that cheap replica of the D1 Mini (was not the original)
Guess I have to get another one and try it with the 3.3V Output which should be good enough for the Relay.

The D1 Mini won't have enough drive capability for a relay. You need a transistor or FET to provide the current. Also a diode across the relay to protect the silicon for the back EMF.

The KY-019 is a Shield Module which has all this inbuild. I mean it worked for a while until the MC got toasted~
https://datasheetspdf.com/pdf-file/1402030/Joy-IT/KY-019/1

I probl just had a short circuit on the platine with the 5V towards IO which roasted it. I know the real Wemos D1 should be 5V safe but it seems the copy I got wasnt.

Both the genuine Lolin and the clones use the ESP8266, which is a 3.3V device. So I don't think the genuine is more tolerant. Anyway, you don't want to power the relay from the Mini's 3.3V pin. Power your relay module from your 5V supply, with Signal being driven by a GPIO pin. It looks like your module has the transistor and diode, so that should work fine.

You probably shorted something. If you get nothing at the 3.3V pin when USB is connected, you probably burned out the input diode, the fuse or the voltage regulator. If you have a 3.3V supply that you could connect to the 3.3V pin, the Mini might still work. But you don't know what may have been damaged in the ESP8266, so it may be best to declare this one dead, and move on.

I haven't looked at your sketch, but I think software is unlikely to be the problem.

ShermanP:
Both the genuine Lolin and the clones use the ESP8266, which is a 3.3V device. So I don't think the genuine is more tolerant. Anyway, you don't want to power the relay from the Mini's 3.3V pin. Power your relay module from your 5V supply, with Signal being driven by a GPIO pin. It looks like your module has the transistor and diode, so that should work fine.

You probably shorted something. If you get nothing at the 3.3V pin when USB is connected, you probably burned out the input diode, the fuse or the voltage regulator. If you have a 3.3V supply that you could connect to the 3.3V pin, the Mini might still work. But you don't telldunkin know what may have been damaged in the ESP8266, so it may be best to declare this one dead, and move on.

I haven't looked at your sketch, but I think software is unlikely to be the problem.

It worked for a while but after a time the IO Pin that was the Signal got to much because it was basicly just a short wired 5~V towards the IO which was to much for that cheap replica of the D1 Mini (was not the original)
Guess I have to get another one and try it with the 3.3V Output which should be good enough for the Relay.