I would like to use my Attiny85 as an remote controlled relay switch. I have already tested the sketch on my Atmega328 and it worked. Now I wanted to burn the sketch on my Attiny85 using ArduinoISP but I get the following error in the ArduinoIDE:

sketch_dec25a.ino: In function ‘void setup()’:
sketch_dec25a:13: error: ‘class RCSwitch’ has no member named ‘enableReceive’
sketch_dec25a.ino: In function ‘void loop()’:
sketch_dec25a:20: error: ‘class RCSwitch’ has no member named ‘available’
sketch_dec25a:21: error: ‘class RCSwitch’ has no member named ‘getReceivedValue’
sketch_dec25a:22: error: ‘class RCSwitch’ has no member named ‘getReceivedValue’
sketch_dec25a:25: error: ‘class RCSwitch’ has no member named ‘resetAvailable’

That's my code:

#include <SoftwareSerial.h>
#include <RCSwitch.h>

int RELAY_PIN = 2;

RCSwitch mySwitch = RCSwitch();
SoftwareSerial mySerial(1, 3); // RX, TX

void setup()  
  mySwitch.enableReceive(0);  // Receiver on inerrupt 0 => that is pin #2
  mySerial.println("Hello, world?");

void loop() // run over and over
  if (mySwitch.available()) {
    if(mySwitch.getReceivedValue() == 1234567){
      digitalWrite(RELAY_PIN, HIGH);

I am using these cores: https://code.google.com/p/arduino-tiny/

I am using the SoftwareSerial just for debugging. Sorry for my bad english and thanks for your help!


The issue you face is that RCSwitch does not seem to support receive mode for ATtiny.

This is what you can find in RCSwitch.h:

// At least for the ATTiny X4/X5, receiving has to be disabled due to
// missing libm depencies (udivmodhi4)
#if defined( __AVR_ATtinyX5__ ) or defined ( __AVR_ATtinyX4__ )
#define RCSwitchDisableReceiving

Then all methods related to receptions are not defined in RCSwitch class for ATtiny MCUs:

#if not defined( RCSwitchDisableReceiving )
void enableReceive(int interrupt);
void enableReceive();
void disableReceive();
bool available();
void resetAvailable();

unsigned long getReceivedValue();
unsigned int getReceivedBitlength();
unsigned int getReceivedDelay();
unsigned int getReceivedProtocol();
unsigned int* getReceivedRawdata();

I am really not sure if there is a way to work around it, I have not looked at the code in RCSwitch.cpp.

Maybe you best option would be to find another RC library.

For instance, if you can use Infra-Red RC, then there are libraries out there that could work for ATtiny:



I have tested with Digispark ATtiny85 and https://github.com/sui77/rc-switch work perfect

just comment #define RCSwitchDisableReceiving than use in setup code enableReceive(0); and external pin 7 PB2(int0) as RF source

Or you can use other software pin interrupt

in setup: PCMSK |= (1<<PCINT0);//here pin number GIMSK |= (1<<PCIE);

interrupt function ISR(PCINT0_vect) { rd.handleInterrupt(); // you need also put handleInterrupt() in public section in RCSwitch.h }

  • Yes, as akaJes addition working great! I move handleInterrupt() do public in RCSwitch.h, comment #define RCSwitchDisableReceiving and adding interrupt function like akaJes. Thanks! :-) – user3680370 May 13 '17 at 7:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.