def setup_rfm98w(frequency=441.200, spi_device=0, shutdown=False, deviation = 71797): # Set this to 1 if your RFM98W is on CE1 hw = HardwareInterface(spi_device) # Start talking to the module... lora = LoRa(hw) # Set us into FSK mode, and set continuous mode on lora.set_register(0x01,0x00) # Standby Mode # If we have been asked to shutdown the RFM98W, then exit here. if shutdown: sys.exit(0) # Otherwise, proceed. lora.set_register(0x31,0x00) # Set Continuous Mode # Set TX Frequency lora.set_freq(frequency) # Set Deviation (~70 kHz). Signals ends up looking a bit wider than the RFM22B version. _dev_lsbs = int(deviation / 61.03) _dev_msb = _dev_lsbs >> 8 _dev_lsb = _dev_lsbs % 256 lora.set_register(0x04,_dev_msb) lora.set_register(0x05,_dev_lsb) # Set Transmit power to 50mW. # NOTE: If you're in another country you'll probably want to modify this value to something legal... lora.set_register(0x09,0x8F) # Go into TX mode. lora.set_register(0x01,0x02) # .. via FSTX mode (where the transmit frequency actually gets set) lora.set_register(0x01,0x03) # Now we're in TX mode...
def lorainit(): global lora BOARD.setup() lora = LoRa(verbose=False) lora.set_mode(MODE.STDBY) lora.set_freq(923.0) #set to 915MHz for SG use
def setup_rfm98w(frequency=434.650, spi_device=0, shutdown=False): # Set this to 1 if your RFM98W is on CE1 hw = HardwareInterface(spi_device) # Start talking to the module... lora = LoRa(hw) # Set us into FSK mode, and set continuous mode on lora.set_register(0x01, 0x00) # Standby Mode # If we have been asked to shutdown the RFM98W, then exit here. if shutdown: print("Transmitter shutdown.") sys.exit(0) # Otherwise, proceed. lora.set_register(0x31, 0x00) # Set Continuous Mode # Set TX Frequency lora.set_freq(frequency) # Set Deviation (~470 Hz) lora.set_register(0x04, 0x00) lora.set_register(0x05, 0x04) # Set Transmit power to 50mW. # NOTE: If you're in another country you'll probably want to modify this value to something legal... lora.set_register(0x09, 0x8F) # Go into TX mode. lora.set_register( 0x01, 0x02 ) # .. via FSTX mode (where the transmit frequency actually gets set) lora.set_register(0x01, 0x03) # Now we're in TX mode...
from SX127x.LoRa import * from SX127x.board_config import BOARD import time import RPi.GPIO as GPIO BOARD.setup() lora = LoRa() lora.set_mode(MODE.STDBY) print(lora.get_freq()) lora.set_freq(478.0) lora.set_coding_rate(CODING_RATE.CR4_6) lora.set_rx_crc(1) lora.set_register(0x1E, 0x94) print(hex(lora.get_register(0x1E))) lora.set_register(0x12, 0xff) lora.set_mode(MODE.RXCONT) lora.set_mode(MODE.RXCONT) lora.set_mode(MODE.RXCONT) value = lora.get_all_registers() print(value) print(len(value)) List = [] for i in range(0, len(value)): List.append(hex(i) + '--' + hex(value[i])) print(List)
from SX127x.LoRa import * from SX127x.board_config import BOARD BOARD.setup() lora = LoRa() lora.set_mode(MODE.STDBY) lora.set_freq(433.0) # Set the frequency to 433 MHz print 'freq = %s' % lora.get_freq() BOARD.teardown()