From 0e6b908a41e3b220b5317793844fe8e5809d56bb Mon Sep 17 00:00:00 2001 From: Mark Jessop Date: Fri, 18 Nov 2016 23:28:29 +1030 Subject: [PATCH] Updates to rfm22b init script, added rfm98w init script. --- init_rfm22b.py | 2 +- init_rfm98w.py | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 init_rfm98w.py diff --git a/init_rfm22b.py b/init_rfm22b.py index ab311b3..dc3ca39 100644 --- a/init_rfm22b.py +++ b/init_rfm22b.py @@ -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. diff --git a/init_rfm98w.py b/init_rfm98w.py new file mode 100644 index 0000000..3f35acd --- /dev/null +++ b/init_rfm98w.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# +# RFM98W Initialisation for Wenet Telemetry +# +# 2016-11-18 Mark Jessop +# +# 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 ") + 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...