sui77 / rc-switch

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

Compatibility with M0? #327

Open sirtet opened 4 years ago

sirtet commented 4 years ago

I tried to use rc-switch on an M0 board (Trinket M0), but could not get the ReceiveDemo_Simple to run. The compiler gave a warning WARNING: library rc-switch claims to run on avr, esp8266, esp32 architecture(s) and may be incompatible with your current board which runs on samd architecture(s). but no errors. Still, the sketch just seemed to do nothing.

Issue #34 reads like it should run on M0, assuming the bug mentioned there is fixed by now. I have not tried it yet, but maybe someone else has? I fiddled around some more, tried to implement the solution from #34 (without really knowing what i was doing, i substituted the calls to the mentioned function in RCswitch.cpp) and... it worked. So i reverted the change from #34 just to verify, but my code still worked. Aparently the bug is fixed now, or does not affect my use case. So, my initial problems were somewhere else. I am not surprised, as i had tried quite a few things, also switching from win to linux, and had at some point also problems to just upload a blink. Upload only works for me after i double-press reset so the red LED pulses. Else bossac finds no device on ttyACM0.

As reference: The sketch that works for me is on a 3.3V TrinketM0 with a FS1000A transmitter:

#include <RCSwitch.h>
RCSwitch sender = RCSwitch();

  // "button" pins to be pulled LOW to activate
  const int Bup = 0; 

void setup() {

  sender.enableTransmit(3);  // FS1000A Module at Pin 3
  sender.setProtocol(1);
  sender.setPulseLength(309);

  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(Bup, INPUT_PULLUP);
}

void loop() {

  if (digitalRead(Bup)== LOW)
    {
      digitalWrite(LED_BUILTIN, HIGH);
      sender.send("101011100101111011110010"); // up
      delay(1000);
      digitalWrite(LED_BUILTIN, LOW);
    }

}

As the library works at least partially on M0, couldn't it include M0 in it's claims? I tried to find out how/where these claims are made, but did not find anything when searching the code for 8266... How is that done?