コード例 #1
0
def run_receiver():
    """ Setup the Raspberry Pi as receiver, listen for transmitted values,
         display every received number as binary < 256 if the display is attached.
         Prints the received value, bit length and protocol to the terminal. """

    receiver = RCSwitchReceiver()
    receiver.enableReceive(2)

    while True:
        print 'Listening...'
        sleep(0.5)

        if receiver.available():
            received_value = receiver.getReceivedValue()

            if received_value:
                display_number(received_value % 256, True)

                print("Value: %s | Bit: %s | Protocol: %s" %
                      (received_value, receiver.getReceivedBitlength(),
                       receiver.getReceivedProtocol()))

            receiver.resetAvailable()
コード例 #2
0
from pi_switch import RCSwitchReceiver
from Config import Config

#---------------------------------------------------------------------------#
# Configure receiver
#---------------------------------------------------------------------------#
receiver = RCSwitchReceiver()
receiver.enableReceive(Config.RPi_Pin_Receiver)

num = 0

#---------------------------------------------------------------------------#
# Loop and wait for commands
#---------------------------------------------------------------------------#
while True:
    if receiver.available():
        received_value = receiver.getReceivedValue()
        if received_value:
            num += 1
            print("Received[%s]:" % num)
            print(received_value)
            print("%s / %s bit" %
                  (received_value, receiver.getReceivedBitlength()))
            print("Protocol: %s" % receiver.getReceivedProtocol())
            print("")

        receiver.resetAvailable()
コード例 #3
0
#mqttClient.connect("54.187.15.61",1883)
mqttClient.connect("54.67.96.20",1883)

message={}

while True:
    if receiver.available():
        received_value = receiver.getReceivedValue()

        if received_value:
            num += 1
            print("Received[%s]:" % num)
            print(received_value)
            print("%s / %s bit" % (received_value, receiver.getReceivedBitlength()))
            print("Protocol: %s" % receiver.getReceivedProtocol())
            print("")
            lst = [int(i) for i in str(received_value)]
            print(lst[1])
            try:
            	checkSum=lst[0]+lst[1]+lst[2]+lst[3]+lst[4]
            	checkSum=checkSum*lst[4]
            except:
            	print("exception: less than 7 digits")
            print("checksum")
            print(checkSum)
            vb=lst[5:]
            print(vb)
	    vb1=''.join(map(str,vb))
	    print(vb1)
            if checkSum!=int(vb1):
コード例 #4
0
ファイル: rfreceive.py プロジェクト: jsanchezi/rpi
    lista_valores[10].sensor_desc = 'temp10'
    lista_valores[11].sensor_desc = ' hum11'
    lista_valores[12].sensor_desc = ' bat12'
    lista_valores[13].sensor_desc = 'temp13'
    lista_valores[14].sensor_desc = ' hum14'
    lista_valores[15].sensor_desc = 'pres15'
    lista_valores[16].sensor_desc = 'P_Te16'
    lista_valores[17].sensor_desc = 'void'
    lista_valores[18].sensor_desc = 'void'

    print lista_valores[1].sensor_desc

#  inicializamos RCSwitch
    receiver = RCSwitchReceiver()
    receiver.enableReceive(0)
    procesa_valor(14003540)
    imprime_lista()

    while True:
           print dt.now() 
#           procesa_valor(14003540)
           if receiver.available():
               received_value = receiver.getReceivedValue()
               if received_value:
                   print("Value: %s | Bit: %s | Protocol: %s" % (received_value,
                        receiver.getReceivedBitlength(),
                        receiver.getReceivedProtocol()))
		   procesa_valor(received_value)
		   receiver.resetAvailable() 
           sleep(10)
コード例 #5
0
#!/usr/bin/python
# coding=utf-8

from pi_switch import RCSwitchReceiver

receiver = RCSwitchReceiver()
receiver.enableReceive(2)

num = 0

while True:
    if receiver.available():
        received_value = receiver.getReceivedValue()
        if received_value:
            num += 1
            print("Received[{}]: {}".format(num, received_value))
            print("Bit Length: {} bit".format(receiver.getReceivedBitlength()))
            print("Delay: {}".format(receiver.getReceivedDelay()))
            print("Protocol: {}\n".format(receiver.getReceivedProtocol()))
        receiver.resetAvailable()