Make Multiple input from Virtual PIN

heloo, first i am sorry ifmy english is bad.

i have project using arduino uno with esp8266 and blynk for controling relay with timer in each relay, i using menu widget for chose from relay 1-4 and after that, i can set timer in each relay and if timer is active, then will triger led widget to turn on, but i new in arduino but i know little bit. First i use blynk_write(), but this can’t use multiple input vPin, so can i use blynk_write_default() for using multiple vpin??

for clearly this my code for set timer menu :

BLYNK_WRITE_DEFAULT() {
  int vPin = request.pin;
  
  if (vPin == 9){
    switch(param.asInt()) 
      {
      case 1:
        if (EEPROM.read(7)==0) { Blynk.virtualWrite(V11,0); led1.on(); }
        else { Blynk.virtualWrite(V11,1); led1.off(); }
        
        if (vPin == 11) {
          if (param.asInt()==0) {
             led1.on();EEPROM.write(7, 0);
             TimeInputParam t(param);     
             EEPROM.write(13,t.getStartHour());
             EEPROM.write(14,t.getStartMinute());
             EEPROM.write(15,t.getStopHour());
             EEPROM.write(16,t.getStopMinute());

             Serial.print(TR1a1);
             Serial.println(TR1a2);
          }
          else {
            led1.off();EEPROM.write(7, 1);
            EEPROM.write(13,00);
            EEPROM.write(14,00);
            EEPROM.write(15,00);
            EEPROM.write(16,00); 
          }
        }
      break;

      case 2:
        if (EEPROM.read(8)==0){Blynk.virtualWrite(V11,0); led2.on();}
        else {Blynk.virtualWrite(V11,1); led2.off();}
        
        if (vPin == 11) {
          if (param.asInt()==0) {
             led2.on();EEPROM.write(8, 0);
             TimeInputParam t(param);     
             EEPROM.write(17,t.getStartHour());
             EEPROM.write(18,t.getStartMinute());
             EEPROM.write(19,t.getStopHour());
             EEPROM.write(20,t.getStopMinute());
          }
          else {
            led2.off();EEPROM.write(8, 1);
            EEPROM.write(17,00);
            EEPROM.write(18,00);
            EEPROM.write(19,00);
            EEPROM.write(20,00);; 
          }
        }
      break;

      case 3:
        if (EEPROM.read(9)==0){Blynk.virtualWrite(V11,0); led3.on();}
        else {Blynk.virtualWrite(V11,1); led3.off();}
        
        if (vPin == 11) {
          if (param.asInt()==0) {
             led3.on();EEPROM.write(9, 0);
             TimeInputParam t(param);     
             EEPROM.write(21,t.getStartHour());
             EEPROM.write(22,t.getStartMinute());
             EEPROM.write(23,t.getStopHour());
             EEPROM.write(24,t.getStopMinute());
          }
          else {
            led3.off();EEPROM.write(9, 1);
            EEPROM.write(21,00);
            EEPROM.write(22,00);
            EEPROM.write(23,00);
            EEPROM.write(24,00); 
          }
        }
      break;

      case 4:
        if (EEPROM.read(10)==0){Blynk.virtualWrite(V11,0); led4.on();}
        else {Blynk.virtualWrite(V11,1); led4.off();}
        
        if (vPin == 11) {
          if (param.asInt()==0) {
             led4.on();EEPROM.write(10, 0);
             TimeInputParam t(param);     
             EEPROM.write(25,t.getStartHour());
             EEPROM.write(26,t.getStartMinute());
             EEPROM.write(27,t.getStopHour());
             EEPROM.write(28,t.getStopMinute());
          }
          else {
            led4.off();EEPROM.write(10, 1);
            EEPROM.write(25,00);
            EEPROM.write(26,00);
            EEPROM.write(27,00);
            EEPROM.write(28,00); 
          }
        }
      break;

      case 5:
        if (EEPROM.read(11)==0){Blynk.virtualWrite(V11,0); led5.on();}
        else {Blynk.virtualWrite(V11,1); led5.off();}
        
        if (vPin == 11) {
          if (param.asInt()==0) {
             led5.on();EEPROM.write(11, 0);
             TimeInputParam t(param);     
             EEPROM.write(29,t.getStartHour());
             EEPROM.write(30,t.getStartMinute());
             EEPROM.write(31,t.getStopHour());
             EEPROM.write(32,t.getStopMinute());
          }
          else {
            led5.off();EEPROM.write(11, 1);
            EEPROM.write(29,00);
            EEPROM.write(30,00);
            EEPROM.write(31,00);
            EEPROM.write(32,00); 
          }
        }
      break;

      case 6:
        if (EEPROM.read(11)==0){Blynk.virtualWrite(V11,0); led6.on();}
        else {Blynk.virtualWrite(V11,1); led6.off();}
        
        if (vPin == 11) {
          if (param.asInt()==0) {
             led6.on();EEPROM.write(12, 0);
             TimeInputParam t(param);     
             EEPROM.write(33,t.getStartHour());
             EEPROM.write(34,t.getStartMinute());
             EEPROM.write(35,t.getStopHour());
             EEPROM.write(36,t.getStopMinute());
          }
          else {
            led6.off();EEPROM.write(12, 1);
            EEPROM.write(33,00);
            EEPROM.write(34,00);
            EEPROM.write(35,00);
            EEPROM.write(36,00); 
          }
        }
      break;      
    }
  }
}

after upload to my hardware, this code not working and not give some feedback to my app, even just turn on led widget, so i think the problem is in my code.

and this is my code for triger the relay to turn on/off, sory if this code lot of false code (i am new in this) :


void TimerRelay(){
 String RTC = rtc.getHour()+rtc.getMinute();
 String R1on = TR1a1+TR1a2; String R1off = TR1b1+TR1b2; //tr1a1 for start hour, tr1a2 for  start minute, tr1b1 for stophour
 String R2on = TR2a1+TR2a2; String R2off = TR2b1+TR2b2;
 String R3on = TR3a1+TR3a2; String R3off = TR3b1+TR3b2;
 String R4on = TR4a1+TR4a2; String R4off = TR4b1+TR4b2;
 String R5on = TR5a1+TR5a2; String R5off = TR5b1+TR5b2;
 String R6on = TR6a1+TR6a2; String R6off = TR6b1+TR6b2;
 
  
  if(EEPROM.read(7==0)){  
    if(RTC==R1on){digitalWrite(relay1, LOW);Serial.println("Relay 1 ON via Timer");
    EEPROM.write(1, 0);}
    if(RTC==R1off){digitalWrite(relay1, HIGH);Serial.println("Relay 1 OFF via Timer");
    EEPROM.write(1, 1);}
  }

  if(EEPROM.read(8==0)){  
    if(RTC==R2on){digitalWrite(relay2, LOW);Serial.println("Relay 2 ON via Timer");
    EEPROM.write(2, 0);}
    if(RTC==R2off){digitalWrite(relay2, HIGH);Serial.println("Relay 2 OFF via Timer");
    EEPROM.write(2, 1);}
  }

  if(EEPROM.read(9==0)){  
    if(RTC==R3on){digitalWrite(relay3, LOW);Serial.println("Relay 3 ON via Timer");
    EEPROM.write(3, 0);}
    if(RTC==R3off){digitalWrite(relay3, HIGH);Serial.println("Relay 3 OFF via Timer");
    EEPROM.write(3, 1);}
  }

  if(EEPROM.read(10==0)){  
    if(RTC==R4on){digitalWrite(relay4, LOW);Serial.println("Relay 4 ON via Timer");
    EEPROM.write(4, 0);}
    if(RTC==R4off){digitalWrite(relay4, HIGH);Serial.println("Relay 4 OFF via Timer");
    EEPROM.write(4, 1);}
  }

   if(EEPROM.read(11==0)){  
    if(RTC==R5on){digitalWrite(relay5, LOW);Serial.println("Relay 5 ON via Timer");
    EEPROM.write(5, 0);}
    if(RTC==R5off){digitalWrite(relay5, HIGH);Serial.println("Relay 5 OFF via Timer");
    EEPROM.write(5, 1);}
  }
   
   if(EEPROM.read(12==0)){  
    if(RTC==R6on){digitalWrite(relay6, LOW);Serial.println("Relay 6 ON via Timer");
    EEPROM.write(6, 0);}
    if(RTC==R6off){digitalWrite(relay6, HIGH);Serial.println("Relay 6 OFF via Timer");
    EEPROM.write(6, 1);}
  }
}

maybe you can help me for fix this,

so thanks friend :slight_smile:

Hey welcome to the community!

So your code is incorrect, but easy to remedy.

You need to fix your BLYNK_WRITE function because im not sure where you got request.pin from?

Edit: re-read your question… update coming shortly

Edit-Edit: okay looking at your code… I think you’re quite confused about how to do this.

Here is a basic example of how multiple BLYNK_WRITE works…

BLYNK_WRITE(V10) { // V10 is the virtual pin that toggles this operation
  if (param.asInt()) { // check if the widget data is true. this would be an int value if using a slider, but 0/1 logic applies
    // do something if HIGH/1/TRUE
  } else {
    // do something if LOW/0/FALSE
  }
}

BLYNK_WRITE(V11) { // V11 is the virtual pin that toggles this operation
  if (param.asInt()) { // check if the widget data is true. this would be an int value if using a slider, but 0/1 logic applies
    // do something if HIGH/1/TRUE
  } else {
    // do something if LOW/0/FALSE
  }
}

BLYNK_WRITE(V12) { // V12 is the virtual pin that toggles this operation
  if (param.asInt()) { // check if the widget data is true. this would be an int value if using a slider, but 0/1 logic applies
    // do something if HIGH/1/TRUE
  } else {
    // do something if LOW/0/FALSE
  }
}

So taking a bit of your example, this would toggle when you assign a widget to V11 and make an action… but press a button or move a slider. param.asInt() is the value from a slider, or 0/1 is a button.

BLYNK_WRITE(V11) {
  if (param.asInt()) {
    led1.off(); 
    EEPROM.write(7, 1);
    EEPROM.write(13, 00);
    EEPROM.write(14, 00);
    EEPROM.write(15, 00);
    EEPROM.write(16, 00);
  } else {
    led1.on(); 
    EEPROM.write(7, 0);
    TimeInputParam t(param.asInt()); // must use param.asInt()
    EEPROM.write(13, t.getStartHour());
    EEPROM.write(14, t.getStartMinute());
    EEPROM.write(15, t.getStopHour());
    EEPROM.write(16, t.getStopMinute());
    Serial.print(TR1a1);
    Serial.println(TR1a2);
  }
}

This is used when overriding the default version BLYNK_WRITE_DEFAULT to know what virtual pin got triggered :slight_smile:

1 Like

You should really rethink all those writes to EEPROM, you will burn through it pretty quickly depending on use of course.
I think I read somewhere that the EEPROM on the esp8266 can handle about 100 000 erase/writes per bit.

Edit: Might not be the worst for your current sketch, I don’t know to be honest, but if you start writing 100s/1000s of times per day it will tear eventually. Best is to avoid learning this practice in my opinion :stuck_out_tongue:

Thanks jamin for your answer and give some idea, today i make change on my code, so not use BLYNK_WRITE_DEFAULT(), and Use BLYNK_WRITE(), i will post my new code

Yes i know EEPROM have limit in read/write data, and i save data in EEPROM from arduino. The purpose i use this EEPROM is becasue i want the hardware running the last state from relay and timer from memory, so if some time the device turn off because power problem, this device can read from EEPROM and running the last state without conect to internet for sync to server. Maybe i should use eeprom.update() so the program not always write data to memory. Correct if i am wrong :slight_smile:

It should suffice that you read eeprom and only save if memory doesn’t match current value

And here the full sketch after trial and error, the result for compiling is done and no error, but not already upload to hardware. but if you found some problem with my code its will helpfull for me

//#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <SimpleTimer.h>
#include <EEPROM.h>
#include <EEPROMAnything.h>
#include <DS1302.h>
#include <DHT.h>
#include <SoftwareSerial.h>

#define ESP8266_BAUD 9600

SoftwareSerial EspSerial(13,12); // RX, TX
ESP8266 wifi(&EspSerial);
DS1302 rtc(A1, A2, A3); // Set pins:  CE/RST,IO/DATA,CLK
Time t = rtc.getTime();
DHT dht;
SimpleTimer timer;

char auth[] = "xxxxxxxxxxxxxxxxxxxxxxx"; //token dari blynk
char ssid[] = "xxxxxxxxxx";                            // nama akses point
char pass[] = "xxxxxxxxxxxx";                         // password akses point

//inisialisasi port relay
const int relay1 =  3; const int relay2 =  4;
const int relay3 =  5; const int relay4 =  6;

char Relay,jamStart,menitStart,jamStop,menitStop,statusT;

WidgetLED led1(V12); WidgetLED led2(V13);
WidgetLED led3(V14); WidgetLED led4(V15); 
WidgetLED led5(V16); WidgetLED led6(V17);

//inisialisasi memori 
byte State1 = EEPROM.read(1); byte State2 = EEPROM.read(2);
byte State3 = EEPROM.read(3); byte State4 = EEPROM.read(4);
byte State5 = EEPROM.read(5); byte State6 = EEPROM.read(6);

struct config_t
{
  char jamStart,menitStart,jamStop,menitStop,statusT;
} cfg;

int startTimer = (jamStart*60+menitStart);
int stopTimer = (jamStop*60+menitStop);
int rtcNow = (t.hour*60+t.min);

byte timerRelay1 = EEPROM_readAnything(7,cfg); 
byte timerRelay2 = EEPROM_readAnything(8,cfg); 
byte timerRelay3 = EEPROM_readAnything(9,cfg); 
byte timerRelay4 = EEPROM_readAnything(10,cfg); 
byte timerRelay5 = EEPROM_readAnything(11,cfg); 
byte timerRelay6 = EEPROM_readAnything(12,cfg);

void setup()
{
  // Debug console
  Serial.begin(9600);

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  dht.setup(2);
  delay(10);
  
  pinMode(relay1, OUTPUT); 
  pinMode(relay2, OUTPUT);
  pinMode(relay3, OUTPUT);
  pinMode(relay4, OUTPUT);
  
  digitalWrite(relay1,HIGH);
  digitalWrite(relay2,HIGH);
  digitalWrite(relay3,HIGH);
  digitalWrite(relay4,HIGH);

 

  Serial.println (F("Perangkat menyala...")); delay(1000);
  // membaca status terakhir relay;
  Serial.println (F("Cek status terakhir...")); delay(1000);
  ReadEEPROM (); delay(2000);
 
  Serial.print(F("menghubungkan ke SSID: "));
  Serial.println(ssid);
  
  //memulai koneksi ke apn
  Blynk.begin(auth, wifi, ssid, pass);
  
  Serial.print (F("terhubung ke SSID "));
  Serial.println(ssid); delay(2000);

  //update status button ke server
  Serial.println (F("update status relay ke server..."));
  writeEEPROMapp ();
  Serial.println (F("update berhasil\n"));
  
  timer.setInterval(5000L, sendSensor);
  
}

void sendSensor(){
  int h = dht.getHumidity();
  int t = dht.getTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println(F("Failed to read from DHT sensor!"));
    return;
  }
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
  
  //menampilkan data pada terminal monitor
  Serial.print(F("update suhu: ")); 
  Serial.print(t);
  Serial.println(F("C"));
  
  Serial.print(F("update humidity: ")); 
  Serial.print(h);
  Serial.println(F("%\n"));
}

BLYNK_WRITE(V1){
  if(param.asInt()==0){
     digitalWrite(relay1,LOW); Serial.println(F("Relay 1 ON"));
     EEPROM.update(1, 0);}
  else{
     digitalWrite(relay1,HIGH); Serial.println(F("Relay 1 OFF"));
     EEPROM.update(1, 1);}  
}

BLYNK_WRITE(V2){
  if(param.asInt()==0){
     digitalWrite(relay2,LOW); Serial.println(F("Relay 2 ON"));
     EEPROM.update(2, 0);}
  else{
     digitalWrite(relay2,HIGH); Serial.println(F("Relay 2 OFF"));
     EEPROM.update(2, 1);}  
}

BLYNK_WRITE(V3){
  if(param.asInt()==0){
     digitalWrite(relay3,LOW); Serial.println(F("Relay 3 ON"));
     EEPROM.update(3, 0);}
  else{
     digitalWrite(relay3,HIGH); Serial.println(F("Relay 3 OFF"));
     EEPROM.update(3, 1);}  
}

BLYNK_WRITE(V4){
  if(param.asInt()==0){
     digitalWrite(relay4,LOW); Serial.println(F("Relay 4 ON"));
     EEPROM.update(4, 0);}
  else{
     digitalWrite(relay4,HIGH); Serial.println(F("Relay 4 OFF"));
     EEPROM.update(4, 1);}  
}

BLYNK_WRITE(V9) {
  switch (param.asInt()) {
    case 1: Relay = 1; break;
    case 2: Relay = 2; break;
    case 3: Relay = 3; break;
    case 4: Relay = 4; break;
    case 5: Relay = 5; break;
    case 6: Relay = 6; break;
  }
}

BLYNK_WRITE(V10) {
  TimeInputParam t(param);
  jamStart = t.getStartHour(); menitStart = t.getStartMinute();
  jamStop = t.getStopHour();   menitStop = t.getStopMinute();
}

BLYNK_WRITE(V11) {
  
  if (Relay == 1) {
    if (param.asInt() && statusT==0){
      statusT = (1);
      EEPROM_writeAnything(7, cfg);
      led1.on();
      Serial.println(String(" Timer Relay 1 AKTIF!! \nStart: ")+ jamStart + ":" + menitStart 
      + "\nStop: " + jamStart + ":" + menitStart);  
    }
    else {
      resetTime(); 
      EEPROM_writeAnything(7, cfg);
      led1.off();
      Serial.println(F(" Timer Relay 1 MATI!! "));   
    }
  }

  if (Relay == 2) {
    if (param.asInt() && statusT==0){
      statusT = (1);
      EEPROM_writeAnything(8, cfg);
      led2.on();
      Serial.println(String(" Timer Relay 2 AKTIF!! \nStart: ")+ jamStart + ":" + menitStart 
      + "\nStop: " + jamStart + ":" + menitStart);  
    }
    else {
      resetTime(); 
      EEPROM_writeAnything(8, cfg);
      led2.off();
      Serial.println(F(" Timer Relay 2 MATI!! "));   
    }
  }

  if (Relay == 3) {
    if (param.asInt() && statusT==0){
      statusT = (1);
      EEPROM_writeAnything(9, cfg);
      led3.on();
      Serial.println(String(" Timer Relay 3 AKTIF!! \nStart: ")+ jamStart + ":" + menitStart 
      + "\nStop: " + jamStart + ":" + menitStart);         
    }
    else {
      resetTime(); 
      EEPROM_writeAnything(9, cfg);
      led3.off();
      Serial.println(F(" Timer Relay 3 MATI!! "));   
    }
  }

  if (Relay == 4) {
    if (param.asInt() && statusT==0){
      statusT = (1);
      EEPROM_writeAnything(10, cfg);
      led4.on();
      Serial.println(String(" Timer Relay 4 AKTIF!! \nStart: ")+ jamStart + ":" + menitStart 
      + "\nStop: " + jamStart + ":" + menitStart);    
    }
    else {
      resetTime(); 
      EEPROM_writeAnything(10, cfg);
      led4.off();
      Serial.println(F(" Timer Relay 4 MATI!! "));   
    }
  }

  if (Relay == 5) {
    if (param.asInt() && statusT==0){
      statusT = (1);
      EEPROM_writeAnything(11, cfg);
      led5.on();
      Serial.println(String(" Timer Relay 5 AKTIF!! \nStart: ")+ jamStart + ":" + menitStart 
      + "\nStop: " + jamStart + ":" + menitStart);       
    }
    else {
      resetTime(); 
      EEPROM_writeAnything(11, cfg);
      led5.off();
      Serial.println(F(" Timer Relay 5 MATI!! "));   
    }
  }

  if (Relay == 6) {
    if (param.asInt() && statusT==0){
      statusT = (1);
      EEPROM_writeAnything(12, cfg);
      led6.on();
      Serial.println(String(" Timer Relay 6 AKTIF!! \nStart: ")+ jamStart + ":" + menitStart 
      + "\nStop: " + jamStart + ":" + menitStart);  
    }
    else {
      resetTime(); 
      EEPROM_writeAnything(12, cfg);
      led6.off();
      Serial.println(F(" Timer Relay 6 MATI!! "));   
    }
  }
}

void resetTime(){
  jamStart = (00); menitStart = (00);
  jamStop = (00);  menitStop = (00);
  statusT =(00);  
}

void timerRelay() {
  if (timerRelay1) {
    if(statusT==1 && rtcNow == startTimer) {
      digitalWrite(relay1,LOW); Serial.println(F("Relay 1 ON with Timer"));
      EEPROM.update(1, 0);}
    else if (statusT==1 && rtcNow == stopTimer) {
      digitalWrite(relay1,HIGH); Serial.println(F("Relay 1 OFF  with Timer"));
      EEPROM.update(1, 1);}
  }

  if (timerRelay2) { 
    if(statusT==1 && rtcNow == startTimer) {
      digitalWrite(relay2,LOW); Serial.println(F("Relay 2 ON with Timer"));
      EEPROM.update(2, 0);}
    else if (statusT==1 && rtcNow == stopTimer) {
      digitalWrite(relay2,HIGH); Serial.println(F("Relay 2 OFF  with Timer"));
      EEPROM.update(2, 1);}
  }

  if (timerRelay3) { 
    if(statusT==1 && rtcNow == startTimer) {
      digitalWrite(relay3,LOW); Serial.println(F("Relay 3 ON with Timer"));
      EEPROM.update(3, 0);}
    else if (statusT==1 && rtcNow == stopTimer) {
      digitalWrite(relay3,HIGH); Serial.println(F("Relay 3 OFF"));
      EEPROM.update(3, 1);}
  }
  
  if (timerRelay4) { 
    if(statusT==1 && rtcNow == startTimer) {
      digitalWrite(relay4,LOW); Serial.println(F("Relay 4 ON with Timer"));
      EEPROM.update(4, 0);}
    else if (statusT==1 && rtcNow == stopTimer) {
      digitalWrite(relay4,HIGH); Serial.println(F("Relay 4 OFF"));
      EEPROM.update(4, 1);}
  }
}

void ReadEEPROM (){

  Serial.print(F("Posisi Terakhir relay1 = "));
  if(State1==0){digitalWrite(relay1,LOW); Serial.println(F("ON"));} 
  else {digitalWrite(relay1,HIGH); Serial.println(F("OFF"));}

  Serial.print(F("Posisi Terakhir relay2 = "));
  if(State2==0){digitalWrite(relay2,LOW); Serial.println(F("ON"));} 
  else {digitalWrite(relay2,HIGH); Serial.println(F("OFF"));}

  Serial.print(F("Posisi Terakhir relay3 = "));
  if(State3==0){digitalWrite(relay3,LOW); Serial.println(F("ON"));} 
  else {digitalWrite(relay3,HIGH); Serial.println(F("OFF"));}
 
  Serial.print(F("Posisi Terakhir relay4 = "));
  if(State4==0){digitalWrite(relay4,LOW); Serial.println(F("ON"));} 
  else {digitalWrite(relay4,HIGH); Serial.println(F("OFF\n"));}

  //digitalWrite(relay5,State5);
  //Serial.print(F("Posisi Terakhir relay5 = "));
  //if(State5==0){Serial.println("ON");} else {Serial.println("OFF");}
  
  //digitalWrite(relay6,State6);
  //Serial.print(F("Posisi Terakhir relay6 = "));
  //if(State6==0){Serial.println("ON");} else {Serial.println("OFF");}

}

void writeEEPROMapp (){

  if(State1==0){Blynk.virtualWrite(V1,0);} 
  else {Blynk.virtualWrite(V1,1);}

  if(State2==0){Blynk.virtualWrite(V2,0);} 
  else {Blynk.virtualWrite(V2,1);}

  if(State3==0){Blynk.virtualWrite(V3,0);} 
  else {Blynk.virtualWrite(V3,1);}

  if(State4==0){Blynk.virtualWrite(V4,0);} 
  else {Blynk.virtualWrite(V4,1);}

  //digitalWrite(relay5,State5);
  //Serial.print(F("Posisi Terakhir relay5 = "));
  //if(State5==0){Serial.println("ON");} else {Serial.println("OFF");}
  
  //digitalWrite(relay6,State6);
  //Serial.print(F("Posisi Terakhir relay6 = "));
  //if(State6==0){Serial.println("ON");} else {Serial.println("OFF");}
}

void loop()
{
  Blynk.run();
  timer.run(); // Initiates SimpleTimer
  timerRelay();
}
2 Likes

Hi guys I have a project to create using below hardware.

ESP8266 module
MAX6675 K type thermocouple
Blynk platform
SG90 servo motors - 3
4 channel relay module

Below shows simply what I want to do with project and I don’t have much knowledge in coding.

the whole system should start by using single virtual pin in Blynk.

  1. Once turn on the switch of the blynk platform 1st relay and 1st servo motor should turn on at the same time. Servo motor should rotate 45 degrees.
  2. Then both 1st relay and servo motor should keep on for 3 minutes
  3. 2nd relay should automatically turn on after 1 minute from the system start and the 2nd servo motor should turn 45 degrees as well.
  4. After 3 minutes from the system start 1st relay and 1st servo motor should turn off automatically. But 2nd relay and 2nd servo are still on.
  5. After another 2 minutes 3rd relay should turn on and at the same time 2nd servo motor should turn off and should turn to 0 degrees(start point)
  6. Once temperature level become equal or less than 30 Celsius 2nd and 3rd both relays should turn off.
  7. This procedure should only run once after on the switch of blynk.
  8. But always temperature sensor should show the current temperature value on the platform.
  9. If turn on the blynk switch again same procedure should run once and stop

Kindly provide me a code to create this project. It will be very helpful to work on my project. Thank you!

@Raveen why have you hijacked this unrelated topic to ask this question?
You need to create a new “need help with my project” topic and ask your questions there. But before you do that’ I’d suggest that you read this link…

Also, the forum isn’t a code factory, so you’ll need to develop some C++ coding skills of your own.

Pete.