Ejemplo n.º 1
0
#!/usr/bin/python

import sys, os
import requests

# Add path to pyRadioHeadiRF95 module
sys.path.append(
    os.path.dirname(__file__) + "/home/pi/Desktop/pyRadioHeadRF95/")

import pyRadioHeadRF95 as radio
import time

rf95 = radio.RF95()

rf95.init()

rf95.setFrequency(915)
rf95.setTxPower(13, True)
rf95.setSpreadingFactor(7)
rf95.setSignalBandwidth(31200)

#rf95.setSignalBandwidth(rf95.Bandwidth500KHZ)
#rf95.setSpreadingFactor(rf95.SpreadingFactor12)
#rf95.setCodingRate4(rf95.CodingRate4_8)

print "StartUp Done!"
print "Receiving..."

while True:
    if rf95.available():
        print "Available"
Ejemplo n.º 2
0
def setupTechnologies(techList):

    global xbee
    global nrf24
    global rf95
    global s, wifi_connection
    global bt_sock, bt_connection, UUID
    global rx433, tx433

    # To lower case
    techList = map(str.lower, techList)

    if len(techList) == 0 or ZIGBEE.lower() in techList:
        print "* Using ZigBee"
        ser = serial.Serial(XBEE_PORT, BAUD_RATE)
        xbee = ZigBee(ser, escaped=True)
        activeTech[ZIGBEE] = True
    else:
        activeTech[ZIGBEE] = False

    if len(techList) == 0 or NRF24.lower() in techList:
        print "* Using nRF24"
        nrf24 = radio.nRF24()
        nrf24.managerInit(1)  #     1 is my address
        activeTech[NRF24] = True
    else:
        activeTech[NRF24] = False

    if len(techList) == 0 or LoRa.lower() in techList:
        print "* Using LoRa - RF95"
        rf95 = loradio.RF95()
        rf95.init()
        rf95.managerInit(1)

        rf95.setFrequency(868)
        rf95.setTxPower(14, False)
        rf95.setSignalBandwidth(rf95.Bandwidth500KHZ)
        rf95.setSpreadingFactor(rf95.SpreadingFactor7)
        activeTech[LoRa] = True
    else:
        activeTech[LoRa] = False

    if len(techList) == 0 or WIFI.lower() in techList:
        print "* Using WiFi"
        s.bind(('', SOCK_PORT))
        s.listen(3)
        activeTech[WIFI] = True
    else:
        activeTech[WIFI] = False

    if len(techList) == 0 or BLUETOOTH.lower() in techList:
        print "* Using Bluetooth"
        bt_sock.bind(('', BT_PORT))
        bt_sock.listen(3)

        bluetooth.advertise_service(bt_sock, "ExServerService", UUID)
        #print "** Start advertising service"
        activeTech[BLUETOOTH] = True
    else:
        activeTech[BLUETOOTH] = False

    if len(techList) == 0 or RF433.lower() in techList:
        print "* Using RF433"
        pi = pigpio.pi()
        rx433 = piVirtualWire.rx(pi, 2, 500)
        tx433 = piVirtualWire.tx(pi, 3, 500)
        activeTech[RF433] = True
    else:
        activeTech[RF433] = False