433MHz RF modules and RadioHead Library: got nothing... why???

Hi everyone, new step in the project, new issue...

I have 2 arduinos (one master and 0ne slave) talking trough these RF modules
( here ).

I already used those in other projects, but now they're not working: I removed everything from the sketch and the HW connected, I tested the modules like this and double checked the connections to be consistent with the coding. i also tried the VirtualWire library.

I'm clearly missing something...

here is the code for TX

#include <RH_ASK.h>

#define ledPin  13
#define rxPin  12
#define txPin  11

RH_ASK tx(2000,rxPin,txPin,3,true);

void setup() {
  Serial.begin(9600);
  pinMode(ledPin,OUTPUT);
   
  if (!tx.init())
  {
     Serial.println("init failed");
  }
  else
  {
    Serial.println("-- START TX");
  }

}

void loop() {
  //TRASMISSIONE
  char msg[1] = {'K'};    
  tx.send((uint8_t *)msg, 1);
  tx.waitPacketSent();       
}

here is the code for the rx

#include <RH_ASK.h>

#define ledPin  13
#define rxPin  12
#define txPin  11

RH_ASK rx(2000,rxPin,txPin,3,true);
  
void setup(){
  Serial.begin(9600);
  pinMode(ledPin,OUTPUT);
   
  if (!rx.init())
  {
    Serial.println("init failed");
  }
  else
  {
    Serial.println("-- START RX");
  }
}
 
void loop(){
  
  uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
  uint8_t buflen = sizeof(buf);
  
   if (rx.recv(buf,&buflen)) // condizione non blocking
  {
    digitalWrite(ledPin,HIGH);
    String msg = "";
    for (int i=0; i< buflen; i++)
    {
      msg+=char(buf[i]);  
    }
    Serial.print("Got:  ");Serial.println(msg);    
  }
  digitalWrite(ledPin,LOW);
}

I never get in the non-blocking condition for the receiver: led never lights.

Anybody who can see something wrong ?

thanks

Start with the simplest examples that come with either RadioHead or VirtualWire, and as instructed, connect the two Arduinos with wires instead of radio modules.

TX1 -> RX2
TX2 -> RX1
GND1 -> GND2

That will work if you have done everything correctly. Then move on to trying it with radio modules.

AVOID using Strings.

if I connect them wired (txPin 11 on transmitter ---> rxPin 12 on receiver), it works...
So I guess it is not a coding issue

But what is it then?

  • Conncetions are fine: I checked them a million times (they're just 3 jumpers per arduino...)

  • I checked the voltage on both tx and rx module: they're correctly powered up at 5V.

  • I tried to change tx/rx modules (I have a bunch of them): could they be all gone???

Any ideas?

Either the modules are defective, or you have wired them incorrectly. Post clear pictures showing the module connections.

Do you have 17 cm straight wire antennas connected to the ANT terminals on each module?

they're simply connected as you can see in the attachment

No antenna, but they are so close... I never needed any antenna for application up to 1 m.

PLus I bought 10 pairs last time, some of them already used in other projects. I can't believe they alle are defective

IMG_20180110_213348.jpg

The photo cannot be interpreted.

Transmitting Arduino on the left and receiving on the right.

Modules are directly.connected in VCC, ground and Digital pins:

Receiver

  • VCC in blue
  • gnd in purple
  • data in green

Transmitter

  • VCC in yellow
  • gnd in orange
  • data in black

I have seen those receiver units get into a state where I don't get any response unless the antennae are almost touching. Those green receiver units are really bad. The RXB12 ones (search ebay for like, RXB12 433, and you'll get em) or other ones based on SYN470 are much, much better, and still dirt cheap (the green transmitters are fine).

piepolitb:
I already used those in other projects, but now they're not working: I removed everything from the sketch and the HW connected, I tested the modules like this and double checked the connections to be consistent with the coding.

The test method in your "instructables" link doesn't work with regenerative receivers, which I think is what you have. You'll get the symptom described by "aswinth" in the second comment. The author of the "instructable" presumably was using a different receiver. The regenerative receivers' output oscillates with no signal.

It's kind of silly to suspect the transmitter receiver pair is broken if you haven't got an antenna on each. i.e. "If at first it doesn't work, try doing it the right way."

Are you suggesting to use antenna on both tx and rx? One jumper each will It be fine?

The output of all the OOK receivers transitions erratically when there isn't a signal - that's not just the superregenerative ones. They adjust the gain to get a ~50% duty cycle on the output, and if no signal is present, they ramp up the gain until they're getting 50% duty cycle from background noise

Cheap superreg receivers detune quite a bit without aerial.
So use at least a spring type aerial (for the right frequency) on the receiver.
No aerial on the transmitter is less of a problem.
Not sure what happens when TX and RX are that close together.
I would test at a minimum distance of 1meter.
Leo..

Wawa:
Cheap superreg receivers detune quite a bit without aerial.
So use at least a spring type aerial (for the right frequency) on the receiver.
No aerial on the transmitter is less of a problem.
Not sure what happens when TX and RX are that close together.
I would test at a minimum distance of 1meter.
Leo..

I found a 17cm wire to be much better than those spring-type antennas. I was very disappointed in the spring antennae.

DrAzzy:
I found a 17cm wire to be much better than those spring-type antennas. I was very disappointed in the spring antennae.

Sure, a full size 1/4λ whip with ground plane or 1/2λ dipole works best.
But a spring provides at least some load on the RF input, to reduce detuning of the receiver.

I always make a "sleeve" aerial for the receiver from a piece of thin 50ohm coax.
Much better matching than "a piece of 17cm wire", and you can get it a bit away from the 'noisy' superreg and Arduino for a better (distance) reception.

A "sleeve" aerial is made by stripping away ~30cm of the outer plastic from a piece (2meters) of thin/braided 50ohm coax. And by pusing the ground braid all the way back over the coax.
Then trim both inner core (leave the insulation) and braid to the right size (17cm each for 433Mhz, 23.5cm for 315Mhz).
Slip a piece of (40-50cm) heatshrink over it all to keep it in place, and hang it by the tip on a skyhook.
Solder the other end to ANT(core) and GND(braid) of the RF receiver.
Leo..

DrAzzy:
The output of all the OOK receivers transitions erratically when there isn't a signal - that's not just the superregenerative ones. They adjust the gain to get a ~50% duty cycle on the output, and if no signal is present, they ramp up the gain until they're getting 50% duty cycle from background noise

I just took a look at a SYN470R based superhet receiver and, as you say, the output does oscillate with no signal. I hadn't looked at this one previously, but it does have AGC per the data sheet. Moreover, the chip brings out the analog AGC signal to a rate capacitor which opens up some interesting possibilities for monitoring RSSI with the device.

this thing is getting annoying: i just soldered two antennas on tx and rx, but nothing.
I used 2 20cm jumpers

I also tried to touch them one another, but still nothing (not sure it would have worked)

Piepot, you need to pay attention to the replies. You have probably made a wiring error. But we can't see anything in the tiny, fuzzy picture you posted. Usually in cases like this, there is some tiny detail that you've missed that someone else might see. But we need clear, complete high resolution images to do that.

I'm sorry, I thought the pictures have been saved at high resolution.

here are the Google drive link to the pictures , you guys should be able to see them at the max resolution possible for my phone camera

they are now just 10-15cm away and they should be 1m away tops from each other during the normal use of the project.

In your sketch you're using pin 12 for RX, in the images it's connected to pin 13.

yes, in the current sketches they are consistent with the pictures

txPin = 11 and rxPin = 13