History Clean Up
This commit is contained in:
BIN
_FIRMWARE/drivers/CH341SER/CH341PT.DLL
Normal file
BIN
_FIRMWARE/drivers/CH341SER/CH341PT.DLL
Normal file
Binary file not shown.
BIN
_FIRMWARE/drivers/CH341SER/CH341S64.SYS
Normal file
BIN
_FIRMWARE/drivers/CH341SER/CH341S64.SYS
Normal file
Binary file not shown.
BIN
_FIRMWARE/drivers/CH341SER/CH341S98.SYS
Normal file
BIN
_FIRMWARE/drivers/CH341SER/CH341S98.SYS
Normal file
Binary file not shown.
213
_FIRMWARE/drivers/CH341SER/CH341SER.INF
Normal file
213
_FIRMWARE/drivers/CH341SER/CH341SER.INF
Normal file
@@ -0,0 +1,213 @@
|
||||
; CH341SER.INF
|
||||
; Driver for CH341 (USB=>SERIAL chip) V3.4
|
||||
; WDM&VXD for Windows 98/Me/2000/XP/Server2003/Vista/64bit Vista/Server2008/Win7/64bit Win7
|
||||
; Copyright (C) W.ch 2001-2014
|
||||
;
|
||||
|
||||
[Version]
|
||||
Signature = "$Chicago$"
|
||||
Class = Ports
|
||||
ClassGuid = {4D36E978-E325-11CE-BFC1-08002BE10318}
|
||||
Provider = %WinChipHead%
|
||||
DriverVer = 08/08/2014, 3.4.2014.08
|
||||
CatalogFile = CH341SER.CAT
|
||||
|
||||
[ControlFlags]
|
||||
ExcludeFromSelect = USB\VID_1A86&PID_7523
|
||||
ExcludeFromSelect = USB\VID_1A86&PID_5523
|
||||
ExcludeFromSelect = USB\VID_4348&PID_5523
|
||||
ExcludeFromSelect = USB\VID_4348&PID_5523&REV_0250
|
||||
ExcludeFromSelect = USBSERPORT\SER5523
|
||||
ExcludeFromSelect = CH341PORT\SER5523
|
||||
|
||||
[Manufacturer]
|
||||
%WinChipHead% = WinChipHead,NT,NTamd64,NTia64
|
||||
|
||||
[WinChipHead]
|
||||
%CH340SER.DeviceDesc% = CH341SER_Install, USB\VID_1A86&PID_7523
|
||||
%CH341ASER.DeviceDesc% = CH341SER_Install, USB\VID_1A86&PID_5523
|
||||
%CH341SER.DeviceDesc% = CH341SER_Install, USB\VID_4348&PID_5523
|
||||
%CH340SER.DeviceDesc% = CH341SER_Install, USB\VID_4348&PID_5523&REV_0250
|
||||
%CH341S98.DeviceDesc% = CH341S98_Install, USBSERPORT\SER5523
|
||||
%CH341S98.DeviceDesc% = CH341S98_Install, CH341PORT\SER5523
|
||||
|
||||
[WinChipHead.NT]
|
||||
%CH340SER.DeviceDesc% = CH341SER_Install.NT, USB\VID_1A86&PID_7523
|
||||
%CH341ASER.DeviceDesc% = CH341SER_Install.NT, USB\VID_1A86&PID_5523
|
||||
%CH341SER.DeviceDesc% = CH341SER_Install.NT, USB\VID_4348&PID_5523
|
||||
%CH340SER.DeviceDesc% = CH341SER_Install.NT, USB\VID_4348&PID_5523&REV_0250
|
||||
|
||||
[WinChipHead.NTamd64]
|
||||
%CH340SER.DeviceDesc% = CH341SER_Inst.NTamd64, USB\VID_1A86&PID_7523
|
||||
%CH341ASER.DeviceDesc% = CH341SER_Inst.NTamd64, USB\VID_1A86&PID_5523
|
||||
%CH341SER.DeviceDesc% = CH341SER_Inst.NTamd64, USB\VID_4348&PID_5523
|
||||
%CH340SER.DeviceDesc% = CH341SER_Inst.NTamd64, USB\VID_4348&PID_5523&REV_0250
|
||||
|
||||
[WinChipHead.NTia64]
|
||||
%CH340SER.DeviceDesc% = CH341SER_Inst.NTia64, USB\VID_1A86&PID_7523
|
||||
%CH341ASER.DeviceDesc% = CH341SER_Inst.NTia64, USB\VID_1A86&PID_5523
|
||||
%CH341SER.DeviceDesc% = CH341SER_Inst.NTia64, USB\VID_4348&PID_5523
|
||||
%CH340SER.DeviceDesc% = CH341SER_Inst.NTia64, USB\VID_4348&PID_5523&REV_0250
|
||||
|
||||
[CH341SER_Install]
|
||||
DelFiles = CH341S98.DelFiles.SYS
|
||||
CopyFiles = CH341SER.CopyFiles.SYS, CH341SER.CopyFiles.DLL
|
||||
AddReg = CH341SER.9X.AddReg, CH341SER.AddReg
|
||||
|
||||
[CH341SER_Install.NT]
|
||||
CopyFiles = CH341SER.NT.CopyFiles.SYS, CH341SER.CopyFiles.DLL
|
||||
AddReg = CH341SER.NT.AddReg, CH341SER.AddReg
|
||||
|
||||
[CH341SER_Install.NT.HW]
|
||||
AddReg = CH341SER.NT.HW.AddReg
|
||||
|
||||
[CH341SER_Inst.NTamd64]
|
||||
CopyFiles = CH341SER.NT.CopyFiles.SYSA64
|
||||
AddReg = CH341SER.NT.AddReg, CH341SER.AddReg
|
||||
|
||||
[CH341SER_Inst.NTamd64.HW]
|
||||
AddReg = CH341SER.NT.HW.AddReg
|
||||
|
||||
[CH341SER_Inst.NTia64]
|
||||
CopyFiles = CH341SER.NT.CopyFiles.SYSI64
|
||||
AddReg = CH341SER.NT.AddReg, CH341SER.AddReg
|
||||
|
||||
[CH341SER_Inst.NTia64.HW]
|
||||
AddReg = CH341SER.NT.HW.AddReg
|
||||
|
||||
[CH341S98_Install]
|
||||
DelFiles = CH341S98.DelFiles.SYS
|
||||
CopyFiles = CH341S98.CopyFiles.VXD, CH341SER.CopyFiles.SYS
|
||||
AddReg = CH341S98.9X.AddReg, CH341S98.AddReg
|
||||
|
||||
;[CH341S98_Install.NT]
|
||||
|
||||
[CH341S98.DelFiles.SYS]
|
||||
CH341S98.SYS, , , 1
|
||||
|
||||
[CH341SER.CopyFiles.SYS]
|
||||
CH341S98.SYS, , , 2
|
||||
|
||||
[CH341SER.NT.CopyFiles.SYS]
|
||||
CH341SER.SYS, , , 2
|
||||
|
||||
[CH341SER.NT.CopyFiles.SYSA64]
|
||||
CH341S64.SYS, , , 2
|
||||
|
||||
[CH341SER.NT.CopyFiles.SYSI64]
|
||||
;CH341I64.SYS, , , 2
|
||||
|
||||
[CH341S98.CopyFiles.VXD]
|
||||
CH341SER.VXD, , , 2
|
||||
|
||||
[CH341SER.CopyFiles.DLL]
|
||||
CH341PT.DLL, , , 2
|
||||
;<3B><>װDLL<4C>ǿ<EFBFBD>ѡ<EFBFBD><D1A1>,DLL<4C><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʶ<EFBFBD><CAB6>CH341<34>˿ںͼ<DABA><CDBC><EFBFBD>CH341<34>˿ڵIJ<DAB5><C4B2><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||
|
||||
[CH341SER.9X.AddReg]
|
||||
HKR, , DevLoader, , *NTKERN
|
||||
HKR, , NTMPDriver, , CH341S98.SYS
|
||||
|
||||
[CH341SER.NT.AddReg]
|
||||
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
|
||||
|
||||
[CH341SER.NT.HW.AddReg]
|
||||
HKR,,"UpperFilters",0x00010000,"serenum"
|
||||
;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD>ٽ<EFBFBD><D9BD>ڴ<EFBFBD><DAB4>ڵļ<DAB5><C4BC>弴<EFBFBD><E5BCB4><EFBFBD>豸,<2C><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DTR<54><52>RTS<54>ź<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫö<D2AA><C3B6>,<2C>뽫<EFBFBD><EBBDAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еķֺ<C4B7>ȥ<EFBFBD><C8A5>
|
||||
|
||||
[CH341S98.9X.AddReg]
|
||||
HKR, , DevLoader, , *vcomm
|
||||
HKR, , PortDriver, , CH341SER.VXD
|
||||
HKR, , Contention, , *vcd
|
||||
HKR, , ConfigDialog, , serialui.dll
|
||||
HKR, , DCB, 3, 1C,00,00,00, 80,25,00,00, 11,00,00,00, 00,00,0A,00, 0A,00,08,00, 00,11,13,00, 00,00,00,00
|
||||
HKR, , PortSubClass, 1, 01
|
||||
HKR, , EnumPropPages, , "serialui.dll,EnumPropPages"
|
||||
HKR, , Enumerator, , serenum.vxd
|
||||
;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD>ٽ<EFBFBD><D9BD>ڴ<EFBFBD><DAB4>ڵļ<DAB5><C4BC>弴<EFBFBD><E5BCB4><EFBFBD>豸,<2C><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DTR<54><52>RTS<54>ź<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫö<D2AA><C3B6>,<2C>뽫<EFBFBD><EBBDAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еķֺ<C4B7>ȥ<EFBFBD><C8A5>
|
||||
|
||||
[CH341SER.AddReg]
|
||||
HKLM, SOFTWARE\WinChipHead\IC\CH341SER, WDM, 0x00010001, 0x00000034
|
||||
HKLM, SOFTWARE\WinChipHead\IC\CH341PORT, DLL, 0x00010001, 0x00000010
|
||||
HKLM, SOFTWARE\WinChipHead\IC\CH341SER, Function, , "USB=>Serial"
|
||||
;HKLM, SYSTEM\CurrentControlSet\Services\CH341SER, UserRemoval, 0x00010001, 0x00000001
|
||||
;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ȫɾ<C8AB><C9BE>USBתSERIALӲ<4C><D3B2><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB>ֹ<EFBFBD>ɾ<EFBFBD><C9BE>Ӳ<EFBFBD><D3B2>
|
||||
|
||||
[CH341S98.AddReg]
|
||||
HKLM, SOFTWARE\WinChipHead\IC\CH341SER, VXD, 0x00010001, 0x00000023
|
||||
|
||||
[CH341SER_Install.NT.Services]
|
||||
AddService = CH341SER, 2, CH341SER.Service
|
||||
AddService = Serenum, , Serenum_Service_Inst
|
||||
|
||||
[CH341SER_Inst.NTamd64.Services]
|
||||
AddService = CH341SER_A64, 2, CH341SER.ServiceA64
|
||||
AddService = Serenum, , Serenum_Service_Inst
|
||||
|
||||
[CH341SER_Inst.NTia64.Services]
|
||||
AddService = CH341SER_I64, 2, CH341SER.ServiceI64
|
||||
AddService = Serenum, , Serenum_Service_Inst
|
||||
|
||||
[CH341SER.Service]
|
||||
DisplayName = "CH341SER"
|
||||
ServiceType = 1
|
||||
StartType = 3
|
||||
ErrorControl = 1
|
||||
ServiceBinary = %10%\System32\Drivers\CH341SER.SYS
|
||||
|
||||
[CH341SER.ServiceA64]
|
||||
DisplayName = "CH341SER_A64"
|
||||
ServiceType = 1
|
||||
StartType = 3
|
||||
ErrorControl = 1
|
||||
ServiceBinary = %10%\System32\Drivers\CH341S64.SYS
|
||||
|
||||
[CH341SER.ServiceI64]
|
||||
DisplayName = "CH341SER_I64"
|
||||
ServiceType = 1
|
||||
StartType = 3
|
||||
ErrorControl = 1
|
||||
ServiceBinary = %10%\System32\Drivers\CH341I64.SYS
|
||||
|
||||
[Serenum_Service_Inst]
|
||||
DisplayName = "SerEnum"
|
||||
ServiceType = 1
|
||||
StartType = 3
|
||||
ErrorControl = 1
|
||||
ServiceBinary = %12%\serenum.sys
|
||||
LoadOrderGroup = PNP Filter
|
||||
|
||||
[DestinationDirs]
|
||||
DefaultDestDir = 10, System32\Drivers
|
||||
CH341S98.DelFiles.SYS = 11
|
||||
CH341SER.CopyFiles.SYS = 10, System32\Drivers
|
||||
CH341SER.NT.CopyFiles.SYS = 10, System32\Drivers
|
||||
CH341S98.CopyFiles.VXD = 11
|
||||
CH341SER.CopyFiles.DLL = 11
|
||||
CH341SER.NT.CopyFiles.SYSA64 = 10, System32\Drivers
|
||||
;CH341SER.NT.CopyFiles.SYSI64 = 10, System32\Drivers
|
||||
|
||||
[SourceDisksFiles]
|
||||
CH341SER.SYS = 1
|
||||
CH341S98.SYS = 1
|
||||
CH341SER.VXD = 1
|
||||
CH341PT.DLL = 1
|
||||
CH341S64.SYS = 1
|
||||
;CH341I64.SYS = 1
|
||||
|
||||
[SourceDisksNames]
|
||||
1 = %DISK_NAME%, , ,
|
||||
|
||||
[SourceDisksNames.amd64]
|
||||
1 = %DISK_NAME%, , ,
|
||||
|
||||
[SourceDisksNames.ia64]
|
||||
1 = %DISK_NAME%, , ,
|
||||
|
||||
[Strings]
|
||||
WinChipHead = "wch.cn"
|
||||
CH341SER.DeviceDesc = "USB-SERIAL CH341"
|
||||
CH341S98.DeviceDesc = "USB-SERIAL CH341"
|
||||
CH340SER.DeviceDesc = "USB-SERIAL CH340"
|
||||
CH341ASER.DeviceDesc = "USB-SERIAL CH341A"
|
||||
DISK_NAME = "CH341 Serial Installation Disk"
|
BIN
_FIRMWARE/drivers/CH341SER/CH341SER.SYS
Normal file
BIN
_FIRMWARE/drivers/CH341SER/CH341SER.SYS
Normal file
Binary file not shown.
BIN
_FIRMWARE/drivers/CH341SER/CH341SER.VXD
Normal file
BIN
_FIRMWARE/drivers/CH341SER/CH341SER.VXD
Normal file
Binary file not shown.
BIN
_FIRMWARE/drivers/CH341SER/DRVSETUP64/DRVSETUP64.exe
Normal file
BIN
_FIRMWARE/drivers/CH341SER/DRVSETUP64/DRVSETUP64.exe
Normal file
Binary file not shown.
BIN
_FIRMWARE/drivers/CH341SER/SETUP.EXE
Normal file
BIN
_FIRMWARE/drivers/CH341SER/SETUP.EXE
Normal file
Binary file not shown.
BIN
_FIRMWARE/drivers/CH341SER/ch341SER.CAT
Normal file
BIN
_FIRMWARE/drivers/CH341SER/ch341SER.CAT
Normal file
Binary file not shown.
BIN
_FIRMWARE/drivers/PL2303/PL2303_Prolific_GPS_1013_20090319.exe
Normal file
BIN
_FIRMWARE/drivers/PL2303/PL2303_Prolific_GPS_1013_20090319.exe
Normal file
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,346 @@
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <WiFiClient.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <EEPROM.h>
|
||||
#include <ESP8266HTTPClient.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include "DHT.h"
|
||||
|
||||
String ssid = "";
|
||||
String pasw = "";
|
||||
String hwId = "";
|
||||
String url = "";
|
||||
|
||||
//Pins
|
||||
#define LIGHTPIN 13
|
||||
#define DHTPIN 4
|
||||
#define DHTTYPE DHT11
|
||||
#define LED_BUILTIN 16
|
||||
|
||||
//Settings
|
||||
bool deepSleepOn = true;
|
||||
long sleepTime = 4; //in minutes
|
||||
bool lightSensor = true;
|
||||
bool humiditySensor = true;
|
||||
bool temperatureSensor = true;
|
||||
|
||||
ESP8266WebServer server(80);
|
||||
DHT dht(DHTPIN, DHTTYPE);
|
||||
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.setDebugOutput(true);
|
||||
EEPROM.begin(512);
|
||||
|
||||
Serial.println("");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
restorSetting();
|
||||
if (!checkConnection()) {
|
||||
settingMode();
|
||||
while (true){
|
||||
Serial.println("CONECTION SETTING LOOP");
|
||||
server.handleClient();
|
||||
}
|
||||
} else {
|
||||
httpRequest();
|
||||
sleep();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//webpages
|
||||
void handleRoot() {
|
||||
String s = "<!DOCTYPE html><html><head>";
|
||||
s += "<meta name=\"viewport\" content=\"width=device-width,user-scalable=0\">";
|
||||
s += "<title>";
|
||||
s += "Main";
|
||||
s += "</title>";
|
||||
s += "</head>";
|
||||
s += "<body>";
|
||||
s += "<a href=\"/restart\"><p>Restartovat</p><a/>";
|
||||
s += "<a href=\"/setting\"><p>Refrest WIFI Networks</p><a/>";
|
||||
s += "</body>";
|
||||
s += "</html>";
|
||||
server.send(200, "text/html", s);
|
||||
}
|
||||
|
||||
void handleSetting() {
|
||||
String wifiList = "";
|
||||
int n = WiFi.scanNetworks();
|
||||
Serial.println("scan done");
|
||||
if (n == 0) {
|
||||
Serial.println("no networks found");
|
||||
} else {
|
||||
for (int i = 0; i < n; ++i) {
|
||||
//Serial.println("SSID: " + WiFi.SSID(i));
|
||||
wifiList = wifiList + String("<option value=\"");
|
||||
wifiList = wifiList + String(WiFi.SSID(i));
|
||||
wifiList = wifiList + String("\">");
|
||||
wifiList = wifiList + String(WiFi.SSID(i) + "(" + WiFi.RSSI() + ")");
|
||||
wifiList = wifiList + String("</option>");
|
||||
}
|
||||
}
|
||||
|
||||
String s = "<!DOCTYPE html><html><head>";
|
||||
s += "<meta name=\"viewport\" content=\"width=device-width,user-scalable=0\">";
|
||||
s += "<title>";
|
||||
s += "Main";
|
||||
s += "</title>";
|
||||
s += "</head>";
|
||||
s += "<body>";
|
||||
s += "<form method=\"get\" action=\"set\">";
|
||||
s += "<br>SSID: <select name=\"ssid\">";
|
||||
s += wifiList;
|
||||
s += "</select>";
|
||||
s += "<br>Password: <input name=\"pasw\" length=64 type=\"password\">";
|
||||
s += "<br>Token: <input name=\"token\" length=64 type=\"text\">";
|
||||
s += "<br>Api Url: <input name=\"url\" length=64 type=\"url\">";
|
||||
s += "<input type=\"submit\">";
|
||||
s += "</form>";
|
||||
s += "</body>";
|
||||
s += "</html>";
|
||||
server.send(200, "text/html", s);
|
||||
}
|
||||
|
||||
//functions
|
||||
bool restorSetting() {
|
||||
Serial.println("Reading EEPROM");
|
||||
ssid = "";
|
||||
pasw = "";
|
||||
hwId = "";
|
||||
url = "";
|
||||
if (EEPROM.read(0) != 0) {
|
||||
Serial.println("Reading EEPROM");
|
||||
for (int i = 0; i < 64; ++i) {
|
||||
ssid += char(EEPROM.read(i));
|
||||
}
|
||||
Serial.println("SSID: " + String(ssid));
|
||||
for (int i = 64; i < 128; ++i) {
|
||||
pasw += char(EEPROM.read(i));
|
||||
}
|
||||
Serial.println("PASS: " + String(pasw));
|
||||
for (int i = 128; i < 192; ++i) {
|
||||
hwId += char(EEPROM.read(i));
|
||||
}
|
||||
Serial.println("TOKEN: " + String(hwId));
|
||||
for (int i = 192; i < 256; ++i) {
|
||||
url += char(EEPROM.read(i));
|
||||
}
|
||||
Serial.println("URL: " + String(url));
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
String urlDecode(String input) {
|
||||
String s = input;
|
||||
s.replace("%20", " ");
|
||||
s.replace("+", " ");
|
||||
s.replace("%21", "!");
|
||||
s.replace("%22", "\"");
|
||||
s.replace("%23", "#");
|
||||
s.replace("%24", "$");
|
||||
s.replace("%25", "%");
|
||||
s.replace("%26", "&");
|
||||
s.replace("%27", "\'");
|
||||
s.replace("%28", "(");
|
||||
s.replace("%29", ")");
|
||||
s.replace("%30", "*");
|
||||
s.replace("%31", "+");
|
||||
s.replace("%2C", ",");
|
||||
s.replace("%2E", ".");
|
||||
s.replace("%2F", "/");
|
||||
s.replace("%2C", ",");
|
||||
s.replace("%3A", ":");
|
||||
s.replace("%3A", ";");
|
||||
s.replace("%3C", "<");
|
||||
s.replace("%3D", "=");
|
||||
s.replace("%3E", ">");
|
||||
s.replace("%3F", "?");
|
||||
s.replace("%40", "@");
|
||||
s.replace("%5B", "[");
|
||||
s.replace("%5C", "\\");
|
||||
s.replace("%5D", "]");
|
||||
s.replace("%5E", "^");
|
||||
s.replace("%5F", "-");
|
||||
s.replace("%60", "`");
|
||||
return s;
|
||||
}
|
||||
|
||||
bool checkConnection() {
|
||||
int count = 0;
|
||||
WiFi.persistent(false);
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.forceSleepWake();
|
||||
WiFi.begin(ssid, pasw);
|
||||
Serial.print("Waiting for Wi-Fi connection");
|
||||
while ( count < 30 ) {
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
Serial.println();
|
||||
Serial.println("Connected!");
|
||||
return (true);
|
||||
}
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
count++;
|
||||
}
|
||||
Serial.println("Timed out.");
|
||||
return false;
|
||||
}
|
||||
|
||||
void settingMode(){
|
||||
WiFi.mode(WIFI_AP);
|
||||
WiFi.softAP("NodeMeter");
|
||||
|
||||
IPAddress myIP = WiFi.softAPIP();
|
||||
Serial.print("HotSpt IP:");
|
||||
Serial.println(myIP);
|
||||
|
||||
server.on("/", handleRoot);
|
||||
server.on("/restart", []() {
|
||||
ESP.restart();
|
||||
});
|
||||
server.on("/setting", handleSetting);
|
||||
server.on("/set", []() {
|
||||
for (int i = 0; i < 96; ++i) {
|
||||
EEPROM.write(i, 'e');
|
||||
}
|
||||
EEPROM.commit();
|
||||
ssid = server.arg("ssid");
|
||||
pasw = server.arg("pasw");
|
||||
hwId = server.arg("token");
|
||||
url = server.arg("url");
|
||||
|
||||
for (int i = 0; i < 256; ++i) {
|
||||
EEPROM.write(i, 0);
|
||||
}
|
||||
|
||||
Serial.println("Writing EEPROM...");
|
||||
Serial.println("SSID:" + ssid);
|
||||
for (int i = 0; i < ssid.length(); ++i) {
|
||||
EEPROM.write(i,ssid[i]);
|
||||
}
|
||||
|
||||
Serial.println("PASW:" + pasw);
|
||||
for (int i = 0; i < pasw.length(); ++i) {
|
||||
EEPROM.write(64 + i, pasw[i]);
|
||||
}
|
||||
|
||||
Serial.println("TOKEN:" + hwId);
|
||||
for (int i = 0; i < hwId.length(); ++i) {
|
||||
EEPROM.write(128 + i, hwId[i]);
|
||||
}
|
||||
|
||||
Serial.println("URL:" + url);
|
||||
for (int i = 0; i < url.length(); ++i) {
|
||||
EEPROM.write(192 + i, url[i]);
|
||||
}
|
||||
EEPROM.commit();
|
||||
|
||||
Serial.println("Write EEPROM done!");
|
||||
String s = "<h1>Setup complete.</h1><p>device will be connected to \"";
|
||||
s += ssid;
|
||||
s += "\" after the restart.";
|
||||
server.send(200, "text/html", s);
|
||||
ESP.restart();
|
||||
});
|
||||
|
||||
server.begin();
|
||||
Serial.println("HTTP server started");
|
||||
}
|
||||
|
||||
bool httpRequest(){
|
||||
StaticJsonDocument<1024> sendContent;
|
||||
sendContent["token"] = hwId;
|
||||
if (temperatureSensor){
|
||||
sendContent["values"]["temp"]["value"] = String(getTemperature());
|
||||
sendContent["values"]["temp"]["unit"] = "C";
|
||||
}
|
||||
|
||||
if (humiditySensor){
|
||||
sendContent["values"]["humi"]["value"] = String(getHumidity());
|
||||
sendContent["values"]["humi"]["unit"] = "%";
|
||||
}
|
||||
|
||||
if (lightSensor){
|
||||
sendContent["values"]["light"]["value"] = String(getLight());
|
||||
sendContent["values"]["light"]["unit"] = "";
|
||||
}
|
||||
|
||||
String requestJson = "";
|
||||
serializeJson(sendContent, requestJson);
|
||||
Serial.println("JSON: " + requestJson);
|
||||
|
||||
HTTPClient http;
|
||||
http.begin(String(url));
|
||||
http.addHeader("Content-Type", "application/json"); //Specify content-type header
|
||||
|
||||
int httpCode = http.POST(requestJson);
|
||||
String payload = http.getString(); //Get the response payload
|
||||
http.end();
|
||||
|
||||
DynamicJsonDocument doc(1024);
|
||||
deserializeJson(doc, payload);
|
||||
|
||||
String hostname = doc["device"]["hostname"];
|
||||
sleepTime = doc["device"]["sleepTime"];
|
||||
WiFi.hostname(hostname);
|
||||
|
||||
Serial.println("HTTP CODE: " + String(httpCode) + ""); //Print HTTP return code
|
||||
Serial.println("HTTP BODY: " + String(payload) + ""); //Print request response payload
|
||||
http.end(); //Close connection
|
||||
}
|
||||
|
||||
void sleep(){
|
||||
Serial.println("DISCONECTED FROM WIFI");
|
||||
WiFi.disconnect();
|
||||
|
||||
if (deepSleepOn) {
|
||||
Serial.println("GOING TO SLEEP FOR " + String(sleepTime));
|
||||
ESP.deepSleep((sleepTime * 60) * 1000000, RF_DEFAULT); // 20e6 is 20 microseconds
|
||||
delay(1000);
|
||||
} else {
|
||||
delay(1000);
|
||||
delay(sleepTime);
|
||||
}
|
||||
}
|
||||
|
||||
//ReadTemperatures
|
||||
float getTemperature() {
|
||||
float t = dht.readTemperature();
|
||||
//Serial.print(dht.readTemperature());
|
||||
//Serial.println(t);
|
||||
if (isnan(t)) {
|
||||
Serial.println( "Failed to read temperature from sensor!") ;
|
||||
return 999;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
float getHumidity() {
|
||||
float h = dht.readHumidity();
|
||||
//Serial.println(h);
|
||||
if (isnan(h)) {
|
||||
Serial.println("Failed to read humidity from sensor!");
|
||||
return 999;
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
int getLight() {
|
||||
int l = analogRead(LIGHTPIN);
|
||||
if (l > 1000) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
Serial.println("Failed to read light from sensor!");
|
||||
return 999;
|
||||
}
|
92
_FIRMWARE/firmwares/Sonoff Original/ESP_END_POINT.ino
Normal file
92
_FIRMWARE/firmwares/Sonoff Original/ESP_END_POINT.ino
Normal file
@@ -0,0 +1,92 @@
|
||||
//Includes
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266HTTPClient.h>
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
//Variables
|
||||
const char* ssid = "";
|
||||
const char* pasw = "";
|
||||
const char* server = "http://ESP:ESP@dev.steelants.cz/projekty/rest_vasek/api/out.php";
|
||||
const char* hwId = "";
|
||||
int lastState = 0;
|
||||
|
||||
//Constant
|
||||
#define SONOFF 12
|
||||
#define SONOFF_LED 13
|
||||
#define SONOFF_BUT 0
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println("HW: " + String(hwId));
|
||||
pinMode(SONOFF, OUTPUT);
|
||||
pinMode(SONOFF_LED, OUTPUT);
|
||||
pinMode(SONOFF_BUT, OUTPUT);
|
||||
pinMode(SONOFF_BUT, INPUT);
|
||||
// WI-FI CONECTING
|
||||
WiFi.persistent(false);
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(ssid, pasw);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if(WiFi.status() != WL_CONNECTED){
|
||||
WiFi.begin(ssid, pasw);
|
||||
while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
|
||||
digitalWrite(SONOFF_LED, LOW); // LOW will turn on the LED
|
||||
delay(1000);
|
||||
digitalWrite(SONOFF_LED, HIGH); // HIGH will turn off the LED
|
||||
delay(1000);
|
||||
}
|
||||
Serial.println("\nCONECTED TO WIFI");
|
||||
Serial.println("IP: " + String(WiFi.localIP()));
|
||||
}
|
||||
|
||||
bool buttonState = digitalRead(SONOFF_BUT);
|
||||
HTTPClient http;
|
||||
http.begin(server);
|
||||
http.addHeader("Content-Type", "text/plain"); //Specify content-type header
|
||||
String requestJson = "{";
|
||||
requestJson += "\"tocken\":\"" + String(hwId) + "\"";
|
||||
|
||||
if (buttonState == true) {
|
||||
requestJson += ",";
|
||||
requestJson += "\"on/off\":{";
|
||||
requestJson += "\"value\":\"" + String(~lastState) + "\",";
|
||||
requestJson += "\"unit\":\"\"";
|
||||
requestJson += "}";
|
||||
}
|
||||
|
||||
while(buttonState == true) {
|
||||
delay(50); // keeps a small delay
|
||||
}
|
||||
|
||||
requestJson += "}";
|
||||
Serial.println("JSON: " + requestJson);
|
||||
|
||||
int httpCode = http.POST(requestJson);
|
||||
String payload = http.getString(); //Get the response payload
|
||||
|
||||
Serial.println("HTTP CODE: " + String(httpCode) + ""); //Print HTTP return code
|
||||
Serial.println("HTTP BODY: " + String(payload) + ""); //Print request response payload
|
||||
|
||||
DynamicJsonDocument doc(1024);
|
||||
deserializeJson(doc, payload);
|
||||
|
||||
string hostname = doc["hostname"];
|
||||
WiFi.hostname(hostname);
|
||||
|
||||
int state = doc["state"];
|
||||
|
||||
if (state == 1 && lastState == 0) {
|
||||
Serial.println("ON");
|
||||
digitalWrite(SONOFF, HIGH); // Turn the LED on by making the voltage LOW
|
||||
digitalWrite(SONOFF_LED, LOW); // Turn the LED on by making the voltage LOW
|
||||
} else {
|
||||
Serial.println("OFF");
|
||||
digitalWrite(SONOFF, LOW); // Turn the LED on by making the voltage LOW
|
||||
digitalWrite(SONOFF_LED, HIGH); // Turn the LED on by making the voltage LOW
|
||||
}
|
||||
|
||||
lastState = state;
|
||||
delay(1000);
|
||||
}
|
94
_FIRMWARE/firmwares/Sonoff_Basic/ESP_END_POINT.ino
Normal file
94
_FIRMWARE/firmwares/Sonoff_Basic/ESP_END_POINT.ino
Normal file
@@ -0,0 +1,94 @@
|
||||
//Includes
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266HTTPClient.h>
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
//Variables
|
||||
const char* ssid = "";
|
||||
const char* pasw = "";
|
||||
const char* server = "http://ESP:ESP@dev.steelants.cz/projekty/rest_vasek/api/out.php";
|
||||
const char* hwId = "";
|
||||
int lastState = 0;
|
||||
|
||||
//Constant
|
||||
#define SONOFF 12
|
||||
#define SONOFF_LED 13
|
||||
#define SONOFF_BUT 0
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println("HW: " + String(hwId));
|
||||
pinMode(SONOFF, OUTPUT);
|
||||
pinMode(SONOFF_LED, OUTPUT);
|
||||
pinMode(SONOFF_BUT, OUTPUT);
|
||||
pinMode(SONOFF_BUT, INPUT);
|
||||
// WI-FI CONECTING
|
||||
WiFi.persistent(false);
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(ssid, pasw);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if(WiFi.status() != WL_CONNECTED){
|
||||
WiFi.begin(ssid, pasw);
|
||||
while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
|
||||
digitalWrite(SONOFF_LED, LOW); // LOW will turn on the LED
|
||||
delay(1000);
|
||||
digitalWrite(SONOFF_LED, HIGH); // HIGH will turn off the LED
|
||||
delay(1000);
|
||||
}
|
||||
Serial.println("\nCONECTED TO WIFI");
|
||||
Serial.println("IP: " + String(WiFi.localIP()));
|
||||
}
|
||||
|
||||
bool buttonState = digitalRead(SONOFF_BUT);
|
||||
HTTPClient http;
|
||||
http.begin(server);
|
||||
http.addHeader("Content-Type", "text/plain"); //Specify content-type header
|
||||
String requestJson = "{";
|
||||
requestJson += "\"tocken\":\"" + String(hwId) + "\"";
|
||||
|
||||
if (buttonState == true) {
|
||||
requestJson += ",";
|
||||
requestJson += "\"on/off\":{";
|
||||
requestJson += "\"value\":\"" + String(~lastState) + "\",";
|
||||
requestJson += "\"unit\":\"\"";
|
||||
requestJson += "}";
|
||||
}
|
||||
|
||||
while(buttonState == true) {
|
||||
delay(50); // keeps a small delay
|
||||
}
|
||||
|
||||
requestJson += "}";
|
||||
Serial.println("JSON: " + requestJson);
|
||||
|
||||
int httpCode = http.POST(requestJson);
|
||||
String payload = http.getString(); //Get the response payload
|
||||
|
||||
Serial.println("HTTP CODE: " + String(httpCode) + ""); //Print HTTP return code
|
||||
Serial.println("HTTP BODY: " + String(payload) + ""); //Print request response payload
|
||||
|
||||
DynamicJsonDocument doc(1024);
|
||||
deserializeJson(doc, payload);
|
||||
|
||||
string hostname = doc["device"]["hostname"];
|
||||
sleepTime = doc["device"]["sleepTime"];
|
||||
|
||||
WiFi.hostname(hostname);
|
||||
|
||||
int state = doc["state"];
|
||||
|
||||
if (state == 1 && lastState == 0) {
|
||||
Serial.println("ON");
|
||||
digitalWrite(SONOFF, HIGH); // Turn the LED on by making the voltage LOW
|
||||
digitalWrite(SONOFF_LED, LOW); // Turn the LED on by making the voltage LOW
|
||||
} else {
|
||||
Serial.println("OFF");
|
||||
digitalWrite(SONOFF, LOW); // Turn the LED on by making the voltage LOW
|
||||
digitalWrite(SONOFF_LED, HIGH); // Turn the LED on by making the voltage LOW
|
||||
}
|
||||
|
||||
lastState = state;
|
||||
delay(1000);
|
||||
}
|
94
_FIRMWARE/firmwares/Sonoff_S20/ESP_END_POINT.ino
Normal file
94
_FIRMWARE/firmwares/Sonoff_S20/ESP_END_POINT.ino
Normal file
@@ -0,0 +1,94 @@
|
||||
//Includes
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266HTTPClient.h>
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
//Variables
|
||||
const char* ssid = "";
|
||||
const char* pasw = "";
|
||||
const char* server = "httpa://dev.steelants.cz/vasek/home/api.php";
|
||||
const char* hwId = "";
|
||||
int lastState = 0;
|
||||
int reconectAtemptsMax = 10; //time to wait before restart
|
||||
|
||||
//Constant
|
||||
#define SONOFF 12
|
||||
#define SONOFF_LED 13
|
||||
#define SONOFF_BUT 0
|
||||
HTTPClient http;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println("HW: " + String(hwId));
|
||||
pinMode(SONOFF, OUTPUT);
|
||||
pinMode(SONOFF_LED, OUTPUT);
|
||||
pinMode(SONOFF_BUT, OUTPUT);
|
||||
pinMode(SONOFF_BUT, INPUT);
|
||||
|
||||
WiFi.persistent(false);
|
||||
WiFi.mode(WIFI_STA);
|
||||
|
||||
WiFi.setAutoConnect (true);
|
||||
WiFi.setAutoReconnect (true);
|
||||
|
||||
WiFi.begin(ssid, pasw);
|
||||
http.begin(server);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
int reconectAtempts = 0;
|
||||
while(WiFi.status() != WL_CONNECTED){
|
||||
if (reconectAtemptsMax == reconectAtempts) {
|
||||
ESP.restart();
|
||||
}
|
||||
WiFi.begin(ssid, pasw);
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
bool buttonState = digitalRead(SONOFF_BUT);
|
||||
|
||||
http.addHeader("Content-Type", "text/plain"); //Specify content-type header
|
||||
|
||||
StaticJsonBuffer<1024> jsonContent;
|
||||
jsonContent["token"] = hwId;
|
||||
|
||||
if (buttonState){
|
||||
jsonContent["values"]["on/off"]["value"] = lastState;
|
||||
jsonContent["values"]["on/off"]["unit"] = '';
|
||||
while(buttonState) {
|
||||
delay(100);
|
||||
}
|
||||
}
|
||||
|
||||
String requestJson = "";
|
||||
serializeJson(jsonContent, requestJson);
|
||||
jsonContent.clean();
|
||||
Serial.println("JSON: " + requestJson);
|
||||
|
||||
int httpCode = http.POST(jsonContent);
|
||||
String payload = http.getString(); //Get the response payload
|
||||
|
||||
Serial.println("HTTP CODE: " + String(httpCode) + ""); //Print HTTP return code
|
||||
Serial.println("HTTP BODY: " + String(payload) + ""); //Print request response payload
|
||||
|
||||
deserializeJson(doc, payload);
|
||||
|
||||
string hostname = doc["device"]["hostname"];
|
||||
|
||||
WiFi.hostname(hostname);
|
||||
|
||||
int state = doc["state"];
|
||||
|
||||
if (state == 1 && lastState == 0) {
|
||||
Serial.println("ON");
|
||||
digitalWrite(SONOFF, HIGH); // Turn the LED on by making the voltage LOW
|
||||
digitalWrite(SONOFF_LED, LOW); // Turn the LED on by making the voltage LOW
|
||||
} else {
|
||||
Serial.println("OFF");
|
||||
digitalWrite(SONOFF, LOW); // Turn the LED on by making the voltage LOW
|
||||
digitalWrite(SONOFF_LED, HIGH); // Turn the LED on by making the voltage LOW
|
||||
}
|
||||
|
||||
lastState = state;
|
||||
delay(1000);
|
||||
}
|
BIN
_FIRMWARE/libs/libraries.zip
Normal file
BIN
_FIRMWARE/libs/libraries.zip
Normal file
Binary file not shown.
Reference in New Issue
Block a user