Esempio n. 1
0
def send(lora):

    sensor = dht.DHT11(Pin(17))

    counter = 0
    print("LoRa Sender")
    display = Display()

    while True:
        ident = "LoRa Sender"

        sleep(2)

        sensor.measure()

        temp = sensor.temperature()
        temp_conv = str('{:d} C'.format(temp))
        hum = sensor.humidity()
        hum_conv = str('{:d} %'.format(hum))

        payload = '{} {} ({})'.format(temp_conv, hum_conv, counter)

        #payload = 'Hello ({0})'.format(counter)

        # print("Sending packet: \n{}\n".format(payload))

        display.show_text_wrap(
            "{0}                     {1}                   RSSI: {2}".format(
                ident, payload, lora.packetRssi()), 2)

        # Mensagem a enviar pelo sx127x.py:
        lora.println(payload)

        counter += 1
        sleep(5)
Esempio n. 2
0
    def send(lora):
        counter = 0
        print("LoRa Sender")
        display = Display()

        while True:
            payload = 'Hello ({0})'.format(counter)
            #print("Sending packet: \n{}\n".format(payload))
            display.show_text_wrap("{0} RSSI: {1}".format(payload, lora.packet_rssi()))
            lora.println(payload)

            counter += 1
            sleep(5)
Esempio n. 3
0
def receive(lora):
    print("LoRa Receiver")
    display = Display()
    display.show_text("En attente...", False)
    while True:
        if lora.received_packet():
            lora.blink_led(times=1, on_seconds=0.01, off_seconds=0.01)
            print('something here')
            payload = lora.read_payload()
            display.show_text("reception...", False)
            display.show_text("{0}".format(payload), 0, 14, False)
            display.show_text("RSSI: {}".format(lora.packet_rssi()), 0, 30,
                              False)
            print(payload)
Esempio n. 4
0
    def receive(self, lora):
        print("LoRa Receiver")
        display = Display()

        while True:
            if lora.received_packet():
                lora.blink_led()
                print('something here')
                payload = lora.read_payload()
                print(payload)
Esempio n. 5
0
def receive(lora):
    print("LoRa Receiver")

    display = Display()

    while True:
        ident = "LoRa Receiver"

        lora.receivedPacket()

        lora.blink_led()

        try:
            payload = lora.read_payload()

            display.show_text_wrap("{0}                   {1}                   RSSI: {2}".format(
                ident, payload.decode(), lora.packetRssi()), 2)
            #print("*** Received message ***\n{}".format(payload.decode()))

        except Exception as e:
            print(e)
Esempio n. 6
0
def send(lora):

    counter = 0
    print("LoRa Sender")
    display = Display()

    while True:
        ident = "LoRa Sender"

        payload = 'Hello ({0})'.format(counter)

        # print("Sending packet: \n{}\n".format(payload))

        display.show_text_wrap(
            "{0}                     {1}                   RSSI: {2}".format(
                ident, payload, lora.packetRssi()), 2)

        # Mensagem a enviar pelo sx127x.py:
        lora.println(payload)

        counter += 1
        sleep(5)
Esempio n. 7
0
    'dio_0': 26,
    'reset': 14,
    'led': 2,
}

device_spi = SPI(baudrate=10000000,
                 polarity=0,
                 phase=0,
                 bits=8,
                 firstbit=SPI.MSB,
                 sck=Pin(device_config['sck'], Pin.OUT, Pin.PULL_DOWN),
                 mosi=Pin(device_config['mosi'], Pin.OUT, Pin.PULL_UP),
                 miso=Pin(device_config['miso'], Pin.IN, Pin.PULL_UP))

lora = SX127x(device_spi, pins=device_config)
display = Display()


def receive(lora):
    print("LoRa Receiver")
    display = Display()
    display.show_text("En attente...", False)
    while True:
        if lora.received_packet():
            lora.blink_led(times=1, on_seconds=0.01, off_seconds=0.01)
            print('something here')
            payload = lora.read_payload()
            display.show_text("reception...", False)
            display.show_text("{0}".format(payload), 0, 14, False)
            display.show_text("RSSI: {}".format(lora.packet_rssi()), 0, 30,
                              False)
Esempio n. 8
0
    'reset': 14,
    'led': 2,
}
compt = 0

device_spi = SPI(baudrate=10000000,
                 polarity=0,
                 phase=0,
                 bits=8,
                 firstbit=SPI.MSB,
                 sck=Pin(device_config['sck'], Pin.OUT, Pin.PULL_DOWN),
                 mosi=Pin(device_config['mosi'], Pin.OUT, Pin.PULL_UP),
                 miso=Pin(device_config['miso'], Pin.IN, Pin.PULL_UP))

lora = SX127x(device_spi, pins=device_config)
display = Display()


def synchro_us(temps_cycle):
    global compt, top, somme
    if compt == 0:
        top = ticks_us()
        somme = 0
    tip = ticks_us()
    delta = tip - top
    compt = compt + 1
    attente = temps_cycle * compt - delta
    somme = somme + attente
    #print("delta : {0:5d}; compt : {1:2d}; attente : {2:6d}; somme : {3:7d} ".format(delta, compt, attente, somme, top, tip, attente))
    print(delta)
    sleep_us((attente))
Esempio n. 9
0
                                     'essid': '',
                                     'password': ''
                                 },
                             },
                             'mesh': {
                                 'address': '1',
                                 'channel': '0',
                                 'datarate': '0',
                             },
                         })

gc.threshold(20000)
gc.collect()

from ssd1306_i2c import Display
display = Display()
display.show_text_wrap("Starting...")

_ADDRESS = int(CONFIG_DATA.get("mesh.address", "1"))

from meshdomains import US902_MESHNET as domain
from meshnet import MeshNet, DataPacket, BROADCAST_ADDRESS

meshnet = MeshNet(
    domain,
    enable_crc=True,
    address=_ADDRESS,
    channel=(int(CONFIG_DATA.get("mesh.channel", default='64')),
             int(CONFIG_DATA.get("mesh.datarate", default='-1'))),
)
# meshnet.set_promiscuous(True)