BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

New blynk Codes related Error

i am trying to control 4 channel module in the new blynk platform:

Hardware Part:

  • ESP-32
  • 4 Channel Relay Module
  • IR Sensor

so here is my coding part

        void ir_remote(){
      if (irrecv.decode(&results)) {
          switch(results.value){
              case 0xFFB04F:  
                digitalWrite(RelayPin1, toggleState_1);
                toggleState_1 = !toggleState_1;
                Blynk.virtualWrite(VPIN_BUTTON_1, toggleState_1);
                delay(100);            
                break;
              case 0xFF9867:  
                digitalWrite(RelayPin2, toggleState_2);
                toggleState_2 = !toggleState_2;
                Blynk.virtualWrite(VPIN_BUTTON_2, toggleState_2);
                delay(100);            
                break;
              case 0xFFD827:  
                digitalWrite(RelayPin3, toggleState_3);
                toggleState_3 = !toggleState_3;
                Blynk.virtualWrite(VPIN_BUTTON_3, toggleState_3);
                delay(100);            
                break;
              case 0xFF807F:  
                digitalWrite(RelayPin4, toggleState_4);
                toggleState_4 = !toggleState_4;
                Blynk.virtualWrite(VPIN_BUTTON_4, toggleState_4);
                delay(100);            
                break;
                case 0xFF906F:  all_SwitchOff(); Blynk.virtualWrite(VPIN_BUTTON_9, toggleState_5); break;
                case 0xFFC03F:  all_SwitchOn();  Blynk.virtualWrite(VPIN_BUTTON_10, toggleState_5); break;
    default : break;  
       }     
            }   
            //Serial.println(results.value, HEX);    
            irrecv.resume();   
      } 
}

but this part is in blynk edgent header file

and i am getting a error

Arduino: 1.8.12 (Windows 10), Board: “ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None”

In file included from C:\Users\jamsa\OneDrive\Desktop\updated version\tech study cell\Code_ESP32_Blynk2_IR_DHT11_LDR_8Relays_Switch\Code_ESP32_Blynk2_IR_DHT11_LDR_8Relays_Switch\Code_ESP32_Blynk2_IR_DHT11_LDR_8Relays_Switch.ino:85:0:

sketch\BlynkEdgent.h: In function ‘void ir_remote()’:

BlynkEdgent.h:215:43: error: ‘all_SwitchOff’ was not declared in this scope

         case 0xFF906F:  all_SwitchOff(); Blynk.virtualWrite(VPIN_BUTTON_9, toggleState_5); dimmer.setState(OFF); break;

                                       ^

BlynkEdgent.h:216:42: error: ‘all_SwitchOn’ was not declared in this scope

         case 0xFFC03F:  all_SwitchOn();  Blynk.virtualWrite(VPIN_BUTTON_10, toggleState_5); dimmer.setState(ON); break;

                                      ^

Multiple libraries were found for “IRremote.h”
Used: C:\Users\jamsa\OneDrive\Documents\Arduino\libraries\IRremote
Not used: C:\Users\jamsa\OneDrive\Documents\Arduino\libraries\Arduino-IRremote-master
Multiple libraries were found for “BlynkSimpleEsp32_SSL.h”
Used: C:\Users\jamsa\OneDrive\Documents\Arduino\libraries\Blynk
Not used: C:\Program Files (x86)\Arduino\libraries\Blynk
Multiple libraries were found for “WiFi.h”
Used: C:\Users\jamsa\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi
Not used: C:\Program Files (x86)\Arduino\libraries\WiFi
Not used: C:\Users\jamsa\OneDrive\Documents\Arduino\libraries\WiFiNINA
exit status 1
‘all_SwitchOff’ was not declared in this scope

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

I already did it in edgent file

void all_SwitchOff(){
  toggleState_1 = 0; digitalWrite(RelayPin1, HIGH); Blynk.virtualWrite(VPIN_BUTTON_1, toggleState_1); delay(100);
  toggleState_2 = 0; digitalWrite(RelayPin2, HIGH); Blynk.virtualWrite(VPIN_BUTTON_2, toggleState_2); delay(100);
  toggleState_3 = 0; digitalWrite(RelayPin3, HIGH); Blynk.virtualWrite(VPIN_BUTTON_3, toggleState_3); delay(100);
  toggleState_4 = 0; digitalWrite(RelayPin4, HIGH); Blynk.virtualWrite(VPIN_BUTTON_4, toggleState_4); delay(100);
}

void all_SwitchOn(){
  toggleState_1 = 0; digitalWrite(RelayPin1, toggleState_1); Blynk.virtualWrite(VPIN_BUTTON_1, toggleState_1); delay(100);
  toggleState_2 = 0; digitalWrite(RelayPin2, toggleState_2); Blynk.virtualWrite(VPIN_BUTTON_2, toggleState_2); delay(100);
  toggleState_3 = 0; digitalWrite(RelayPin3, toggleState_3); Blynk.virtualWrite(VPIN_BUTTON_3, toggleState_3); delay(100);
  toggleState_4 = 0; digitalWrite(RelayPin4, toggleState_4); Blynk.virtualWrite(VPIN_BUTTON_4, toggleState_4); delay(100);
 
}

You need to clarify exactly what these two statements mean.

Pete.

It means when I press on button (ir) my all relay will goes off and when I press off button (ir) my all relay goes off

Hey there. Check this out :

1 Like

Same problem in this project not control all relays with ir remote buttons

So you want to control all relays simultaneously using one remote button right ?

Yahhh you are right

Any idea

Okay buddy.

Download the code, Go to the blynkedgent.h, you will find void ir_remote() like this :


Add another case then add all buttons without break, something like this :

case 0x00000000 :  
            digitalWrite(RelayPin1, toggleState_1);
            toggleState_1 = !toggleState_1;
            Blynk.virtualWrite(VPIN_BUTTON_1, toggleState_1);
            delay(100);            
           
            digitalWrite(RelayPin2, toggleState_2);
            toggleState_2 = !toggleState_2;
            Blynk.virtualWrite(VPIN_BUTTON_2, toggleState_2);
            delay(100);            
            
            digitalWrite(RelayPin3, toggleState_3);
            toggleState_3 = !toggleState_3;
            Blynk.virtualWrite(VPIN_BUTTON_3, toggleState_3);
            delay(100);            

etc…
You got the idea.
Try and let me know if it works.

This statement makes no sense in the context of your original post in this topic.
Your compiler error is because one part of the sketch can’t see the other part, which is why I said…

How to solve that compiler error depends on exactly where you’ve put the two snippets of code that you posted. Without that information I can’t really help.

Pete.

I am trying this but in my case I want to control all relays with one single remote button