Go Down

Topic: Problem sending anything with RF 433MHz using radiohead. (Read 175 times) previous topic - next topic

Svalan

Jan 11, 2019, 06:05 pm Last Edit: Jan 11, 2019, 07:37 pm by Svalan Reason: wrong wiring in picture
Hi, I'm having trouble sending messages and values with my RF 433MHz Transmitter/Receiver Module.

I have a few days ago successfully sent values from my Arduino Uno to a Feather HUZZAH ESP8266 and an Arduino Nano, but I had problem sending a message from the feather (both have 1 reciever and 1 transmitter). They never sent at the same time so no interference. I did manage to send from the feather to the Arduino Nano though but the signal was very weak so maybe 1/20 arrived (distance 10 cm). No difference when changing to the other reciever or transmitter.


I have no extra antennas but distance is not a problem, it's just a experiment.


The big problem is now that I can't send anything from anywhere and I don't know where to continue. I have tried everything!!
  • Sending from all 3 (one at the time), the other 2 listening
  • Tried 5V powersupply from different sources, all the MCUs and battery with bread board power supply.
  • Bought new RF 433, (total 4 recievers and 4 transmitters)
  • Reinstalled RH_ASK.h
  • Changing pins on rx/tx and even PTT
  • Different delays
  • Different size of package 4 (like in 4 bytes in 'test'), 8, 32, 255


I have taken away my original project and only try to send the most simple stuff

Reciever (32 byte package)

Code: [Select]

#include <RH_ASK.h>
#include <SPI.h>
RH_ASK rf_driver (2000,7,8,10);

void setup()
{
  Serial.begin(115200);
  rf_driver.init();
}

void loop()
{
  recTest();
  recTest2();
  recTest3();
}

void recTest()
{
  uint8_t msgRecieved[32];
  uint8_t buflen = sizeof(msgRecieved);
  if (rf_driver.recv(msgRecieved, 32))
  {
    Serial.println(" ");
    Serial.print("Recieved: ");
    Serial.println((char*)msgRecieved);
  }
  else
  {
    Serial.print(".");
    delay(200);
  }
}
void recTest2()
{
    uint8_t msgRecieved[32];
  uint8_t buflen = sizeof(msgRecieved);
  if (rf_driver.recv(msgRecieved, &buflen))
  {
    Serial.println(" ");
    Serial.print("Recieved: ");
    Serial.println((char*)msgRecieved);
  }
  else
  {
    Serial.print("-");
    delay(500);
  }
}

void recTest3()
{
  uint8_t msgRecieved[RH_ASK_MAX_MESSAGE_LEN];
  uint8_t buflen = sizeof(msgRecieved);
  if (rf_driver.recv(msgRecieved, &buflen))
  {
    Serial.println(" ");
    Serial.print("Recieved: ");
    Serial.println((char*)msgRecieved);
  }
  else
  {
    Serial.print(",");
    delay(1000);
  }
}


Sender

Code: [Select]

#include <RH_ASK.h>
#include <SPI.h>

RH_ASK rf_driver;

void setup()
{
  Serial.begin(115200);
  rf_driver.init();
}

void loop()
{
  sendTest();
  //sendTest2(); // pick one
}
 
void sendTest()
{
  const char *msg  = "Test";
  rf_driver.send((uint8_t *)msg, 4);
  rf_driver.waitPacketSent();
  Serial.print("Message sent: ");
  Serial.println(msg);
  delay(500);
}

void sendTest2()
{
  const char *msg  = "Test";
  rf_driver.send((uint8_t *)msg, 4);
  rf_driver.waitPacketSent();
  Serial.print("Message sent: ");
  Serial.println(msg);
  delay(1000);
}




I have been trying for days! What am I missing?? :smiley-confuse:  :o
Below is picture of wiring (WRONG in picture. I accidently moved 1 cable on arduino when taking the photo, there is not 2 wires to ground)

cattledog

The problem is not in your code. If you bypass the radios and connect pin 12 of the sending arduino to pin 7 of the receiving arduino your messages come across. Better would be to use the library examples.

There is something wrong in the wiring but I can't see it. You may need antennas. You can try stick a piece 17 cm rigid bare wire in a breadboard hole at the antenna location.

Svalan

Ah wow, well that works great. Why didn't I think of that, could have spared me lots of hours. Now I can focus on my code at least and get that going. Thanks!

Go Up