sui77 / rc-switch

Arduino lib to operate 433/315Mhz devices like power outlet sockets.
1.89k stars 651 forks source link

Not receiving (fix offered included here) #466

Open ThreepE0 opened 2 years ago

ThreepE0 commented 2 years ago

Noticed that in RCSwitch.cpp the pin mode is set when enableTransmit is called. Pin mode is not set on receive. I set the pin mode manually in my sketch uploaded to a Uno Wifi Rev 2 (using pin 3) and it started working great.

Noticed exists: void RCSwitch::enableTransmit(int nTransmitterPin) { this->nTransmitterPin = nTransmitterPin; pinMode(this->nTransmitterPin, OUTPUT); }

Suggested addition in the enableReceive function: `void RCSwitch::enableReceive() { if (this->nReceiverInterrupt != -1) { RCSwitch::nReceivedValue = 0; RCSwitch::nReceivedBitlength = 0;

if defined(RaspberryPi) // Raspberry Pi

wiringPiISR(this->nReceiverInterrupt, INT_EDGE_BOTH, &handleInterrupt);

else // Arduino

attachInterrupt(digitalPinToInterrupt(this->nReceiverInterrupt), handleInterrupt, CHANGE);
pinMode(this->nTransmitterPin, INPUT);

endif

}`

Sorry I do not know how to perform a pull request

ronrem commented 2 years ago

Hi, I probably experiencing the same issue, can you please share you RCSwitch.cpp code via https://gist.github.com ?