LowPowerLab Forum

Hardware support => General topics => Topic started by: MVCutter on October 12, 2022, 09:31:59 PM

Title: Anyone play around with getting an RFM69 running on a Pico W?
Post by: MVCutter on October 12, 2022, 09:31:59 PM
I'm playing around with CircuitPython and I don't seem to be having any luck receiving data on via an RFM69HCW directly wired via SPI. I believe I have everything wired properly as it responds with the correct version and reports out temperature etc. But listening for messages from a known working node doesn't seem to be functioning. Code is pretty straight forward

# Example to send a packet periodically between addressed nodes
# Author: Jerry Needell
#
import time
import board
import busio
import digitalio
import adafruit_rfm69
from digitalio import DigitalInOut, Direction, Pull

#print(dir(board))

# set the time interval (seconds) for sending packets
transmit_interval = 10

# Define radio parameters.
RADIO_FREQ_MHZ = 433.0  # Frequency of the radio in Mhz. Must match your
# module! Can be a value like 915.0, 433.0, etc.
# dio = DigitalInOut(board.GP8)
# dio.direction = Direction.OUTPUT
# dio.value = True
# Define pins connected to the chip.
CS = digitalio.DigitalInOut(board.GP13)
RESET = digitalio.DigitalInOut(board.GP9)

# Initialize SPI bus.
spi = busio.SPI(board.GP10, MOSI=board.GP11, MISO=board.GP12)
# Initialze RFM radio
rfm69 = adafruit_rfm69.RFM69(spi, CS, RESET, RADIO_FREQ_MHZ, sync_word=b"\x31\x31\x30")

# Optionally set an encryption key (16 byte AES key). MUST match both
# on the transmitter and receiver (or be set to None to disable/the default).
rfm69.encryption_key = (
    b"\x30\x33\x30\x33\x32\x53\x68\x69\x7A\x30\x33\x32\x38\x31\x7A\x78"
)

# set node addresses
rfm69.node = 1
#rfm69.destination = 2
# initialize counter
counter = 0
# send a broadcast message from my_node with ID = counter
#rfm69.send(
#    bytes("Startup message {} from node {}".format(counter, rfm69.node), "UTF-8")
#)

# Wait to receive packets.
print("Waiting for packets...")

while True:
    # Look for a new packet: only accept if addresses to my_node
    packet = rfm69.receive(with_header=True)
    # If no packet was received during the timeout then None is returned.
    if packet is not None:
        # Received a packet!
        # Print out the raw bytes of the packet:
        print("Received (raw header):", [hex(x) for x in packet[0:4]])
        print("Received (raw payload): {0}".format(packet[4:]))
        print("Received RSSI: {0}".format(rfm69.last_rssi))


This references the Adafruit module
https://github.com/adafruit/Adafruit_CircuitPython_RFM69

Any leads would be helpful!

Thanks!