RF wall switch to esp32 devkit v1

JokoNako
Posts: 1
Joined: Sat Mar 13, 2021 5:09 pm

RF wall switch to esp32 devkit v1

Postby JokoNako » Sat Mar 13, 2021 8:11 pm

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);
}

Who is online

Users browsing this forum: No registered users and 78 guests