I'm trying to control a 315MHz RF socket using the RCSwitch library. I tested with an Arduino and it worked 100% of the time but when porting over to a pi zero I can only get it to correctly turn on / off about 1 in every 10-15 tries.
I'm not sure if there is a problem with my code, the library or just the pi not being fast enough to handle sending the data properly.
Here's my current code:
#include <wiringPi.h>
#include "RCSwitch.h>
int main(int argc, char** argv)
{
wiringPiSetup();
RCSwitch sw;
sw.enableTransmit(0);
sw.setProtocol(6);
sw.send(16777173, 24);
}
edit: It definitely appears to be at least partly a performance problem, compiling with -O2 ups the success rate to around 1/3.