Wemos D1 Mini Relæ Shield gør det muligt at aktivere/deaktivere relæet via internettet. Perfekt til alle slags IoT projekter. Relæet monteres på D1 mini.
Tekniske detaljer:
Power: 3-5V
Pin: Bruger pin 5 (D1)
Current: Max 10A
Passer til: Wemos D1 Mini (Køb den HER)
Installere ESP package (Arduino IDE)
- Åben Arduino IDE (Download her)
- Klik “Fil/Egenskaber”
- Indtast dette link i feltet “Additionel Board Manager URL’s”
- Link “http://arduino.esp8266.com/stable/package_esp8266com_index.json“
- Klik OK
- Åben “Værktøj/Board/Boards manager” (Lad programmet opdatere)
- Find “ESP8266” og installere
- Klik derefter “Værktøj/Board” og find (WeMos D1 R1)
- “Værktøj/Programmer” skal være “AVR ISP”
- Du er nu klar til at sende en kode
Eksempel
Her viser vi et hurtig eksempel på du via en browser kan tænde/slukke relæ’et.
Placere den som vist på billedet: (Vær sikker på den er vendt rigtigt)
Kode
/* * ESP8266 NodeMCU LED Control over WiFi Demo * * https://circuits4you.com */ #include <ESP8266WiFi.h> #include <WiFiClient.h> //ESP Web Server Library to host a web page #include <ESP8266WebServer.h> //--------------------------------------------------------------- //Our HTML webpage contents in program memory const char MAIN_page[] PROGMEM = R"=====( <!DOCTYPE html> <html> <body> <center> <h1>WiFi LED on off demo: 1</h1><br> Ciclk to turn <a href="ledOn">LED ON</a><br> Ciclk to turn <a href="ledOff">LED OFF</a><br> <hr> <a href="https://circuits4you.com">circuits4you.com</a> </center> </body> </html> )====="; //--------------------------------------------------------------- //On board LED Connected to GPIO2 #define Relay 5 // //SSID and Password of your WiFi router const char* ssid = "02479293"; const char* password = "00453527"; //Declare a global object variable from the ESP8266WebServer class. ESP8266WebServer server(80); //Server on port 80 //=============================================================== // This routine is executed when you open its IP in browser //=============================================================== void handleRoot() { Serial.println("You called root page"); String s = MAIN_page; //Read HTML contents server.send(200, "text/html", s); //Send web page } void handleLEDon() { Serial.println("LED on page"); digitalWrite(Relay, HIGH); //LED is connected in reverse server.send(200, "text/html", "LED is ON"); //Send ADC value only to client ajax request } void handleLEDoff() { Serial.println("LED off page"); digitalWrite(Relay, LOW); //LED off server.send(200, "text/html", "LED is OFF"); //Send ADC value only to client ajax request } //============================================================== // SETUP //============================================================== void setup(void){ Serial.begin(115200); WiFi.begin(ssid, password); //Connect to your WiFi router Serial.println(""); pinMode(Relay, OUTPUT); // 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 server.on("/", handleRoot); //Which routine to handle at root location. This is display page server.on("/ledOn", handleLEDon); //as Per <a href="ledOn">, Subroutine to be called server.on("/ledOff", handleLEDoff); server.begin(); //Start server Serial.println("HTTP server started"); } //============================================================== // LOOP //============================================================== void loop(void){ server.handleClient(); //Handle client requests }
Kontakt os
Du er altid velkommen til at kontakte os på info@ardustore.dk, eller sende os en besked via messenger (Klik her) og vi vil hjælpe dig.
Anmeldelser
Der er endnu ikke nogle anmeldelser.