Skip to content

Commit 81f1b7a

Browse files
committed
set default baudrate to 5MHz -- rename simpletest to rfm9x_simpletest
1 parent 732a40a commit 81f1b7a

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ This is easily achieved by downloading
2929
Usage Example
3030
=============
3131

32-
See examples/simpletest.py for a demo of the usage.
33-
Note: the default baudrate for the SPI is 10000000 (10MHz). This works well when you are using a board with
34-
the radio module built in (FeatherM0 RFM9x) or with an RFM9x FeatherWing mounted directly to a feather board.
32+
See examples/rfm9x_simpletest.py for a demo of the usage.
33+
Note: the default baudrate for the SPI is 50000000 (5MHz). The maximum setting is 10Mhz but
34+
transmission errors have been observed expecially when using breakout boards.
3535
For breakout boards or other configurations where the boards are separated, it may be necessary to reduce
3636
the baudrate for reliable data transmission.
3737
The baud rate may be specified as an keyword parameter when initializing the board.

adafruit_rfm9x.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
adapted from the Radiohead library RF95 code from:
2828
http: www.airspayce.com/mikem/arduino/RadioHead/
2929
30-
* Author(s): Tony DiCola
30+
* Author(s): Tony DiCola, Jerry Needell
3131
"""
3232
import time
3333
import digitalio
@@ -334,9 +334,10 @@ def __set__(self, obj, val):
334334
rx_done = _RegisterBits(_RH_RF95_REG_12_IRQ_FLAGS, offset=6, bits=1)
335335

336336
def __init__(self, spi, cs, reset, frequency, *, preamble_length=8,
337-
high_power=True, baudrate=1000000):
337+
high_power=True, baudrate=5000000):
338338
self.high_power = high_power
339339
# Device support SPI mode 0 (polarity & phase = 0) up to a max of 10mhz.
340+
# Set Default Baudrate to 5MHz to avoid problems
340341
self._device = spi_device.SPIDevice(spi, cs, baudrate=baudrate,
341342
polarity=0, phase=0)
342343
# Setup reset as a digital input (default state for reset line according
@@ -361,8 +362,9 @@ def __init__(self, spi, cs, reset, frequency, *, preamble_length=8,
361362
raise RuntimeError('Failed to configure radio for LoRa mode, check wiring!')
362363
except OSError:
363364
raise RuntimeError('Failed to communicate with radio, check wiring!')
364-
# clear default setting ofr access to LF registers
365-
self.low_frequency_mode = 0
365+
# clear default setting for access to LF registers if frquency > 525MHz
366+
if frequency > 525:
367+
self.low_frequency_mode = 0
366368
# Setup entire 256 byte FIFO
367369
self._write_u8(_RH_RF95_REG_0E_FIFO_TX_BASE_ADDR, 0x00)
368370
self._write_u8(_RH_RF95_REG_0F_FIFO_RX_BASE_ADDR, 0x00)
@@ -532,10 +534,11 @@ def rssi(self):
532534
# Remember in LoRa mode the payload register changes function to RSSI!
533535
return self._read_u8(_RH_RF95_REG_1A_PKT_RSSI_VALUE) - 137
534536

535-
def send(self, data, timeout_s=1.):
537+
def send(self, data, timeout_s=2.):
536538
"""Send a string of data using the transmitter. You can only send 252
537539
bytes at a time (limited by chip's FIFO size and appended headers). Note
538540
this appends a 4 byte header to be compatible with the RadioHead library.
541+
The timeout is just to prevent a hang (arbitrarily set to 2 Seconds).
539542
"""
540543
# Disable pylint warning to not use length as a check for zero.
541544
# This is a puzzling warning as the below code is clearly the most
File renamed without changes.

0 commit comments

Comments
 (0)