0

Trouble talking to my RF receiver
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Trouble talking to my RF receiver

by SkyLeopardMan on Fri Sep 13, 2019 3:03 pm

Hi Im putting together a project where I control a stepper motor with a push of an RF button.

I am running into trouble right away just trying to verify my RF receiver works.


Control Im using: https://www.adafruit.com/product/1095
Reciever Im using: https://www.adafruit.com/product/1096
I have an Arduino UNO R3 and a adafruit motorshield v2.3 attached on top of it. The motorshield is powered with a 12v wall charger and the arduino is through my computer.

I have the receiver +5V wired to 5v on the motor shield and ground wired to ground on the motorshield.

I then have D0 and D2 on receiver wired to digial pins 2 and 4 on motorshield respectively.

I was following this video tutorial:

https://www.youtube.com/watch?v=jUieRwJKMMA

I got the code from it as well, listed below. Im entirely new and just trying to figure things out. But my expected result is when I press crt-shift-m a screen appears and with the code running I should see the put from pushing the button. I see nothing. Im a bit lost and unsure where to look next. If there is a better way to do this please let me know! In theroy my plan is have code that says. When RF button is pushed turn stepper motor X turns in Y direction. But before I get there I have to understand how to use the RF which I am having trouble with

EDIT: I followed another video tutorial to try something else. this time i wiried D0 to digital pin 11. I will include my code at the bottom after the other code. I once again got nothing

/*
Simple example for receiving

https://github.com/sui77/rc-switch/
*/

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {
Serial.begin(9600);
mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2
}

void loop() {
if (mySwitch.available()) {

int value = mySwitch.getReceivedValue();

if (value == 0) {
Serial.print("Unknown encoding");
} else {
Serial.print("Received ");
Serial.print( mySwitch.getReceivedValue() );
Serial.print(" / ");
Serial.print( mySwitch.getReceivedBitlength() );
Serial.print("bit ");
Serial.print("Protocol: ");
Serial.println( mySwitch.getReceivedProtocol() );
}

mySwitch.resetAvailable();
}
}




other code

#include <RH_ASK.h>

#include <SPI.h>

RH_ASK rf_driver;

void setup()
{
//Init ASK object
rf_driver.init();
//Setup Serial Monitor
Serial.begin(9600);
}

void loop()
{
//Set buffer to size of expected message
uint8_t buf[24];
uint8_t buflen = sizeof(buf);
//Check if received packet is correct size
if (rf_driver.recv(buf, &buflen))
{

//Message received with valid checksum
Serial.print("Message Received: ");
Serial.println((char*)buf);
}

}

SkyLeopardMan
 
Posts: 1
Joined: Thu Sep 12, 2019 12:41 pm

Please be positive and constructive with your questions and comments.