433 MHz RF transmitter tutorial trouble on Elegato boards

I'm following this tutorial Insight Into How 433MHz RF Tx-Rx Modules Work & Interface with Arduino to set up two elegato boards (essentially arduino uno), one with an rf transmitter and one with a receiver. The issue is I'm not seeing anything being received. I'm wondering if this could be because of the elegato boards I'm using. Or if there's a good way to debug this. I've tried printing the serial output to make sure the message send request is being queued properly. I've switched out the transmitter and receiver units and tried sending data on different pins. I feel like I'm missing something obvious, but I'm just trying to follow the tutorial exactly. I've looked through the forum for similar problems, but I haven't been able to fix my issue. Any idea what I'm doing wrong?

Here's the code I'm using for the transmitter

// Include RadioHead Amplitude Shift Keying Library
#include <RH_ASK.h>
// Include dependant SPI Library 
#include <SPI.h> 
 
// Create Amplitude Shift Keying Object
RH_ASK rf_driver;
 
void setup()
{
    // Initialize ASK Object
    rf_driver.init();
}
 
void loop()
{
    const char *msg = "Hello World";
    rf_driver.send((uint8_t *)msg, strlen(msg));
    rf_driver.waitPacketSent();
    delay(1000);
}

Here's the code I'm using for the receiver

// Include RadioHead Amplitude Shift Keying Library
#include <RH_ASK.h>
// Include dependant SPI Library 
#include <SPI.h> 
 
// Create Amplitude Shift Keying Object
RH_ASK rf_driver;
 
void setup()
{
    // Initialize ASK Object
    rf_driver.init();
    // Setup Serial Monitor
    Serial.begin(9600);
}
 
void loop()
{
    // Set buffer to size of expected message
    uint8_t buf[11];
    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);         
    }
}

Here are the circuits I've wired.



Thanks!

Unfortunately you have chosen a very poor tutorial to follow.

Antennas are required on both transmitter and receiver. 17 cm of straight wire connected to ANT works well.

I would set this to be larger, to accommodate larger messages.

    uint8_t buf[11]; //set 11 to 40 or larger.

The following line is guaranteed to lead to problems, with gibberish being printed on the serial monitor, because the received message is not properly zero terminated.

      Serial.println((char*)buf); 

AFTER increasing the input message buffer size, add a couple of lines to the receiver code as follows:

    if (rf_driver.recv(buf, &buflen))
    {
      if (buflen < sizeof(buf)) buf[buflen]=0;  //make sure the message is zero
 terminated.
    else buf[sizeof(buf) - 1]=0;
1 Like

After you put on the antennas use an external power supply for the radios and be sure the antennas are at least 1 meter apart.

1 Like

Thank you for the responses. I got it working! The key issue was the antenna. Though jremington was also right about the buffer.

1 Like

Late to the thread but...

I bought a few pairs of cheap Tx/Rx modules, intending to dip my toes into the 433 MHz waters. Two days ago started trying to get them working. In vain. Studied dozens of threads and tutorials and tried many sketches but success remains elusive.

So as my next step it would be helpful if you could please share your final code, including the edits suggested by @jremington. I could not get my version of that working with Nanos today, and will next yet try UNO, or a mix.

On an associated point, like almost every 433 MHz sketch I've seen, your code appears to be using the RH.ASK library, with the ask_transmitter.ino and ask_receiver.ino examples.

So it dents my confidence if these widely used sketches are significantly flawed. Puzzling too, as I'd have expected them to be corrected by now?

So it appears to be a Nano issue. Worked OK with UNOs.

The two Nanos run other sketches, such as blink.ino.

Not optimistic but will now try the two configurations: Nano to UNO, and UNO to Nano.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.