is not yet ported but by using the example-code provided by the author of rc-switch I managed to talk to a “dip switch” model:
/*
This is a minimal sketch without using the library at all but only works for
the 10 pole dip switch sockets. It saves a lot of memory and thus might be
very useful to use with ATTinys :)
http://code.google.com/p/rc-switch/
*/
int RCLpin = D7; // modified run with a Spark Core
void setup() {
pinMode(RCLpin, OUTPUT);
}
void loop() {
RCLswitch(0b010001000001); // DIPs at rc power outlet: 0100010000 ON:01
delay(2000);
RCLswitch(0b010001000010); // DIPs at rc power outlet: 0100010000 OFF:10
delay(2000);
}
void RCLswitch(uint16_t code) {
for (int nRepeat=0; nRepeat<6; nRepeat++) {
for (int i=4; i<16; i++) {
RCLtransmit(1,3);
if (((code << (i-4)) & 2048) > 0) {
RCLtransmit(1,3);
} else {
RCLtransmit(3,1);
}
}
RCLtransmit(1,31);
}
}
void RCLtransmit(int nHighPulses, int nLowPulses) {
digitalWrite(RCLpin, HIGH);
delayMicroseconds( 350 * nHighPulses);
digitalWrite(RCLpin, LOW);
delayMicroseconds( 350 * nLowPulses);
}
Worked fine with one of those cheap 433Mhz modules from china!
Hi,
I tried Frido version, with the example in attached at the end of pastebin site.
unfortunately it is not working for me I get a bunch of errors.
In file included from ../inc/spark_wiring.h:30:0,
from ../inc/application.h:31,
from /433test.cpp:2:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
/RCSwitch.cpp:33:15: error: 'RCSwitch' has not been declared
[...]
Is there anyone being able to import this as libery successfully please?
I just took my (raw!) paste bin source code, pasted in a new project on sparculator (aka “WEB-IDE”) and it compiled without any error!
BTW: Anybody may feel free to create a sparculator-library!!!
Output of arm-none-eabi-size:
text data bss dec hex
70832 3104 12548 86484 151
In a nutshell:
Flash used 73936 / 110592 66.9 %
RAM used 15652 / 20480 76.4 %
Thank you for your reply.
I just tried to copy paste all the raw in one single file and i can compile it.
I guess it was just the fact that I was splitting it to .h .cpp and ino… that is why!
anyway if someone understood how to port it to the library system… I’ll be more than happy to test it!!!
I’ve a working RCSwitch port for Spark here: https://github.com/suda/RCSwitch Tested both sending (using D0) and receiving (D3). ReceiveDemo_Advanced and SparkFunction examples contain some integration with Spark Cloud.
It’s also added to Community Libraries in web IDE.
Thanks to @wgbartley and @Frido for initial version of this port
Hi @suda so I’ve completed a project using the RC-Switch library for original arduino, and I’m trying to use your library to get my photon working with my switches. The receive demo works fine but I can’t seem to use the send demo to transmit the codes. I’ve tried two brands of switches i have no problem contorlling from my arduino. Any photon specific issues?
Hmmm I must admit I haven’t tested it w/ Photon. Do you have two Particle devices or Particle+Arduino so you could try sending data from one to another?
Anyone who cares, my issue is resolved. Thanks to @suda’s help I found that for the Photon the pulse length option needs to be enabled and set to 180 (ms). Although it doesn’t seem to work with my other switches. I wonder if I have to change the pulse length for different types of switches.