KitRelayWifiEsp
https://www.aliexpress.com/item/ESP8266-ESP-01S-5V-WiFi-Relay-Module-Things-Smart-Home-Remote-Control-Switch-for-Arduino-Phone/32841061942.html
Oooops: titre disait "sans wifi module! mais il y en a un dans le colis
commentaire : "nous avons téléchargé"
enfin un article pertinent:
https://andrologiciels.wordpress.com/materiels-android/esp8266/relais-esp/esp-01s-relay-module/
qui mène à:
https://github.com/IOT-MCU/ESP-01S-Relay-v1.0/blob/master/Arduino%20usage%20and%20demo%20code.zip
essayé sur
Esp8266mod01number4
(mais il manque des .h ...)
dépalcé à la main
finamleùent fonctionne sur l'AP
Ok debug serial 9600
mais pas trace de la connexion au réseau local
souvent erreur ouveture port sérue
n°1
arrivé
ouvre wifi farylink
est ip 192.168.4.1
Ok ping
scan ne découvre aucun port ouvert
échange email: pas de support
envisager que le programme préchargé ne permette pas la commande du relais, on ouvrira une dispute lors de la prochaine livraison
farilink sur google!
https://www.instructables.com/id/Getting-Started-With-ESP8266LiLon-NodeMCU-V3Flashi/
tour du propriétaire:
un poussoir gravé "RST"
dessous
"Esp-01S Relay
V4.0
TB:IOTMCU"
APP V1
https://github.com/IOT-MCU/ESP-01S-Relay-v1.0/raw/master/Android%20APP.zip
app brut:
http://antiguide.free.fr/apk/iot/ESP8266_Controller.apk ; ok, mais ne communique pas plus, pas de message d'erreur.
20181008
sans ESP
conso 1 mA
si je mets à la masse le pin GPIO0, diode bleue, conso 150 mA, et clic et certainement relai activé.
avec
Esp01:
conso 70 mA (mais gaffe on sait nécessaire plus de 500 mA en pointe)
reset enfoncé : 44 mA
google TB=IOTMCU:
image:
https://fr.aliexpress.com/item/Elecrow-ESP8266-ESP-01S-Relay-Module-Remote-Switch-Phone-APP-DIY-Project-Design-Kit/32819462977.html
https://github.com/IOT-MCU/ESP-01S-Relay-v1.0
exactement:
h
ttps://fr.aliexpress.com/item/Elecrow-ESP8266-ESP-01S-Relay-Module-Remote-Switch-Phone-APP-DIY-Project-Design-Kit/32819462977.html
https://github.com/IOT-MCU/ESP-01S-Relay-v4.0
programmé en LUA
led1 = 3
led2 = 4
gpio.mode(led1, gpio.OUTPUT)
gpio.mode(led2, gpio.OUTPUT)
gpio.write(led1, gpio.HIGH)
gpio.write(led2, gpio.HIGH)
print("Ready to start soft ap")
local str=wifi.ap.getmac();
local ssidTemp=string.format("%s%s%s",string.sub(str,10,11),string.sub(str,13,14),string.sub(str,16,17));
cfg={}
cfg.ssid="ESP8266_"..ssidTemp;
cfg.pwd="12345678"
wifi.ap.config(cfg)
cfg={}
cfg.ip="192.168.1.1";
cfg.netmask="255.255.255.0";
cfg.gateway="192.168.1.1";
wifi.ap.setip(cfg);
wifi.setmode(wifi.SOFTAP)
str=nil;
ssidTemp=nil;
collectgarbage();
print("Soft AP started")
print("Heep:(bytes)"..node.heap());
print("MAC:"..wifi.ap.getmac().."\r\nIP:"..wifi.ap.getip());
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive", function(client,request)
local buf = "";
buf = buf.."HTTP/1.1 200 OK\n\n"
local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP");
if(method == nil)then
_, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP");
end
local _GET = {}
if (vars ~= nil)then
for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do
_GET[k] = v
end
end
if(_GET.pin == "ON1")then
gpio.write(led1, gpio.LOW);
print("led1 on")
elseif(_GET.pin == "OFF1")then
gpio.write(led1, gpio.HIGH);
print("led1 off")
elseif(_GET.pin == "ON2")then
gpio.write(led2, gpio.LOW);
print("led2 on")
elseif(_GET.pin == "OFF2")then
gpio.write(led2, gpio.HIGH);
print("led2 off")
end
client:send(buf);
client:close();
collectgarbage();
end)
end)
circuit:
https://github.com/IOT-MCU/ESP-01S-Relay-v4.0/blob/master/ESP-01S%20Relay%20v4.0.pdf
.ino AP ou Server
lu:
https://app.box.com/s/bwtfxnqlisadh544z5l38h1pxqr2t4wq
////////////////////////////////////
//Relay Web Page by Elac 1/1/18
//Adapt by Andrologiciels (05/03/18)
////////////////////////////////////////
// ESP-01S Relay Module vRef
////////////////////////
// http://192.168.0.67/?sCmd=FUNCTION1ON
// http://192.168.0.67/?sCmd=OFF
////////////////////////////////////
// WEB SERVER VERSION
/*-----------------------------------------------------------------------------------------------------
Access Point Web Server e.g.
http://192.168.4.1 http://192.168.0.67 (depends on your network)
Works with generic ESP01
Usage: ACCESS Point:
After upload search with your device (Phone, Tablet, etc.) for
new WiFi. Select ESP_FastLED_Access_Point.
Open in your webbrowser the URL 192.168.4.1
Optional print a QR-Code with the URL on your lamp http://goqr.me/
WEB SERVER:
After upload open the Serial Monitor in Arduino and see what
IP address is returned. In my case it is 192.168.1.252
Open this IP address in a browser (PC or phone)
From Gyro Gearloose J. Bruegl, Feb 2016
/*------------------------------------------------------------------------------------------------------
HTTP 1.1 Webserver for ESP8266 adapted to Arduino IDE
From Stefan Thesen 04/2015
https://blog.thesen.eu/http-1-1-webserver-fuer-esp8266-als-accesspoint/
https://blog.thesen.eu/stabiler-http-1-1-wlan-webserver-mit-dem-esp8266-microcontroller
-----------------------------------------------------------------------------------------------------*/
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
const int RelayPin = 0;
byte crm; // Holds if command was recieved to change relay mode
byte relayMode; // Holds current relay state
// Select EITHER ACCESS-Point OR WEB SERVER setup
/*
// ACCESS-Point setup ------------------------------------------------------------------------------------------------------
const char* ssid = "ESP Relay";
const char* password = ""; // set to "" for open access point w/o password; or any other pw (min length = 8 characters)
unsigned long ulReqcount;
// Create an instance of the server on Port 80
WiFiServer server(80);
//IPAddress apIP(192, 168, 10, 1); // if you want to configure another IP address
void setup()
{
// Start Serial
Serial.begin(9600);
delay(500);
// setup globals
relayMode = 0;
crm = 0;
ulReqcount = 0;
// prepare GPIO2
// pinMode(2, OUTPUT);
///14 digitalWrite(2, 0);
// AP mode
WiFi.mode(WIFI_AP);
// WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0)); // if you want to configure another IP address
WiFi.softAP(ssid, password);
server.begin();
}
*/
// End ACCESS-Point setup ---------------------------------------------------------------------------------------------------
// WEB SERVER setup ---------------------------------------------------------------------------------------------------------
const char* ssid = "xxxx"; // Enter router SSID
const char* password = "xxxx"; // Enter router password
unsigned long ulReqcount;
unsigned long ulReconncount;
WiFiServer server(80); // Create an instance of the server on Port 80
void setup()
{
// Start Serial
//Serial.begin(9600); //or 115200
pinMode(RelayPin, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output
///////////
//Serial.print("Connecting to ");
//Serial.println(ssid);
//////////
relayMode = 0;
crm = 0;
ulReqcount = 0; // Setup globals for Webserver
ulReconncount = 0;
// Set static IP or comment out // next 4 lines for router to assign
/*
IPAddress ip(192, 168, 1, 99); // Put the static IP addres you want to assign here
IPAddress gateway(192, 168, 0, 254); // Put your router gateway here
IPAddress subnet(255, 255, 255, 0);
WiFi.config(ip, gateway, subnet);
WiFi.mode(WIFI_STA);
*/
WiFi.mode(WIFI_STA);
WiFiStart();
///////////////
//Serial.println("");
//Serial.println("WiFi connected");
//Serial.println("IP address: ");
//Serial.println(WiFi.localIP());
//////////
}
// End WEB SERVER setup -----------------------------------------------------------------------------------------------------
void WiFiStart()
{
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
//Serial.println(".");
}
server.begin();
}
/////////////////////////////////////////////////////////////
void loop() {
Webserver();
CheckForChange();
};
///////////////////////////////////////////////////////////
void CheckForChange() {
if (crm == 1)
{
switch (relayMode) {
case 0: {
Off();
}
break;
case 1: {
On();
}
break;
}
crm = 0;
}
};
///////////////////////////////////////////////////////////////////////////
void Webserver() { /// complete web server (same for access point) ////////////////////////////////////////////////////////
// Check if a client has connected
WiFiClient client = server.available();
if (!client)
{
return;
}
// Wait until the client sends some data
unsigned long ultimeout = millis() + 250;
while (!client.available() && (millis() < ultimeout) )
{
delay(1);
}
if (millis() > ultimeout)
{
return;
}
// Read the first line of the request
String sRequest = client.readStringUntil('\r');
client.flush();
// stop client, if request is empty
if (sRequest == "")
{
client.stop();
return;
}
// get path; end of path is either space or ?
// Syntax is e.g. GET /?pin=MOTOR1STOP HTTP/1.1
String sPath = "", sParam = "", sCmd = "";
String sGetstart = "GET ";
int iStart, iEndSpace, iEndQuest;
iStart = sRequest.indexOf(sGetstart);
if (iStart >= 0)
{
iStart += +sGetstart.length();
iEndSpace = sRequest.indexOf(" ", iStart);
iEndQuest = sRequest.indexOf("?", iStart);
if (iEndSpace > 0)
{
if (iEndQuest > 0)
{
// there are parameters
sPath = sRequest.substring(iStart, iEndQuest);
sParam = sRequest.substring(iEndQuest, iEndSpace);
}
else
{
// NO parameters
sPath = sRequest.substring(iStart, iEndSpace);
}
}
}
if (sParam.length() > 0)
{
int iEqu = sParam.indexOf("=");
if (iEqu >= 0)
{
sCmd = sParam.substring(iEqu + 1, sParam.length());
char carray[4]; // values 0..255 = 3 digits; array = digits + 1
sCmd.toCharArray(carray, sizeof(carray)); // convert char to the array
}
}
//////////////////////////////
// format the html response //
//////////////////////////////
String sResponse, sHeader;
///////////////////////////////
// 404 for non-matching path //
///////////////////////////////
if (sPath != "/")
{
sResponse = "<html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL was not found on this server.</p></body></html>";
sHeader = "HTTP/1.1 404 Not found\r\n";
sHeader += "Content-Length: ";
sHeader += sResponse.length();
sHeader += "\r\n";
sHeader += "Content-Type: text/html\r\n";
sHeader += "Connection: close\r\n";
sHeader += "\r\n";
}
//////////////////////////
// format the html page //
//////////////////////////
else
{
ulReqcount++;
sResponse = "<html><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>ESP8266 Relay</title></head>";
sResponse += "<body bgcolor=\"#1F1F1F\" >";
sResponse += "<div style='text-align:center; height:96%; border:10px groove blue; border-radius: 5px;'>";
sResponse += "<strong><h1><i><a style=color:#00CCCC>ESP Relay</a></i></h1></strong><br><br><br><br>";
///// Buttons
sResponse += "<form action=\"?sCmd\">";
sResponse += "<button name=\"sCmd\" value=\"FUNCTION1ON\" style=\"color:yellow; background-color:black; font-size:130%; width:80px; margin-right:20px;\" onclick=\'this.form.submit();'>ON</button>";
sResponse += "<button name=\"sCmd\" value=\"OFF\" style=\"color:yellow; background-color:black; font-size:130%; width:80px; margin-left:20px;\" onclick=\'this.form.submit();'>OFF</button>";
sResponse += "</select></form><br><br><br><br>";
/////////////////////////////
// react on parameters //
/////////////////////////////
if (sCmd.length() > 0)
{
// write received command to html page
// change the effect
if (sCmd.indexOf("FUNCTION1ON") >= 0)
{
relayMode = 1;
crm = 1;
}
else if (sCmd.indexOf("OFF") >= 0)
{
relayMode = 0;
crm = 1;
}
};
sResponse += "<font size=+2><a style=color:#FFFDD2 >Relay State:</a><i> ";
switch (relayMode) {
case 0:
sResponse += "<a style=color:#FF0E0E >Off</a>";
break;
case 1:
sResponse += "<a style=color:#00FF00 >On</a></i>";
break;
}
sResponse += "</div></body></html>";
sHeader = "HTTP/1.1 200 OK\r\n";
sHeader += "Content-Length: ";
sHeader += sResponse.length();
sHeader += "\r\n";
sHeader += "Content-Type: text/html\r\n";
sHeader += "Connection: close\r\n";
sHeader += "\r\n";
}
// Send the response to the client
client.print(sHeader);
client.print(sResponse);
// and stop the client
client.stop();
}; // End of web server
///////////////////////////////////////////////////////////////////////////
/// END of complete web server /////////////////////////////////////
///Button functions
void Off() {
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(RelayPin, LOW);
};
void On() {
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(RelayPin, HIGH);
};
///End of sketch/////////////////////////////////////////
20181013
connecté USB 2 fils
monitor com 17 à 115200
AT répond OK! même si débranché!
com 17 zen !
rechargé pilotes mais erreur en installant
essai:
https://sparks.gogo.co.nz/ch340.html
pas mieux
essai
DellVostro1720Sevenok? brancheùent adaptateur usb com27
OUF, com27, 115200 par putty
at+cifsr me dit ip et mac
mais ensiuiote impossibme
suivant:
https://forum.arduino.cc/index.php?topic=501923.0
AT+GMR donne version
premier essai du programme ci desus
diode bleu ermanente, pas de webserver
modifié led_builtin 10!