I'm new to Arduino programming and I'm trying to get a simple 433 MHz transmitter and receiver module working on an Arduino Uno board. Unsurprisingly, it's not working as expected and I'm trying to debug the problem.
I'm using RadioHead and read in the documentation that the send() and waitPacketSent() methods return a boolean to indicate success. However, I disconnected the data wire and the send() method still returns true. As the module is no longer connected to the arduino I would have expected it to return false.
I understand that the messages are sent as unreliable datagrams, but I'm just trying to work out whether the transmitter has actually sent something. Is there some way I can do this?
The code I'm using is relatively short, so I've included it in full below, for what it's worth
#include <RH_ASK.h>
#include <RadioHead.h>
#ifdef RH_HAVE_HARDWARE_SPI
#include <SPI.h> // Not actually used but needed to compile
#endif
RH_ASK driver;
bool sent;
void setup()
{
#ifdef RH_HAVE_SERIAL
Serial.begin(9600); // Debugging only
#endif
if (!driver.init())
#ifdef RH_HAVE_SERIAL
Serial.println("init failed");
#else
;
#endif
sent = false;
}
void loop()
{
uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
uint8_t buflen = sizeof(buf);
const char *msg = "hello";
bool sendSuccess;
bool waitSuccess;
if (!sent) {
Serial.println("sending");
sendSuccess = driver.send((uint8_t *)msg, strlen(msg));
if (sendSuccess) {
Serial.println("Send completed successfully");
} else {
Serial.println("Send Error");
}
Serial.println("Waiting");
waitSuccess = driver.waitPacketSent();
if (waitSuccess) {
Serial.println("Wait Sent Success");
} else {
Serial.println("Wait Sent Error");
}
Serial.println("Done Sending");
sent = true;
delay(1000);
}
if (driver.recv(buf, &buflen)) // Non-blocking
{
Serial.println("driver.recv");
// Message with a good checksum received, dump it.
driver.printBuffer("Got:", buf, buflen);
}
}
The output on the serial monitor is as follows
22:22:30.647 -> sending
22:22:30.647 -> Send completed successfully
22:22:30.684 -> Waiting
22:22:30.753 -> Wait Sent Success
22:22:30.753 -> Done Sending
Thanks in advance!