mirror of
https://github.com/Skysamara/hydro.git
synced 2025-12-06 06:16:01 +00:00
Работает, кроме автополива
This commit is contained in:
parent
6bbc20548e
commit
24a4776ea1
@ -14,8 +14,8 @@
|
|||||||
#define led_pin 2 // D4
|
#define led_pin 2 // D4
|
||||||
|
|
||||||
boolean led_status = 0;
|
boolean led_status = 0;
|
||||||
//float Temperature;
|
|
||||||
//float Humidity;
|
const int timeSleep = 60*1000*1000; // одна минута
|
||||||
|
|
||||||
DHT dht(DHTPin, DHTTYPE); // Инициализация датчика DHT
|
DHT dht(DHTPin, DHTTYPE); // Инициализация датчика DHT
|
||||||
BlynkTimer timer;
|
BlynkTimer timer;
|
||||||
|
|||||||
@ -3,11 +3,11 @@ class Pump
|
|||||||
unsigned long lastTime;
|
unsigned long lastTime;
|
||||||
int duration = 10; // Время полива **************************
|
int duration = 10; // Время полива **************************
|
||||||
|
|
||||||
int maxDuration; // Максимальное время полива
|
int maxDuration = 600; // Максимальное время полива 10 минут
|
||||||
int currentDuration; // Текущее время полива для отображения в приложении
|
int currentDuration; // Текущее время полива для отображения в приложении
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Pump(uint8_t address, uint8_t motor, uint32_t freq) {
|
Pump(uint8_t address, uint8_t motor, uint32_t freq) {
|
||||||
_m = new Motor(address, motor, freq);
|
_m = new Motor(address, motor, freq);
|
||||||
lastTime = millis();
|
lastTime = millis();
|
||||||
currentDuration = 0;
|
currentDuration = 0;
|
||||||
@ -15,33 +15,32 @@ class Pump
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Update() {
|
void Update() {
|
||||||
// if ((millis() - lastTime) > duration * 1000) // Пора выключать
|
if (((millis() - lastTime) > duration * 1000) // истекло установленное время
|
||||||
// {
|
|| ((millis() - lastTime) > maxDuration * 1000))// или превышено максимальное
|
||||||
// lastTime = millis();
|
{
|
||||||
// Serial.println("Update-stop");
|
lastTime = millis();
|
||||||
// _m -> setmotor(_STOP);
|
Serial.println("class Pump. void Stop()");
|
||||||
// }
|
_m -> setmotor(_STOP);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Start() {
|
void Start() {
|
||||||
// if (!IsON())
|
// if (!IsON())
|
||||||
// {
|
// {
|
||||||
Serial.print("Start! ");
|
Serial.print("class Pump. void Start() ");
|
||||||
Serial.println(duration);
|
Serial.println(duration);
|
||||||
lastTime = millis();
|
lastTime = millis();
|
||||||
_m -> setmotor(_CCW, 100);
|
_m -> setmotor(_CCW, 100);
|
||||||
// Update();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stop() {
|
void Stop() {
|
||||||
// if (IsON())
|
// if (IsON())
|
||||||
// {
|
// {
|
||||||
Serial.print("Stop! ");
|
Serial.print("class Pump. void Stop() ");
|
||||||
Serial.println(duration);
|
Serial.println(duration);
|
||||||
lastTime = millis();
|
lastTime = millis();
|
||||||
_m -> setmotor(_STOP);
|
_m -> setmotor(_STOP);
|
||||||
// Update();
|
// Update();
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +57,7 @@ class Pump
|
|||||||
|
|
||||||
void SetDuration(int d) {
|
void SetDuration(int d) {
|
||||||
duration = d;
|
duration = d;
|
||||||
Serial.print("SetDuration ");
|
Serial.print("void SetDuration(int d): ");
|
||||||
Serial.println(duration);
|
Serial.println(duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
46
y10_fun.ino
46
y10_fun.ino
@ -1,3 +1,8 @@
|
|||||||
|
void sleep(){
|
||||||
|
delay (200);
|
||||||
|
ESP.deepSleep(timeSleep);
|
||||||
|
}
|
||||||
|
|
||||||
void timerEvent()
|
void timerEvent()
|
||||||
{
|
{
|
||||||
read_DHT22();
|
read_DHT22();
|
||||||
@ -6,34 +11,35 @@ void timerEvent()
|
|||||||
|
|
||||||
void refreshApp()
|
void refreshApp()
|
||||||
{
|
{
|
||||||
|
while (Blynk.connect() == false){}; // Ждём подключения
|
||||||
Blynk.virtualWrite(V5, pump1.GetCurrentDuration());
|
Blynk.virtualWrite(V5, pump1.GetCurrentDuration());
|
||||||
// Blynk.virtualWrite(V4, pump1.IsON());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void read_DHT22()
|
void read_DHT22()
|
||||||
{
|
{
|
||||||
|
while (Blynk.connect() == false){}; // Ждём подключения
|
||||||
float Temperature = dht.readTemperature();
|
float Temperature = dht.readTemperature();
|
||||||
float Humidity = dht.readHumidity();
|
float Humidity = dht.readHumidity();
|
||||||
|
|
||||||
// Serial.print("Температура: ");
|
// Serial.print("Температура: ");
|
||||||
// Serial.println(Temperature, 2);
|
// Serial.println(Temperature, 2);
|
||||||
// Serial.print("Влажность: ");
|
// Serial.print("Влажность: ");
|
||||||
// Serial.println(Humidity, 2);
|
// Serial.println(Humidity, 2);
|
||||||
|
|
||||||
Blynk.virtualWrite(V3, Temperature);
|
Blynk.virtualWrite(V3, Temperature);
|
||||||
Blynk.virtualWrite(V2, Humidity);
|
Blynk.virtualWrite(V2, Humidity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPumpDuration(int v0){
|
void setPumpDuration(int v0) {
|
||||||
int d = v0;
|
int d = v0;
|
||||||
// pump1.SetDuration(d);
|
pump1.SetDuration(d);
|
||||||
Serial.print("Длительность: ");
|
Serial.print("setPumpDuration(int v0): ");
|
||||||
Serial.println(d);
|
Serial.println(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
void blynk_connected(){
|
void blynk_connected() {
|
||||||
Blynk.syncAll();
|
Blynk.syncAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,14 +48,14 @@ void blynk_connected(){
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
void readSettings() {
|
void readSettings() {
|
||||||
// int f = 0;
|
// int f = 0;
|
||||||
// EEPROM.get(0, f);
|
// EEPROM.get(0, f);
|
||||||
// pump1.setDuration(f);
|
// pump1.setDuration(f);
|
||||||
// Serial.print("EEPROM.get(0, f): ");
|
// Serial.print("EEPROM.get(0, f): ");
|
||||||
// Serial.println(f, 2);
|
// Serial.println(f, 2);
|
||||||
//
|
//
|
||||||
// EEPROM.write(0, 15);
|
// EEPROM.write(0, 15);
|
||||||
// EEPROM.get(0, f);
|
// EEPROM.get(0, f);
|
||||||
// Serial.print("EEPROM.write(0, f): ");
|
// Serial.print("EEPROM.write(0, f): ");
|
||||||
// Serial.println(f, 2);
|
// Serial.println(f, 2);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,10 +12,17 @@ BLYNK_WRITE(V1) // Установка времени старта полива
|
|||||||
// until you remove widget or stop project or
|
// until you remove widget or stop project or
|
||||||
// clean stop/start fields of widget
|
// clean stop/start fields of widget
|
||||||
|
|
||||||
Serial.print("Таймер: ");
|
Serial.print("BLYNK_WRITE(V1) // Установка времени старта полива: ");
|
||||||
|
Serial.println(param.asStr());
|
||||||
// Serial.println(pump1.GetCurrentDuration());
|
// Serial.println(pump1.GetCurrentDuration());
|
||||||
|
|
||||||
// pump1.Start();
|
if (param.asInt() == 1){
|
||||||
|
pump1.Start();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
pump1.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BLYNK_WRITE(V4) // Кнопка помпы 1
|
BLYNK_WRITE(V4) // Кнопка помпы 1
|
||||||
|
|||||||
13
z999_.ino
13
z999_.ino
@ -7,4 +7,17 @@ char auth[] = "Fdj2ndHfZmRirtgrgdrfh81fzPpfB0-";
|
|||||||
char ssid[] = "WIFI";
|
char ssid[] = "WIFI";
|
||||||
char pass[] = "132password";
|
char pass[] = "132password";
|
||||||
|
|
||||||
|
https://www.youtube.com/watch?v=gX71MupZQF4
|
||||||
|
Для погружения в сон соединить D0 и Reset!
|
||||||
|
https://habr.com/ru/post/257141/
|
||||||
|
И убрать светодиод
|
||||||
|
|
||||||
|
https://itnan.ru/post.php?c=2&p=130421
|
||||||
|
Про датчик влажности грунта и сон.
|
||||||
|
512 байт RTC памяти, которая прекрасно сохраняет данные в то время,
|
||||||
|
пока чип находится в режиме Deep sleep
|
||||||
|
|
||||||
|
https://habr.com/ru/post/411537/
|
||||||
|
Про железо почитать
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user