-
Notifications
You must be signed in to change notification settings - Fork 2
/
RFM95.py
49 lines (38 loc) · 1.12 KB
/
RFM95.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import board
import busio
import adafruit_rfm9x
from digitalio import DigitalInOut
import os
import logging
import time
from setup_logger import logger
class RFM95(adafruit_rfm9x.RFM9x):
"""Communication device, subclass of adafruit_rfm9x.RFM9x
Raspberry Pi Adafruit GPS
5V Vin
GND GND
EN
GPIO5 G0
SPI0_SCLK SCK
SPI0_MISO MISO
SPI0_MOSI MOSI
SPI0_CE1_N CS
GPIO25 RST
Example of how to use it:
At the same time, on the sender
>>> my_frm95 = RFM95()
>>> my_rfm95.send("Hello world!")
At the same time, on the receiver :
>>> my_rfm95 = RFM95()
>>> my_rfm95.receive()
Hello world!
For more information, read the doc of adafruit_rfm9x.RFM9x
"""
def __init__(self):
CS = DigitalInOut(board.CE1)
RESET = DigitalInOut(board.D25)
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
adafruit_rfm9x.RFM9x.__init__(
self, spi, CS, RESET, 868.0, baudrate=1000000)
self.tx_power = 23
self.enable_crc = True