Scyl
June 1, 2015, 3:30pm
1
I can’t see to get Blynk to work with the RCSwitch library from https://github.com/sui77/rc-switch
I am using Arduino over USB, and the arduino see the disconnect itself after I try to call the send function from RCSwitch.
Here is my code
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
#include <SoftwareSerial.h>
SoftwareSerial SwSerial(10, 11);
#define BLYNK_PRINT SwSerial
#include <BlynkSimpleSerial.h>
char auth[] = "SOME CHARACTERS HERE";
void setup() {
mySwitch.enableTransmit(10);
SwSerial.begin(9600);
Blynk.begin(auth);
}
void loop() {
Blynk.run();
}
BLYNK_WRITE(0) {
mySwitch.send(3852814, 24);
}
BLYNK_WRITE(1) {
mySwitch.send(3852806, 24);
}
I know my switch work and the code is correct.
I am not sure if this is how virtual pins are suppose to be used by the way.
Hey, you must realize that BLYNK_WRITE can be called twice if you push the button (once for button down and once for up). You can distinguish those by checking param.asInt().
Besides that I can’t see any problems. Actually I didn’t have a chance to use this module, maybe other guys?
Also, I don’t know haw much RAM can mySwitch.send use…
Scyl
June 11, 2015, 5:29am
3
I tried it with a Mega as well, same result, so i don’t think it’s a lack of RAM issue.
twobe
June 11, 2015, 9:28am
4
You are using your digital pin 10 twice. In your SoftwareSerial and the RCSwitch. Change one of them to an other pin and it should work.
1 Like
Scyl
June 11, 2015, 9:43am
5
I have no idea what
SoftwareSerial SwSerial(10, 11);
does actually, so 10 and 11 are actually pins? they can be anything? What are you suppose to connect to it?
twobe
June 11, 2015, 10:58am
6
These are the in- and output pins for the sowtware serial. ( http://www.arduino.cc/en/Reference/SoftwareSerialConstructor )
You can change them to other pins that you don’t need. (with some limitations: http://www.arduino.cc/en/pmwiki.php?n=Reference/SoftwareSerial )
The SoftwareSerial is used for the serial output that blynk creates.
If you don’t need that output you can disable it by deleting these lines:
#include <SoftwareSerial.h>
SoftwareSerial SWSerial(10,11);
#define BLYNK_PRINT SwSerial
and
SwSerial.begin(9600);
@Scyl , @twobe seems to be right.
Please update us if it helped.
Thanks.
Scyl
June 11, 2015, 11:52am
8
Yes! that worked, thanks everyone!!