Problem with RFM69HCW and MetroM0 Express

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
adafruit_support_carter
 
Posts: 29168
Joined: Tue Nov 29, 2016 2:45 pm

Re: Problem with RFM69HCW and MetroM0 Express

Post by adafruit_support_carter »

There is no RESET pin in the board module. The RST pin from the radio module can just be tied to a digital IO pin.

You have found the correct pins to use for SPI:
https://learn.adafruit.com/adafruit-met ... ts#step-10
and then you can use any other 2 digital pins for RST and CS. The example here uses 5 and 6:
https://learn.adafruit.com/adafruit-rfm ... #usage-6-8

Once you've attached to those SPI pins and the 2 digital pins, then follow that example for the general syntax and usage.

User avatar
ludiusvox
 
Posts: 26
Joined: Sat Sep 07, 2013 10:21 am

Re: Problem with RFM69HCW and MetroM0 Express

Post by ludiusvox »

Yea it appears that the digital pins are what causes problems with the software (with the circuitpython library). Everything else is working fine

User avatar
adafruit_support_carter
 
Posts: 29168
Joined: Tue Nov 29, 2016 2:45 pm

Re: Problem with RFM69HCW and MetroM0 Express

Post by adafruit_support_carter »

If you'd rather use the pins on the regular header row, you can. For example:

Code: Select all

spi = busio.SPI(board.D13, MOSI=board.D12, MISO=board.D11)
The pins need to be available. Like D13 can't be used for an LED at the same time. And if it complains about that function not being available for the pin, try a different pin.

User avatar
ludiusvox
 
Posts: 26
Joined: Sat Sep 07, 2013 10:21 am

Re: Problem with RFM69HCW and MetroM0 Express

Post by ludiusvox »

I got the SPI line initializing, it’s the CS line and the RESET line that are giving me trouble.

When I get home I will try different pin and stuff

User avatar
adafruit_support_carter
 
Posts: 29168
Joined: Tue Nov 29, 2016 2:45 pm

Re: Problem with RFM69HCW and MetroM0 Express

Post by adafruit_support_carter »

FWIW - I hooked one of these up to a Metro M0 Express like this:
  • VIN - 3.3V
  • GND - GND
  • SCK - 13
  • MOSI - 12
  • MISO - 11
  • CS - 5
  • RST - 6
and got it working.

Here's the code. Note I commented out all the LED stuff which was using 13.

Code: Select all

# Simple example to send a message and then wait indefinitely for messages
# to be received.  This uses the default RadioHead compatible GFSK_Rb250_Fd250
# modulation and packet format for the radio.
# Author: Tony DiCola
import board
import busio
import digitalio

import adafruit_rfm69


# Define radio parameters.
RADIO_FREQ_MHZ = 915.0  # Frequency of the radio in Mhz. Must match your
                        # module! Can be a value like 915.0, 433.0, etc.

# Define pins connected to the chip, use these if wiring up the breakout according to the guide:
CS = digitalio.DigitalInOut(board.D5)
RESET = digitalio.DigitalInOut(board.D6)
# Or uncomment and instead use these if using a Feather M0 RFM69 board
# and the appropriate CircuitPython build:
#CS = digitalio.DigitalInOut(board.RFM69_CS)
#RESET = digitalio.DigitalInOut(board.RFM69_RST)

# Define the onboard LED
#LED = digitalio.DigitalInOut(board.D13)
#LED.direction = digitalio.Direction.OUTPUT

# Initialize SPI bus.
#spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
spi = busio.SPI(board.D13, MOSI=board.D12, MISO=board.D11)

# Initialze RFM radio
rfm69 = adafruit_rfm69.RFM69(spi, CS, RESET, RADIO_FREQ_MHZ)

# 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'\x01\x02\x03\x04\x05\x06\x07\x08\x01\x02\x03\x04\x05\x06\x07\x08'

# Print out some chip state:
print('Temperature: {0}C'.format(rfm69.temperature))
print('Frequency: {0}mhz'.format(rfm69.frequency_mhz))
print('Bit rate: {0}kbit/s'.format(rfm69.bitrate/1000))
print('Frequency deviation: {0}hz'.format(rfm69.frequency_deviation))

# Send a packet.  Note you can only send a packet up to 60 bytes in length.
# This is a limitation of the radio packet size, so if you need to send larger
# amounts of data you will need to break it into smaller send calls.  Each send
# call will wait for the previous one to finish before continuing.
rfm69.send(bytes('Hello world!\r\n',"utf-8"))
print('Sent hello world message!')

# Wait to receive packets.  Note that this library can't receive data at a fast
# rate, in fact it can only receive and process one 60 byte packet at a time.
# This means you should only use this for low bandwidth scenarios, like sending
# and receiving a single message at a time.
print('Waiting for packets...')
while True:
    packet = rfm69.receive()
    # Optionally change the receive timeout from its default of 0.5 seconds:
    #packet = rfm69.receive(timeout=5.0)
    # If no packet was received during the timeout then None is returned.
    if packet is None:
        # Packet has not been received
        #LED.value = False
        print('Received nothing! Listening again...')
    else:
        # Received a packet!
        #LED.value = True
        # Print out the raw bytes of the packet:
        print('Received (raw bytes): {0}'.format(packet))
        # And decode to ASCII text and print it too.  Note that you always
        # receive raw bytes and need to convert to a text format like ASCII
        # if you intend to do string processing on your data.  Make sure the
        # sending side is sending ASCII data before you try to decode!
        packet_text = str(packet, 'ascii')
        print('Received (ASCII): {0}'.format(packet_text))

User avatar
ludiusvox
 
Posts: 26
Joined: Sat Sep 07, 2013 10:21 am

Re: Problem with RFM69HCW and MetroM0 Express

Post by ludiusvox »

Ok I will copy.

Locked
Please be positive and constructive with your questions and comments.

Return to “Metro, Metro Express, and Grand Central Boards”