I am building a system in which an Arduino Uno with an RFM69 radio chip transmits data to a Raspberry Pi running a script in Python.
I am using the RFM69 library for both scripts:
The Raspberry Pi successfully receives data packets, and shows that it also sends an acknowledgement (ACK) of this to the transmitter. However, the transmitted node does not receive this ACK. It is worth noting that when this was implemented using 2 Arduino boards, it worked, so it does not appear to be a hardware issue.
The code for the Raspberry Pi based receiver is as follows:
def receive_loop():
tick = 0
retry_window = 0.5
while True:
radio.begin_receive()
# If no packet received, wait retry_window seconds, then retry.
time_start = time.time()
while radio.has_received_packet == False:
if time.time() >= (time_start + retry_window):
return
for packet in radio.get_packets():
radio_info = packet.to_dict()
if radio_info['sender'] > 0:
tick += 1
print("Received from node: ", radio_info)
print("Receive cycle: " + str(tick))
return
with Radio(FREQ_433MHZ, my_node_id, network_id, isHighPower=False, promiscuousMode=True, auto_acknowledge=True) as radio:
receive_loop()
The snippet of code from the Arduino which deals with transmitting the data is as follows:
bool loop_var = true;
int tock = 0;
while (loop_var == true) {
if (radio.sendWithRetry(TONODEID, RF_payload, sizeof(RF_payload)+1)) {
Serial.print("\nMessage sent.\n___\n\n");
loop_var = false;
}
else {
if (tock == 0) {
Serial.print("\nNo ACK received, retrying...\n\n");
tock++;
}
}
}
My assumption is that there is an issue with the two versions of the RFM69 library communicating properly, however, it is beyond my level of understanding to deduct why.
The issue stems from hardware compatibility. The RFM69 HCW radio module used needs to draw at least 40mA of power, whereas a single GPIO pin on a RaspberryPi 3b+ can only safely provide 16mA.
This meant that the radio chip would transmit, but only at very low power, meaning that the range was < 1cm.
To solve this issue, it is possible to build a hat for your Raspberry Pi with a voltage regulator which connects to the 5V pin. This increases the power the radio chip can draw, whilst maintaining a safe level of voltage supply. See below for a circuit diagram of said hat using a LM1117 3.3V voltage regulator: