Hi Everyone I still learning Blynk and coding skill. I try searching the similar issue thread through Blynk Forum and Google, I did not find the solution yet, I had use many method but it nothing happen, please kindly help to identify the issue.
About My Project:
My project is about Development of Automatic Shoe Rack with Ultraviolet (UV) and Dryer Apparatus. For open and close the rack just press the button from blynk and it open and close the rack.After that next choose button for Auto or Manual. For example i choose Auto the choose what type of choose. When press fabric then heater will on 30 minutes with time had been set and turn off go for the next UV Light for 10 minutes. After that All will set off.
Problem:
The problem is when i set delay below than 1 minutes it work well then if i set more than 1 minutes ,it always repeat (after finish dry go to UV light then after UV light it always go to heater again).What i want is to make it not repeat.
I had set button for (fabric) in blynk push not switch.But it not turn off when i look at blynk it in low condition.
What i had done:
i had use time interval but it not go to my direction that had been set
void Autol()
{
if(button2==1&&selectmode==1)
{
digitalWrite(4,LOW);//Heater On
digitalWrite(2,HIGH);//UV Light Off
timer.setInterval(60000, reconnectBlynk);
}
else
{
digitalWrite(2,HIGH);//UV Light OFF
digitalWrite(4,HIGH);//Heater OFF
}
}
void reconnectBlynk()
{
digitalWrite(2,LOW);//UV Light On
digitalWrite(4,HIGH);//Heater off Off
timer.setInterval(30000, Auto);
}
Hardware:
- NodeMcu Amica
- Heater
- UV Light
- 5V Relay
Blynk Library: 0.6.1
Blynk App Version: V2.27.3
** NODEMCU Lua IoT I2C ESP8266 Wifi Controller Board ESP-12 CP2102**
Blynk Widget:
- Button
Wire Connection:
D0: 5V Relay(open linear actual motor)
D1: 5V Relay(close linear actual moto)
D2: 5V Relay(Heater)
D4: 5V Relay(UV Light)
Skecth
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <BlynkSimpleEsp8266.h>
#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>
#include <SPI.h>
#include <DHT.h>
char auth[] = "0d2e2960f823481f8f2940a30b1a4bdc";
char ssid[] = "nikzhafran";
char pass[] = "678250nik";
int timer2; //hidup motor Blynk
int timer3; //mati motor Blynk
int timer4; //hidup motor Blynk
int timer5; //mati motor Blynk
int timer6; //hidup motor Blynk
int timer7; //mati motor Blynk
int button2;
int selectmode; //Select Mode for Auto or Manual
int openmotor; //open the motor
int closemotor; //close the motor
SimpleTimer timer;
void setup()
{
Serial.begin(115200); // See the connection status in Serial Monitor
Blynk.begin(auth, ssid, pass);
pinMode(16,OUTPUT); //output for open motor
pinMode(5,OUTPUT); //output for close motor
pinMode(4,OUTPUT); //output for heater
pinMode(2,OUTPUT); //output UV LIGHT
digitalWrite(16, HIGH );
digitalWrite(5, HIGH );
digitalWrite(4, HIGH );
digitalWrite(2, HIGH );
}
void openmotor1() //open linear actual motor
{
if(openmotor==1)
{
digitalWrite(16, LOW );//Motor 16 open
}
}
void openmotor2()//open linear actual motor
{
if(openmotor==0)
{
digitalWrite(16, HIGH );//Motor 16 close
}
}
void closemotor1() //close linear actual motor
{
if(closemotor==1)
{
digitalWrite(5, LOW ); //Motor 5 open
}
}
void closemotor2() //close linear actual motor
{
if(closemotor==0)
{
digitalWrite(5, HIGH );//Motor 5 close
}
}
void Auto()
{
if(button2==1&&selectmode==1)
{
digitalWrite(4,LOW);//Heater On
digitalWrite(2,HIGH);//UV Light OFF
delay(200); //i had put 60000 but it always repeat
digitalWrite(2,LOW);//UV Light ON
digitalWrite(4,HIGH);//Heater OFF
delay(200); //i had put 60000 but it always repeat
}
else if (button2==0&&selectmode==1)
{
digitalWrite(2,HIGH);//UV Light OFF
digitalWrite(4,HIGH);//Heater OFF
}
}
void Manual()
{
digitalWrite(4,HIGH);//not complete yet
}
//..........................................................................................................................................
void loop()
{
Blynk.run(); // Initiates Blynk
timer.run(); // Initiates SimpleTimer
}
BLYNK_WRITE(V4)
{
openmotor = param.asInt(); // Get the state of the Button for opeen motor
if(openmotor ==1){
timer.disable(timer3); // Disables the timer3
timer2=timer.setInterval(1000L, openmotor1); // Setup a function to be called every 1000 ms
}
else
{
timer.disable(timer2); //Disables the timer2
timer3=timer.setInterval(1000L, openmotor2); // Setup a function to be called every 1000 ms
}
}
BLYNK_WRITE(V5)
{
closemotor= param.asInt(); // Get the state of the Button for close motor
if(closemotor ==1){
timer.disable(timer5); // Disables the timer5
timer4=timer.setInterval(1000L, closemotor1); // Setup a function to be called every 1000 ms
}
else
{
timer.disable(timer4); //Disables the timer4
timer5=timer.setInterval(1000L, closemotor2); // Setup a function to be called every 1000 ms
}
}
BLYNK_WRITE(V6) //Select Mode
{
selectmode = param.asInt(); // Get the state of the Button for selectmode
if(selectmode ==1){
timer.disable(timer7); // Disables the timer7
timer6=timer.setInterval(1000L, Auto); // Setup a function to be called every 1000 ms
}
else
{
timer.disable(timer6); //Disables the timer6
timer7=timer.setInterval(1000L, Manual); // Setup a function to be called every 1000 ms
}
}
BLYNK_WRITE(V7) // Case 1 ON OFF fabric
{
button2 = param.asInt(); // Get the state of the VButton for Case 1 ONOFF
}
BLYNK_CONNECTED()
{
Blynk.syncVirtual(V4); //Open Motor
Blynk.syncVirtual(V5); //Close Motor
Blynk.syncVirtual(V6); //Select Mode
Blynk.syncVirtual(V7); //Fabric button
}