示例#1
0
from network import LoRa
import socket
import pycom
import time

# initialize LoRa in LORA mode
# more params can also be given, like frequency, tx power and spreading factor
lora = LoRa(mode=LoRa.LORA, frequency=915000000)

# create a raw LoRa socket
s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
pycom.heartbeat(False)
pycom.rgbled(0x7f0000)  # red
s.setblocking(False)

while True:
    #Allow For Data to be recieved
    #Set LED Blue while Recieving
    pycom.rgbled(0x0000CC)
    data = s.recv(64)
    #Get Signal strength in units of dB closer to 0 is strongest
    signal_strength = lora.rssi()
    print(signal_strength)

    if data == b'Start':
        pycom.rgbled(0x00FF00)  # green
        send = s.send('Lets Go')
        time.sleep(5)
示例#2
0
        print("Send data...")
        #data = "%s %s %s" % (weather.temperature,weather.humidity,weather.pressure)
        t = weather.read_temperature()
        p = weather.read_pressure()
        h = weather.read_humidity()
        data = "{\"temp\":%.2f, \"humi\":%.2f, \"pres\":%.2f}" % (
            t / 100, h / 1024, p / 25600)
        # send some data
        try:
            s.send(data)
        except OSError as e:
            # Check for EAGAIN
            if e.args[0] == 11:
                print("EAGAIN error, retrying")
                current -= 10
                continue

        pycom.rgbled(0x00ff00)
        sleep(0.1)
        pycom.rgbled(0x000000)
        sleep(0.1)
        pycom.rgbled(0x00ff00)
        sleep(0.1)

        pycom.rgbled(0x000000)
        print("Sending data done (RSSI: %s)..." % lora.rssi())
        # get any data received...
        data = s.recv(64)
        print("Received Data (RSSI: %s): %s" % (lora.rssi(), data))
        current -= every
示例#3
0
lora = LoRa(mode=LoRa.LORA, frequency=915000000)
# create a raw LoRa socket
s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
pycom.heartbeat(False)
pycom.rgbled(0x7f0000)  # red
s.setblocking(False)
while True:
    #LED Will Be Orange while Transimitting Info
    pycom.rgbled(0xFF8000)
    # send some data
    s.send('Start')
    print('Start')

    #Recieve Data
    data = s.recv(64)
    print(data)

    #Reporting the Signal Strength of the last signal recieved
    signal_strength = [lora.rssi()]
    for item in signal_strength:
        csv.writerow()

    print(signal_strength)

    #Set condition for program to continue
    if data == b'Lets Go':
        pycom.rgbled(0x007f00)  # green
        print('Lets Go!')
        time.sleep(5)
    time.sleep(5)