Datasheet
Basic Transmission Code
If you are using the transmitter, this code will wait 1 second, then transmit a packet with "Hello World #" and an
incrementing packet number, then check for a reply
Its pretty simple, the delay does the waiting, you can replace that with low power sleep code. Then it generates the
packet and appends a number that increases every tx. Then it simply calls send() waitPacketSent() to wait until is is
done transmitting.
It will then wait up to 500 milliseconds for a reply from the receiver with waitAvailableTimeout(500) . If there is a reply, it
will print it out. If not, it will complain nothing was received. Either way the transmitter will continue the loop and sleep
for a second until the next TX.
Basic Receiver Code
The Receiver has the same exact setup code, but the loop is different
void loop() {
delay(1000); // Wait 1 second between transmits, could also 'sleep' here!
char radiopacket[20] = "Hello World #";
itoa(packetnum++, radiopacket+13, 10);
Serial.print("Sending "); Serial.println(radiopacket);
// Send a message!
rf69.send((uint8_t *)radiopacket, strlen(radiopacket));
rf69.waitPacketSent();
// Now wait for a reply
uint8_t buf[RH_RF69_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if (rf69.waitAvailableTimeout(500)) {
// Should be a reply message for us now
if (rf69.recv(buf, &len)) {
Serial.print("Got a reply: ");
Serial.println((char*)buf);
Blink(LED, 50, 3); //blink LED 3 times, 50ms between blinks
} else {
Serial.println("Receive failed");
}
} else {
Serial.println("No reply, is another RFM69 listening?");
}
}
© Adafruit Industries
https://learn.adafruit.com/adafruit-rfm69hcw-and-rfm96-rfm95-rfm98-lora-packet-padio-
breakouts
Page 34 of 70