/ README.rst
README.rst
1 Introduction 2 ============ 3 4 .. image:: https://readthedocs.org/projects/adafruit-circuitpython-rfm9x/badge/?version=latest 5 :target: https://circuitpython.readthedocs.io/projects/rfm9x/en/latest/ 6 :alt: Documentation Status 7 8 .. image:: https://img.shields.io/discord/327254708534116352.svg 9 :target: https://adafru.it/discord 10 :alt: Discord 11 12 .. image:: https://github.com/adafruit/Adafruit_CircuitPython_RFM9x/workflows/Build%20CI/badge.svg 13 :target: https://github.com/adafruit/Adafruit_CircuitPython_RFM9x/actions/ 14 :alt: Build Status 15 16 CircuitPython module for the RFM95/6/7/8 LoRa 433/915mhz radio modules. 17 18 Dependencies 19 ============= 20 This driver depends on: 21 22 * `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_ 23 * `Bus Device <https://github.com/adafruit/Adafruit_CircuitPython_BusDevice>`_ 24 25 Please ensure all dependencies are available on the CircuitPython filesystem. 26 This is easily achieved by downloading 27 `the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_. 28 29 Installing from PyPI 30 ==================== 31 32 On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from 33 PyPI <https://pypi.org/project/adafruit-circuitpython-rfm9x/>`_. To install for current user: 34 35 .. code-block:: shell 36 37 pip3 install adafruit-circuitpython-rfm9x 38 39 To install system-wide (this may be required in some cases): 40 41 .. code-block:: shell 42 43 sudo pip3 install adafruit-circuitpython-rfm9x 44 45 To install in a virtual environment in your current project: 46 47 .. code-block:: shell 48 49 mkdir project-name && cd project-name 50 python3 -m venv .env 51 source .env/bin/activate 52 pip3 install adafruit-circuitpython-rfm9x 53 54 Usage Example 55 ============= 56 57 Initialization of the RFM radio requires specifying a frequency appropriate to 58 your radio hardware (i.e. 868-915 or 433 MHz) and specifying the pins used in your 59 wiring from the controller board to the radio module. 60 61 This example code matches the wiring used in the 62 `LoRa and LoRaWAN Radio for Raspberry Pi <https://learn.adafruit.com/lora-and-lorawan-radio-for-raspberry-pi/>`_ 63 project: 64 65 .. code-block:: python 66 67 import digitalio 68 import board 69 import busio 70 import adafruit_rfm9x 71 72 RADIO_FREQ_MHZ = 915.0 73 CS = digitalio.DigitalInOut(board.CE1) 74 RESET = digitalio.DigitalInOut(board.D25) 75 spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) 76 rfm9x = adafruit_rfm9x.RFM9x(spi, CS, RESET, RADIO_FREQ_MHZ) 77 78 Note: the default baudrate for the SPI is 50000000 (5MHz). The maximum setting is 10Mhz but 79 transmission errors have been observed expecially when using breakout boards. 80 For breakout boards or other configurations where the boards are separated, it may be necessary to reduce 81 the baudrate for reliable data transmission. 82 The baud rate may be specified as an keyword parameter when initializing the board. 83 To set it to 1000000 use : 84 85 .. code-block:: python 86 87 # Initialze RFM radio with a more conservative baudrate 88 rfm9x = adafruit_rfm9x.RFM9x(spi, CS, RESET, RADIO_FREQ_MHZ, baudrate=1000000) 89 90 Optional controls exist to alter the signal bandwidth, coding rate, and spreading factor 91 settings used by the radio to achieve better performance in different environments. 92 By default, settings compatible with RadioHead Bw125Cr45Sf128 mode are used, which can 93 be altered in the following manner (continued from the above example): 94 95 .. code-block:: python 96 97 # Apply new modem config settings to the radio to improve its effective range 98 rfm9x.signal_bandwidth = 62500 99 rfm9x.coding_rate = 6 100 rfm9x.spreading_factor = 8 101 rfm9x.enable_crc = True 102 103 See examples/rfm9x_simpletest.py for an expanded demo of the usage. 104 105 106 Contributing 107 ============ 108 109 Contributions are welcome! Please read our `Code of Conduct 110 <https://github.com/adafruit/Adafruit_CircuitPython_RFM9x/blob/master/CODE_OF_CONDUCT.md>`_ 111 before contributing to help this project stay welcoming. 112 113 Documentation 114 ============= 115 116 For information on building library documentation, please check out `this guide <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/sharing-our-docs-on-readthedocs#sphinx-5-1>`_.