예제 #1
0
def init_lora():
    global lora
    # Create library object using our bus SPI port for radio
    spi = busio.SPI(board.SCK, MISO=board.MISO, MOSI=board.MOSI)
    # RFM9x Breakout Pinouts
    cs = digitalio.DigitalInOut(board.D6)
    irq = digitalio.DigitalInOut(board.D5)
    # TTN Device Address, 4 Bytes, MSB
    devaddr = bytearray([0x26, 0x01, 0x14, 0xE1])
    # TTN Network Key, 16 Bytes, MSB
    nwkey = bytearray([
        0xAF, 0x6E, 0xE8, 0xC4, 0x20, 0x42, 0x62, 0x86, 0x96, 0xFB, 0xFB, 0xF7,
        0x74, 0x00, 0xA7, 0xA1
    ])
    # TTN Application Key, 16 Bytess, MSB
    app = bytearray([
        0x7F, 0x06, 0x6A, 0xF1, 0xE2, 0xD9, 0xDB, 0x62, 0x53, 0x39, 0x53, 0xA7,
        0x90, 0x9D, 0x60, 0xC2
    ])
    ttn_config = TTN(devaddr, nwkey, app, country='EU')
    lora = TinyLoRa(spi, cs, irq, ttn_config)
예제 #2
0
    def __init__(self, spi, cs_pin, reset_pin,
                 dev_addr, nwk_key, app_key, tx_led=None,
                 name="lrw0", interval=10.0, *args, **kwargs):

        Device.__init__(self, name=name, interval=interval, *args, **kwargs)

        from adafruit_tinylora.adafruit_tinylora import TTN, TinyLoRa
        import digitalio

        cs = digitalio.DigitalInOut(cs_pin)
        reset = digitalio.DigitalInOut(reset_pin)

        self.tx_led = tx_led
        if self.tx_led:
            self.tx_led = digitalio.DigitalInOut(tx_led)
            self.tx_led.direction = digitalio.Direction.OUTPUT

        ttn_config = TTN(dev_addr, nwk_key, app_key, country='US')
        # Suppose to be cs, irq, rst, ttn_config?
        self.lora = TinyLoRa(spi, cs, reset, ttn_config)

        self.data["tx_buffer"] = None
예제 #3
0
# TTN Device Address, 4 Bytes, MSB
devaddr = bytearray([0x00, 0x00, 0x00, 0x00])

# TTN Network Key, 16 Bytes, MSB
nwkey = bytearray([
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00
])

# TTN Application Key, 16 Bytess, MSB
app = bytearray([
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00
])

ttn_config = TTN(devaddr, nwkey, app, country='US')

lora = TinyLoRa(spi, cs, irq, ttn_config)

# Data Packet to send to TTN
data = bytearray(4)

while True:
    temp_val = sensor.temperature
    humid_val = sensor.relative_humidity
    print('Temperature: %0.2f C' % temp_val)
    print('relative humidity: %0.1f %%' % humid_val)

    # Encode float as int
    temp_val = int(temp_val * 100)
    humid_val = int(humid_val * 100)
예제 #4
0
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
])

ttn_config = TTN(devaddr, nwkey, app, country="US")

lora = TinyLoRa(spi, cs, irq, rst, ttn_config)

# Data Packet to send to TTN
data = bytearray(4)

while True:
    temp_val = sensor.temperature
    humid_val = sensor.relative_humidity
    print("Temperature: %0.2f C" % temp_val)
    print("relative humidity: %0.1f %%" % humid_val)

    # Encode float as int
    temp_val = int(temp_val * 100)
    humid_val = int(humid_val * 100)
예제 #5
0
rst = digitalio.DigitalInOut(board.D4)

#set up the temperature sensor device for tiny lora
temp_addr = bytearray([0x26, 0x01, 0x18, 0x92])
# network key from the things network console
temp_netw_key = bytearray([
    0x4E, 0xF8, 0x21, 0xA4, 0x11, 0x98, 0xA8, 0x5D, 0x51, 0x2D, 0x2A, 0xD3,
    0x0C, 0xCA, 0x91, 0xB7
])
# application key from the things network console
temp_app_key = bytearray([
    0x22, 0xD5, 0xC3, 0x29, 0xE9, 0x06, 0x77, 0xD9, 0x22, 0xBB, 0x28, 0xA6,
    0x0B, 0x55, 0xB0, 0x62
])
#configure the moisture sensor for the things network
temp_ttn_config = TTN(temp_addr, temp_netw_key, temp_app_key, country="EU")
# create a tiny loar object for the temperature sensor
temp_lora = TinyLoRa(spi, cs, irq, rst, temp_ttn_config, channel=0)

# set up the moisture sensor device for tiny lora
moisture_addr = bytearray([0x26, 0x01, 0x15, 0xA9])
# network key from the things network console
moisture_netw_key = bytearray([
    0xD9, 0x56, 0xFE, 0x3B, 0xDB, 0x76, 0x78, 0x4D, 0xBA, 0x28, 0x1E, 0x5D,
    0x89, 0xE2, 0x11, 0xD4
])
# application key from the things network console
moisture_app_key = bytearray([
    0xB2, 0x26, 0xDE, 0x4B, 0xB5, 0x99, 0xF7, 0x7D, 0xDD, 0xE1, 0xCD, 0x0B,
    0x6C, 0x9D, 0xF2, 0x0E
])