Merge pull request #16 from ke5gdb/rfm98w_packettx

Added get_temperature function to radio_wrappers.py
rfm98w_packettx
Mark Jessop 2024-09-27 14:27:48 +09:30 zatwierdzone przez GitHub
commit b94ffcbcf5
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
1 zmienionych plików z 16 dodań i 0 usunięć

Wyświetl plik

@ -54,6 +54,8 @@ class RFM98W_Serial(object):
self.tx_packet_count = 0
self.temperature = -999
self.start()
@ -87,6 +89,9 @@ class RFM98W_Serial(object):
self.lora.set_register(0x01,0x00) # FSK Sleep Mode
self.lora.set_register(0x31,0x00) # Set Continuous Transmit Mode
# Get the IC temperature
self.temperature = self.get_temperature()
self.lora.set_freq(self.frequency)
logging.info(f"RFM98W - Frequency set to: {self.frequency} MHz.")
@ -203,6 +208,17 @@ class RFM98W_Serial(object):
logging.info(f"RFM98W - Reinitialising Radio at {self.tx_packet_count} packets.")
self.start()
def get_temperature(self):
"""
Get radio module temperature (uncalibrated)
"""
# Make temperature measurement
temperature = self.lora.get_register(0x3c) * (-1)
if temperature < -63:
temperature += 255
logging.info(f"RFM98W - Temperature: {self.temperature} C")
return temperature
class SerialOnly(object):
"""