Updates to rfm22b init script, added rfm98w init script.

pull/1/head
Mark Jessop 2016-11-18 23:28:29 +10:30
rodzic 95eda9a58c
commit 0e6b908a41
2 zmienionych plików z 65 dodań i 1 usunięć

Wyświetl plik

@ -268,7 +268,7 @@ if __name__ == '__main__':
tx_freq = tx_freq*1e6
rfm = RFM22B()
rfm.set_tx_power(TXPOW.TXPOW_14DBM | 0x08)
rfm.set_tx_power(TXPOW.TXPOW_17DBM | 0x08)
rfm.set_frequency(tx_freq)
rfm.write_register(REG.GPIO2_CONFIGURATION,0x30) # TX Data In
rfm.set_bulk(CONFIGS.REGISTERS,CONFIGS.DIRECT_120K) # Direct Asynchronous mode, ~120KHz tone spacing.

64
init_rfm98w.py 100644
Wyświetl plik

@ -0,0 +1,64 @@
#!/usr/bin/env python
#
# RFM98W Initialisation for Wenet Telemetry
#
# 2016-11-18 Mark Jessop <vk5qi@rfhead.net>
#
# Requires pySX127x:
# https://github.com/darksidelemm/pySX127x
# Copy the SX127x directory into this directory...
#
# Uses spidev for comms with a RFM98W module.
#
# Note: As with the RFM22B version, all this script does
# is get the RFM98W onto the right frequency, and into the right mode.
#
# SPI: Connected to CE0 (like most of my LoRa shields)
# RPi TXD: Connected to RFM98W's DIO2 pin.
#
from SX127x.LoRa import *
from SX127x.hardware_piloragateway import HardwareInterface
import sys
if __name__ == '__main__':
# Attempt to extract a frequency from the first argument:
if len(sys.argv)<2:
print("Usage: \tpython init_rfm98w.py <TX Frequency in MHz>")
print("Example: \tpython init_rfm98w.py 441.200")
sys.exit(1)
try:
tx_freq = float(sys.argv[1])
except:
print("Unable to parse input.")
if tx_freq>450.0 or tx_freq<430.00:
print("Frequency out of 70cm band, using default.")
tx_freq = 441.200
# Set this to 1 if your RFM98W is on CE1
hw = HardwareInterface(0)
# 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
lora.set_register(0x31,0x00) # Set Continuous Mode
# Set TX Frequency
lora.set_freq(tx_freq)
# Set Deviation (~70 kHz). Signals ends up looking a bit wider than the RFM22B version.
lora.set_register(0x04,0x04)
lora.set_register(0x05,0x99)
# Set Transmit power to 50mW
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...