智能wifi插座刷固件

Title
智能wifi插座刷固件
Date
May 14, 2023
买了两个智德智能插座,某鱼9块9一个,由于原厂的App倒闭,导致不能使用,原本是通过公子小白机器人(从没有听过的机器人😅)进行控制的,也可以通过公子小白APP控制,但是好像也不能用了,就算能用也不太想用,毕竟不想把智能电器暴露在互联网中,就想通过Arduino刷程序只在家庭局域网中进行控制。
卖家提供了针脚图:
notion image
notion image
但是卖家没有提供刷机的方法,看得出主芯片是ESP8266EX芯片,拆机研究了一通之后,找到了刷机的办法:
在用CH340芯片连接芯片之前要先把GPIO0的引脚接地,这样ESP8266就会进入下载模式,但是不用一直接地就可以烧录程序,只要让最开始让芯片进入烧录模式即可。
引脚连接: VCC -- 3.3V GND -- GND RTD -- TXD TXD -- RXD
arduino:
#include <WiFiManager.h> #include <ESP8266WiFi.h> #include <ESP8266WebServer.h> #include "FS.h" ESP8266WebServer server(80); //const int LED_PIN = LED_BUILTIN; const int LED_PIN = 4; int ledStatus = HIGH; void handleRoot() { // Just serve the index page from SPIFFS when asked for File index = SPIFFS.open("/index.html", "r"); server.streamFile(index, "text/html"); index.close(); } // A function which sends the LED status back to the client void sendStatus() { if (ledStatus == HIGH) server.send(200, "text/plain", "HIGH"); else server.send(200, "text/plain", "LOW"); } // Toggle the LED and back its status void toggleLED() { ledStatus = ledStatus == HIGH ? LOW : HIGH; digitalWrite(LED_PIN, ledStatus); sendStatus(); } void setup() { pinMode(LED_PIN, OUTPUT); digitalWrite(LED_PIN, ledStatus); Serial.begin(115200); SPIFFS.begin(); WiFiManager wm; wm.autoConnect("SmartSocket"); Serial.println(""); Serial.print("ESP8266 Connected to "); Serial.println(WiFi.SSID()); // WiFi名称 Serial.print("IP address:\t"); Serial.println(WiFi.localIP()); server.on("/", handleRoot); // Handlers for various user-triggered events server.on("/toggle", toggleLED); server.on("/status", sendStatus); server.begin(); } void loop() { server.handleClient(); }
index.html:
<!doctype html> <html> <head> <meta charset='UTF-8' /> <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=yes"> <!-- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.min.css"> --> <!-- <link rel="stylesheet" href="https://unpkg.com/mdui@1.0.2/dist/css/mdui.min.css" /> --> <link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css"> <title>智能家居控制平台</title> <style> body{height: 100vh;justify-content: center;align-items: center;background-color: #efeeee; } .container{ width: 100%; height: 100%; display: flex; justify-content: space-around; flex-wrap: wrap; align-items: center; } </style> </head> <body> <div class="container"> <center> <h2>智能家居控制平台</h2> <svg id = "light" xmlns="on" width="96" height="96" fill="currentColor" class="bi bi-lightbulb" viewBox="0 0 16 16"> <path d="M2 6a6 6 0 1 1 10.174 4.31c-.203.196-.359.4-.453.619l-.762 1.769A.5.5 0 0 1 10.5 13h-5a.5.5 0 0 1-.46-.302l-.761-1.77a1.964 1.964 0 0 0-.453-.618A5.984 5.984 0 0 1 2 6zm3 8.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1l-.224.447a1 1 0 0 1-.894.553H6.618a1 1 0 0 1-.894-.553L5.5 15a.5.5 0 0 1-.5-.5z" /> </svg> <h3>灯光: <span id='status'></span></h3> <button id='toggleBtn'>ON/OFF</button> </center> </div> <script> function makeRequest(action, callback) { var req = new XMLHttpRequest(); req.open('GET', '/' + action + '?' + Date.now()); if (callback !== undefined) { req.onreadystatechange = function() { if (req.status === 200) callback(req.responseText); }; } req.send(null); } var statusSpan = document.getElementById('status'); var lightstatus = document.getElementById('light'); function updateStatus(status) { if (status == "HIGH") { statusSpan.textContent = "开"; lightstatus.innerHTML = '<path d="M2 6a6 6 0 1 1 10.174 4.31c-.203.196-.359.4-.453.619l-.762 1.769A.5.5 0 0 1 10.5 13a.5.5 0 0 1 0 1 .5.5 0 0 1 0 1l-.224.447a1 1 0 0 1-.894.553H6.618a1 1 0 0 1-.894-.553L5.5 15a.5.5 0 0 1 0-1 .5.5 0 0 1 0-1 .5.5 0 0 1-.46-.302l-.761-1.77a1.964 1.964 0 0 0-.453-.618A5.984 5.984 0 0 1 2 6zm6-5a5 5 0 0 0-3.479 8.592c.263.254.514.564.676.941L5.83 12h4.342l.632-1.467c.162-.377.413-.687.676-.941A5 5 0 0 0 8 1z"/>' } else{ statusSpan.textContent = "关"; lightstatus.innerHTML = '<path d="M2 6a6 6 0 1 1 10.174 4.31c-.203.196-.359.4-.453.619l-.762 1.769A.5.5 0 0 1 10.5 13h-5a.5.5 0 0 1-.46-.302l-.761-1.77a1.964 1.964 0 0 0-.453-.618A5.984 5.984 0 0 1 2 6zm3 8.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1l-.224.447a1 1 0 0 1-.894.553H6.618a1 1 0 0 1-.894-.553L5.5 15a.5.5 0 0 1-.5-.5z"/>' } } document.getElementById('toggleBtn').addEventListener('click', function() { makeRequest('toggle', updateStatus); }); makeRequest('status', updateStatus); </script> </body> </html>
 
Built with Potion.so