Page 1 of 1

RF wall switch to esp32 devkit v1

Posted: Sat Mar 13, 2021 8:11 pm
by JokoNako
Hello,
A few days banging my head against the wall, can't get any response in my serial print using RCSwitch library.
Receiver (https://www.aliexpress.com/item/3296986 ... 4c4dk64hNl) and transmitter are paired just fine.
Have tried varies codes along Internet, but none works for me.
Great thanks in advance to anyone who may help here!



Code: Select all



#include "RCSwitch.h"

const int D27 = 27;
int val = 0; 
RCSwitch mySwitch = RCSwitch();

void setup() {
  Serial.begin(115200);
  pinMode(D27, INPUT);
mySwitch.enableReceive(digitalPinToInterrupt(D27));
  mySwitch.enableReceive(D27);  
  Serial.println("ESP8266 RF receiver scanning now...");
  
}

void loop() {
  if (mySwitch.available()) {
    
    int value = mySwitch.getReceivedValue();
    
    if (value == 0) {
      Serial.print("Unknown encoding");
    } else {
      Serial.print("Received ");
      Serial.print( mySwitch.getReceivedValue() );
      Serial.print(" / ");
      Serial.print( mySwitch.getReceivedBitlength() );
      Serial.print("bit ");
      Serial.print("Protocol: ");
      Serial.println( mySwitch.getReceivedProtocol() );
    }

    mySwitch.resetAvailable();
  }
 val = digitalRead(D27);
  Serial.println(val);
}