-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit decc7e4
Showing
11 changed files
with
1,301 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Start-Stop-Generaor | ||
|
||
Добро пожаловать в проект контроллера ESP32 для автостарта генератора ELP LH45iE. | ||
|
||
Логика автоматической работы: Генератор запускается(4 попытки) спустя 3 мин. после отключения напряжения с города и остнавливается спустя 1 мин. после влючения напряжения города. | ||
|
||
Описание состояния RGB индикатора: | ||
Белый мигает - есть напряжение с города и подключен WiFi | ||
Розовый мигает - есть напряжение с города, но не подключен WiFi | ||
Синий горит - автостарт генератора | ||
Жёлто-красный мигает - пропало напряжение с города | ||
Зеленый-красный мигает - если бензо-клапан закрыт, но генератор работает | ||
|
||
Для управления контроллером используйте следующий команды: | ||
/gen_start : запустить генератор | ||
/gen_stop : заглушить генератор | ||
/status : получить сотояние генератора, WiFi, получить температуру/влажность/давление с датчиков у контроллера и генратора | ||
|
||
В zip/v6_RELISE_bin.zip три бинарника bootloader.bin, partitions.bin, firmware.bin - имя сети WIFI: test пароль: test1234 доступ по http://ip/ | ||
|
||
В плнах отправлять в zabbix и перейти на FastBot2 для включения ESP.restart()(которы сейчас уходит в bootloop) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<title>ESP IOT DASHBOARD</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" charset="utf-8"> | ||
<link rel="stylesheet" type="text/css" href="style.css"> | ||
<link rel="icon" type="image/png" href="favicon.png"> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css"> | ||
</head> | ||
<body> | ||
<div class="topnav"> | ||
<h1>ESP32-DevKitC-1 WEB SERVER - состояние реле старта генератора ELP LH45iE</h1> | ||
</div> | ||
|
||
<p class="text">Напряжение с города: <span id="network"></span></p> | ||
<p class="text">Напряжение с генератора: <span id="generator"></span></p> | ||
|
||
<div class="content"> | ||
<div class="card-grid"> | ||
<div class="card"> | ||
<p class="card-title"><i class="fas fa-lightbulb"></i>Запуск генератора</p> | ||
<label class="switch"> | ||
<input type="checkbox" onchange="toggleGenerator(this)" id="generatorControl"> | ||
<span class="slider"></span> | ||
</label> | ||
<p class="state">State: <span id="generatorState"></span></p> | ||
</div> | ||
<hr> | ||
<div class="card"> | ||
<p class="card-title"><i class="fas fa-lightbulb"></i>Реле Бензоклапан (GPIO 35)</p> | ||
<label class="switch"> | ||
<input type="checkbox" onchange="toggleCheckbox(this)" id="35"> | ||
<span class="slider"></span> | ||
</label> | ||
<p class="state">State: <span id="35s"></span></p> | ||
</div> | ||
|
||
<div class="card"> | ||
<p class="card-title"><i class="fas fa-lightbulb"></i>Реле START (GPIO 36)</p> | ||
<label class="switch"> | ||
<input type="checkbox" onchange="toggleCheckbox(this)" id="36"> | ||
<span class="slider"></span> | ||
</label> | ||
<p class="state">State: <span id="36s"></span></p> | ||
</div> | ||
|
||
<div class="card"> | ||
<p class="card-title"><i class="fas fa-lightbulb"></i>Кнопка START (GPIO 37)</p> | ||
<label class="switch"> | ||
<input type="checkbox" onchange="toggleCheckbox(this)" id="37"> | ||
<span class="slider"></span> | ||
</label> | ||
<p class="state">State: <span id="37s"></span></p> | ||
</div> | ||
|
||
<div class="card"> | ||
<p class="card-title"><i class="fas fa-lightbulb"></i>Запас (GPIO 38)</p> | ||
<label class="switch"> | ||
<input type="checkbox" onchange="toggleCheckbox(this)" id="38"> | ||
<span class="slider"></span> | ||
</label> | ||
<p class="state">State: <span id="38s"></span></p> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
|
||
<div class="content"> | ||
<div class="card-grid"> | ||
<div class="card"> | ||
<p class="card-title"><i class="fas fa-thermometer-threequarters" style="color:#059e8a;"></i> Температура у контроллера</p> | ||
<p class="reading"><span id="temperature1"></span> °C</p> | ||
</div> | ||
<div class="card"> | ||
<p class="card-title"> Влажность у контроллера</p> | ||
<p class="reading"><span id="humidity1"></span> %</p> | ||
</div> | ||
<div class="card"> | ||
<p class="card-title"> Давление у контроллера</p> | ||
<p class="reading"><span id="pressure1"></span> hpa</p> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="content"> | ||
<div class="card-grid"> | ||
<div class="card"> | ||
<p class="card-title"><i class="fas fa-thermometer-threequarters" style="color:#059e8a;"></i> Температура у генератора</p> | ||
<p class="reading"><span id="temperature2"></span> °C</p> | ||
</div> | ||
<div class="card"> | ||
<p class="card-title"> Влажность у генератора</p> | ||
<p class="reading"><span id="humidity2"></span> %</p> | ||
</div> | ||
<div class="card"> | ||
<p class="card-title"> Давление у генератора</p> | ||
<p class="reading"><span id="pressure2"></span> hpa</p> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<script src="/script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
var gateway = `ws://${window.location.hostname}/ws`; | ||
var websocket; | ||
window.addEventListener('load', onLoad); | ||
|
||
function onLoad(event) { | ||
initWebSocket(); | ||
} | ||
|
||
function getReadings(){ | ||
websocket.send("getReadings"); | ||
} | ||
|
||
function initWebSocket() { | ||
console.log('Trying to open a WebSocket connection...'); | ||
websocket = new WebSocket(gateway); | ||
websocket.onopen = onOpen; | ||
websocket.onclose = onClose; | ||
websocket.onmessage = onMessage; | ||
} | ||
|
||
function onOpen(event) { | ||
console.log('Connection opened'); | ||
websocket.send("states"); | ||
//getOutputStates(); | ||
} | ||
|
||
function onClose(event) { | ||
console.log('Connection closed'); | ||
setTimeout(initWebSocket, 2000); | ||
} | ||
|
||
function onMessage(event) { | ||
var myObj = JSON.parse(event.data); | ||
|
||
// var keys = Object.keys(myObj); | ||
// for (var i = 0; i < keys.length; i++){ | ||
// var key = keys[i]; | ||
// document.getElementById(key).innerHTML = myObj[key]; | ||
// } | ||
console.log(myObj); | ||
for (i in myObj.gpios){ | ||
var output = myObj.gpios[i].output; | ||
var state = myObj.gpios[i].state; | ||
console.log(output); | ||
console.log(state); | ||
if (state == "1"){ | ||
document.getElementById(output).checked = true; | ||
document.getElementById(output+"s").innerHTML = "ON"; | ||
} | ||
else{ | ||
document.getElementById(output).checked = false; | ||
document.getElementById(output+"s").innerHTML = "OFF"; | ||
} | ||
} | ||
console.log(event.data); | ||
} | ||
|
||
// Send Requests to Control GPIOs | ||
function toggleCheckbox (element) { | ||
console.log(element.id); | ||
websocket.send(element.id); | ||
if (element.checked){ | ||
document.getElementById(element.id+"s").innerHTML = "ON"; | ||
} | ||
else { | ||
document.getElementById(element.id+"s").innerHTML = "OFF"; | ||
} | ||
} | ||
|
||
function toggleGenerator(element) { | ||
const isChecked = element.checked; | ||
if (isChecked) { | ||
// Вызов функции для запуска генератора | ||
fetch('/start_generator', { method: 'POST' }); | ||
document.getElementById('generatorState').innerText = "Запущен"; | ||
} else { | ||
// Вызов функции для остановки генератора | ||
fetch('/stop_generator', { method: 'POST' }); | ||
document.getElementById('generatorState').innerText = "Остановлен"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
html { | ||
font-family: Arial, Helvetica, sans-serif; | ||
text-align: center; | ||
} | ||
h1 { | ||
font-size: 1.8rem; | ||
color: white; | ||
} | ||
.topnav { | ||
overflow: hidden; | ||
background-color: #0A1128; | ||
} | ||
body { | ||
margin: 0; | ||
} | ||
.content { | ||
padding: 50px; | ||
} | ||
.card-grid { | ||
max-width: 600px; | ||
margin: 0 auto; | ||
display: grid; | ||
gap: 2rem; | ||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); | ||
} | ||
.card { | ||
background-color: white; | ||
box-shadow: 2px 2px 12px 1px rgba(140,140,140,.5); | ||
} | ||
.card-title { | ||
font-size: 1.2rem; | ||
font-weight: bold; | ||
color: #034078 | ||
} | ||
.state { | ||
font-size: 1.2rem; | ||
color:#1282A2; | ||
} | ||
.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: 50px | ||
} | ||
.slider:before { | ||
position: absolute; | ||
content: ""; | ||
height: 52px; | ||
width: 52px; | ||
left: 8px; | ||
bottom: 8px; | ||
background-color: #fff; | ||
-webkit-transition: .4s; | ||
transition: .4s; | ||
border-radius: 50px; | ||
} | ||
.reading { | ||
font-size: 1.2rem; | ||
color: #1282A2; | ||
} | ||
.text { | ||
text-align: left; | ||
font-size: 1.2rem; | ||
color: #0a19a1; | ||
} | ||
input:checked+.slider { | ||
background-color: #b30000; | ||
} | ||
input:checked+.slider:before { | ||
-webkit-transform: translateX(52px); | ||
-ms-transform: translateX(52px); | ||
transform: translateX(52px); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class button { | ||
public: | ||
button (byte pin) { | ||
_pin = pin; | ||
pinMode(_pin, INPUT_PULLUP); | ||
} | ||
bool click() { | ||
bool btnState = digitalRead(_pin); | ||
if (!btnState && !_flag && millis() - _tmr >= 100) { | ||
_flag = true; | ||
_tmr = millis(); | ||
return true; | ||
} | ||
if (!btnState && _flag && millis() - _tmr >= 500) { | ||
_tmr = millis(); | ||
return true; | ||
} | ||
if (btnState && _flag) { | ||
_flag = false; | ||
_tmr = millis(); | ||
} | ||
return false; | ||
} | ||
private: | ||
byte _pin; | ||
uint32_t _tmr; | ||
bool _flag; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef SECRETS_H | ||
#define SECRETS_H | ||
|
||
const char* SEC_WIFI_SSID = "your_wifi_ssid"; //Установите имя сети WIFI | ||
const char* SEC_WIFI_PASS = "your_wifi_password"; //Установите пароль сети WIFI | ||
const char* SEC_BOT_TOKEN = "your_bot_token"; //Установите bot token | ||
// Используйте @myidbot, чтобы получить ID пользователя или группы | ||
// Помните, что бот сможет вам писать только после нажатия вами кнопки /start | ||
const char* CHAT_ID = "your_chat_id"; //Установите chat id | ||
const char* SEC_NAME_BOT= "name_bot"; // Установите имя бота или оставьте без изменений | ||
//const char* SEC_TG_NAMES= "@tg_name1 @tg_name2"; | ||
const char* SEC_TG_NAMES= ""; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
; PlatformIO Project Configuration File | ||
; | ||
; Build options: build flags, source filter | ||
; Upload options: custom upload port, speed and extra flags | ||
; Library options: dependencies, extra library storages | ||
; Advanced options: extra scripting | ||
; | ||
; Please visit documentation for the other options and examples | ||
; https://docs.platformio.org/page/projectconf.html | ||
|
||
[platformio] | ||
default_envs = GEN-esp32-s3-devkitc-1 | ||
|
||
[env:GEN-esp32-s3-devkitc-1] | ||
platform = espressif32 | ||
board = esp32-s3-devkitc-1 | ||
framework = arduino | ||
upload_speed = 921600 | ||
monitor_speed = 115200 | ||
lib_ldf_mode = deep | ||
lib_deps = | ||
me-no-dev/AsyncTCP@^1.1.1 | ||
ayushsharma82/ElegantOTA | ||
Arduino_JSON | ||
https://github.com/Abdurraziq/ZMPT101B-arduino | ||
https://github.com/adafruit/Adafruit_NeoPixel | ||
mathieucarbou/ESPAsyncWebServer | ||
https://github.com/adafruit/Adafruit_BME280_Library | ||
;gyverlibs/FastBot2@^1.0.10 | ||
lib_extra_dirs = | ||
build_flags = -DELEGANTOTA_USE_ASYNC_WEBSERVER=1 |
Oops, something went wrong.