Newbie here. I am trying to create a project that involves sending and receiving wireless data. I went with a 434Mhz receiver and transmitter. Using a software defined radio I can see that something is being sent on 434Mhz, but I don’t see anything being received via the serial println in my script.
I’ve double checked my wiring against the datasheets to see if I was missing something, but I am at a loss. What should I try now or does something plainly standout?
- [https://www.sparkfun.com/products/10534](https://www.sparkfun.com/products/10534)
- [https://www.sparkfun.com/products/10532](https://www.sparkfun.com/products/10532)
- [https://imgur.com/a/f3s2o6c](https://imgur.com/a/f3s2o6c) 1 - Album containing pictures of the breadboard as well as a video of me seeing something being sent on 434Mhz via radio when I upload the scratch to the arduino.
The following scratch is based off the one at https://github.com/sparkfun/RF_Links/tr … -RFLink_Tx . It is the one I use in the video linked above.
// RF LINK RECEIVER LIBRARY
#include <RH_ASK.h>
#ifdef RH_HAVE_HARDWARE_SPI#include <SPI.h> // Not actually used but needed to compile
#endif
const char * msg = "1";
const int rxPin = 11;
const int txPin = 10;
const int msgReceivedPin = 4;
const int characterMatchespin = 3;
RH_ASK driver(4800, rxPin, txPin, 0);
void setup() {
#ifdef RH_HAVE_SERIAL
Serial.begin(9600); // Debugging only
Serial.println("Initialize RF Link Rx Code");
#endif
if (!driver.init())
#ifdef RH_HAVE_SERIAL
Serial.println("init failed");
#else
;
#endif
pinMode(characterMatchespin, OUTPUT);
pinMode(msgReceivedPin, OUTPUT);
// test to make sure the LEDs will turn on before using them as a status indicator
digitalWrite(msgReceivedPin, HIGH);
digitalWrite(characterMatchespin, HIGH);
delay(5000);
digitalWrite(msgReceivedPin, LOW);
digitalWrite(characterMatchespin, LOW);
delay(1000);
}
void loop() {
//Initialize/reinitialize LEDs
digitalWrite(characterMatchespin, LOW);
//Set buffer array based on max message length
uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
//Set variable to indicate buffer length
uint8_t buflen = sizeof(buf);
if (driver.recv(buf, & buflen)) // Non-blocking
{
// Flash status LED to show received data
digitalWrite(msgReceivedPin, true);
//Note: This line of code just prints the buffer with space
// you will see the ASCII value instead of the character
// Message with a good checksum received, dump it.
//driver.printBuffer("Got:", buf, buflen);
// Message with a good checksum received, dump it.
Serial.print("Received message: ");
//print each character individually, this is useful if you are just checking for certain characters and printing it as character
//Note: The original code for the ask_receiver.pde used `int i` but it
//doesn't appear to be used. Just in case, we'll create another variable `j`
for (int j = 0; j < buflen; j++) {
// Print message received in buffer through this loop as a character by typcasting it as a char
Serial.print((char) buf[j]);
//add space to distinguish characters from each other if showing ASCII decimal #
//Serial.print(" ");
//if character received matches, turn on associated LED
if (buf[j] == '1') {
digitalWrite(characterMatchespin, HIGH);
}
}
//Print next character on new line
Serial.println("");
delay(200);
//Turn off status LED
digitalWrite(msgReceivedPin, LOW);
}
delay(1000);
driver.send((uint8_t * ) msg, strlen(msg));
driver.waitPacketSent();
}
Someone on Reddit recommended using a second arduino: One for the rx and one for tx. I set that up and am still not receiving anything. I’m attaching both the scratches I used and a video of them running.
Video: https://imgur.com/a/AKTPk1w
rx code:
/*RF ASK Tx and Rx Example Code
Created in 2011 by NPoole @ SparkFun Electronics
q
modified 13 Oct 2022
by Bobby Chan @ SparkFun Electronics
Description:
This code depends on the RadioHead Library for Arduino and is
based on the example code provided by Mike McCauley.
It is based on the ask_receivier.pde example.
To download the most recent RadioHead Library =>
http://www.airspayce.com/mikem/arduino/RadioHead/index.html
See RH_ASK.h for detailed API docs. You will need to use this code
with the 01-RadioHead-Simple_RFLink_Tx.ino.
This example shows how to use the RadioHead Library to send and receive
simple messages and use them to control digital I/O pins with the RF Links.
Can be used for either the 314MHz or 434MHz frequency bands. Be sure that the
transmitter and the receiver are using the same frequency in order to transmit
data. Buttons are connected to the transmitting Arduino on pins 8-11 and ground.
Arduino's internal pullup resistor is used with the button. Pin 13 is enabled
as a status LED to indicate when characters are being sent.
For the receiving side, they are set up in the same fashion, where LEDs are
connected to the receiving Arduino on pin 8. When a button is pressed on the
transmitter, the corresponding LED will light on the receiver if the character
matches what is expected. Pin 13 is enabled as a status LED to indicate
when characters are being received.
Note: You may need to check out the ASCII Table
when viewing the output as it is the ASCII value
http://www.asciitable.com/ for more information.
This was tested on an Arduino Uno w/ ATmega328P and RF Link Transmitters (315MHz 434MHz).
*/
// RF LINK RECEIVER LIBRARY
#include <RH_ASK.h>
#ifdef RH_HAVE_HARDWARE_SPI
#include <SPI.h> // Not actually used but needed to compile
#endif
const char *msg = "1";
const int rxPin = 11;
const int txPin = 10;
const int msgReceivedPin = 4;
const int characterMatchespin = 3;
RH_ASK driver(4800, rxPin, txPin, 0);
void setup() {
#ifdef RH_HAVE_SERIAL
Serial.begin(9600); // Debugging only
Serial.println("Initialize RF Link Rx Code");
#endif
if (!driver.init())
#ifdef RH_HAVE_SERIAL
Serial.println("init failed");
#else
;
#endif
pinMode(characterMatchespin, OUTPUT);
pinMode(msgReceivedPin, OUTPUT);
// test to make sure the LEDs will turn on before using them as a status indicator
digitalWrite(msgReceivedPin, HIGH);
digitalWrite(characterMatchespin, HIGH);
delay(5000);
digitalWrite(msgReceivedPin, LOW);
digitalWrite(characterMatchespin, LOW);
delay(1000);
}
void loop() {
//Initialize/reinitialize LEDs
digitalWrite(characterMatchespin, LOW);
//Set buffer array based on max message length
uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
//Set variable to indicate buffer length
uint8_t buflen = sizeof(buf);
if (driver.recv(buf, &buflen)) // Non-blocking
{
// Flash status LED to show received data
digitalWrite(msgReceivedPin, true);
//Note: This line of code just prints the buffer with space
// you will see the ASCII value instead of the character
// Message with a good checksum received, dump it.
//driver.printBuffer("Got:", buf, buflen);
// Message with a good checksum received, dump it.
Serial.print("Received message: ");
//print each character individually, this is useful if you are just checking for certain characters and printing it as character
//Note: The original code for the ask_receiver.pde used `int i` but it
//doesn't appear to be used. Just in case, we'll create another variable `j`
for (int j = 0; j < buflen; j++) {
// Print message received in buffer through this loop as a character by typcasting it as a char
Serial.print((char)buf[j]);
//add space to distinguish characters from each other if showing ASCII decimal #
//Serial.print(" ");
//if character received matches, turn on associated LED
if (buf[j] == '1') {
digitalWrite(characterMatchespin, HIGH);
}
}
//Print next character on new line
Serial.println("");
delay(200);
//Turn off status LED
digitalWrite(msgReceivedPin, LOW);
}
}
tx code:
/*RF ASK Tx and Rx Example Code
Created in 2011 by NPoole @ SparkFun Electronics
q
modified 13 Oct 2022
by Bobby Chan @ SparkFun Electronics
Description:
This code depends on the RadioHead Library for Arduino and is
based on the example code provided by Mike McCauley.
It is based on the ask_receivier.pde example.
To download the most recent RadioHead Library =>
http://www.airspayce.com/mikem/arduino/RadioHead/index.html
See RH_ASK.h for detailed API docs. You will need to use this code
with the 01-RadioHead-Simple_RFLink_Tx.ino.
This example shows how to use the RadioHead Library to send and receive
simple messages and use them to control digital I/O pins with the RF Links.
Can be used for either the 314MHz or 434MHz frequency bands. Be sure that the
transmitter and the receiver are using the same frequency in order to transmit
data. Buttons are connected to the transmitting Arduino on pins 8-11 and ground.
Arduino's internal pullup resistor is used with the button. Pin 13 is enabled
as a status LED to indicate when characters are being sent.
For the receiving side, they are set up in the same fashion, where LEDs are
connected to the receiving Arduino on pin 8. When a button is pressed on the
transmitter, the corresponding LED will light on the receiver if the character
matches what is expected. Pin 13 is enabled as a status LED to indicate
when characters are being received.
Note: You may need to check out the ASCII Table
when viewing the output as it is the ASCII value
http://www.asciitable.com/ for more information.
This was tested on an Arduino Uno w/ ATmega328P and RF Link Transmitters (315MHz 434MHz).
*/
// RF LINK RECEIVER LIBRARY
#include <RH_ASK.h>
#ifdef RH_HAVE_HARDWARE_SPI
#include <SPI.h> // Not actually used but needed to compile
#endif
const char *msg = "1";
const int rxPin = 11;
const int txPin = 10;
RH_ASK driver(4800, rxPin, txPin, 0);
void setup() {
#ifdef RH_HAVE_SERIAL
Serial.begin(9600); // Debugging only
Serial.println("TX Code");
#endif
if (!driver.init())
#ifdef RH_HAVE_SERIAL
Serial.println("init failed");
#else
;
#endif
}
void loop() {
delay(3000);
driver.send((uint8_t *)msg, strlen(msg));
driver.waitPacketSent();
}
Handling via email; replacement being sent