welcome to the forum. Well done posting code in your first post as code-sections.
There exist so many 433MHz-Rf-modules. I tried to find your by googling iHaosapce 433MHz RF Wireless but had no luck. Where have you bought the modules?
Can you provide a datasheet?
I have looked up the example at GitHub. Usually the initialisation of a "driver"-library wants to have specified the IO-pins that are used. The example-code shows this
RH_ASK driver;// RH_ASK driver(2000, 2, 4, 5);
the out-commented line has some parameters. The used line has no parameters at all.
I guess with thiss call you have to use the standard-hardware-SPI of the Arduino.
So did you connect the RFmodules to the hardware-SPIIO-Pins?
And the example does a check if the initialisation faile
if (!driver.init()) Serial.println("init failed");}
add this to your code to realy determine if sending is working
Yes, almost... I think RH library assigns default pins if none are specified, but I don't think they are the SPI pins. In any case, I remember that it is well documented in the source code.
The easy way to test correct program operation is to leave out the RF transmitter and receiver, and connect the two Arduinos with two wires (TX to RX and GND to GND).
You do not need to use the available() function. I don't know if it actually hurts to use it, but anyway it's not necessary. Here is the receive example directly from the RH library:
void loop()
{
uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
uint8_t buflen = sizeof(buf);
if (driver.recv(buf, &buflen)) // Non-blocking
{
int i;
// Message with a good checksum received, dump it.
driver.printBuffer("Got:", buf, buflen);
}
}
After trying all that you have suggested I finally got there by testing a direct connection as suggested by jremington and rather embarrassingly traced it to a bad connection on the receiver.!!
tinkering with microcontrollers includes making all kinds of basic electrical connections. It is the well known experience of everybody here to have a faulty electrical connection now and then. It is the well known experience that you don't think about a faulty electrical connection at first. Though it is a good idea to check them if something behaves strange.