示例#1
0
                            print("invalid type, only DHT11, DHT22 and AM2302 are supported.")
                            sys.exit(3)

                        if pinDHT <= 0 | pinDHT > 40:
                            print("invalid GPIO pin#")
                            sys.exit(3)

                        print("Detect on wiringPi PIN #{0} for DHT sensor".format(pinDHT))
                        
                        DHTreader.init()
                        Addons["DHTreader"] = True

                    if AD and Addons["PCF8591"]:
                        channel = int(AD[0])
                        if channel in [0, 1, 2, 3]:
                            value = IOboard.readPCF8591(channel)
                            inV = 3.3*value/255
                            print("I2C PCF8591: channel {0} input: {1} voltage.".format(channel, inV))
                            sendCmd("sensor-update readPCF8591 %.2f" % (inV))
                        else:
                            print("I2C PCF8591 should read from channel [0 | 1 | 2 | 3]")
                                        
                    if DA and Addons["PCF8591"]:
                        out = int(DA[0])
                        IOboard.writePCF8591(out)
                        outV = 3.3*out/255
                        print("I2C PCF8591: analog output: {0} voltage.".format(outV))
                        sendCmd("sensor-update writePCF8591 %.2f" % (outV))

                    if Sound: 
                        soundPin = int(Sound[0])
示例#2
0
                            print("invalid type, only DHT11, DHT22 and AM2302 are supported.")
                            sys.exit(3)

                        if pinDHT <= 0 | pinDHT > 40:
                            print("invalid GPIO pin#")
                            sys.exit(3)

                        print("Detect on wiringPi PIN #{0} for DHT sensor".format(pinDHT))
                        
                        DHTreader.init()
                        Addons["DHTreader"] = True

                    if AD and Addons["PCF8591"]:
                        channel = int(AD[0])
                        if channel in [0, 1, 2, 3]:
                            value = IOboard.readPCF8591(channel)
                            inV = 3.3*value/255
                            print("I2C PCF8591: channel {0} input: {1} voltage.".format(channel, inV))
                            sendCmd("sensor-update readPCF8591 %.2f" % (inV))
                        else:
                            print("I2C PCF8591 should read from channel [0 | 1 | 2 | 3]")
                                        
                    if DA and Addons["PCF8591"]:
                        out = int(DA[0])
                        IOboard.writePCF8591(out)
                        outV = 3.3*out/255
                        print("I2C PCF8591: analog output: {0} voltage.".format(outV))
                        sendCmd("sensor-update writePCF8591 %.2f" % (outV))

                    if Sound: 
                        soundPin = int(Sound[0])
示例#3
0
import IOboard

if len(sys.argv) != 4:
    print("usage: {0} Address Channel[0|1|2|3] DigitalOut[0~255].".format(sys.argv[0]))
    print("example: {0} I2C Address Read from Channel 0 and write 127 to D/A converter. ".format(sys.argv[0]))
    sys.exit(2)

address = int("0x"+sys.argv[1], 16)
channel = int(sys.argv[2])
out = int(sys.argv[3])

if channel not in [0, 1, 2, 3]:
	print("Channel[0|1|2|3]")
if out not in range(0,256):
	print("DigitalOut[0~255]")

IOboard.init(address)

read = IOboard.readPCF8591(channel)
IOboard.writePCF8591(out)

inV = 3.3*read/255
outV = 3.3*out/255
print("A/D converter reads voltage = {0}".format(inV))
print("D/A converter writes voltage = {0}".format(outV))

data = 255
IOboard.writeAT45Buff(data)
readData = IOboard.readAT45Buff()
print("Read AT45: ", readData)
示例#4
0
    print("usage: {0} Address Channel[0|1|2|3] DigitalOut[0~255].".format(
        sys.argv[0]))
    print(
        "example: {0} I2C Address Read from Channel 0 and write 127 to D/A converter. "
        .format(sys.argv[0]))
    sys.exit(2)

address = int("0x" + sys.argv[1], 16)
channel = int(sys.argv[2])
out = int(sys.argv[3])

if channel not in [0, 1, 2, 3]:
    print("Channel[0|1|2|3]")
if out not in range(0, 256):
    print("DigitalOut[0~255]")

IOboard.init(address)

read = IOboard.readPCF8591(channel)
IOboard.writePCF8591(out)

inV = 3.3 * read / 255
outV = 3.3 * out / 255
print("A/D converter reads voltage = {0}".format(inV))
print("D/A converter writes voltage = {0}".format(outV))

data = 255
IOboard.writeAT45Buff(data)
readData = IOboard.readAT45Buff()
print("Read AT45: ", readData)