コード例 #1
0
def check_for_gas():
    status = 1
    count = 0
    print ADC.read(3)
    tmp = GPIO.input(DO);
    if tmp != status:
        Print(tmp)
    else:
        Print(0)
def loop():
	status = 1
	while True:
		print ADC.read(0)
		
		tmp = GPIO.input(DO);
		if tmp != status:
			Print(tmp)
			status = tmp
		
		time.sleep(0.2)
コード例 #3
0
ファイル: run.py プロジェクト: haloteam/halo
def loop():
    worker = Thread(target=queue_task, args=(q,))
    worker.setDaemon(True)
    worker.start()
    alarm_thread = Thread(target=alarm_task)
    alarm_thread.setDaemon(True)
    alarm_thread.start()
    status = 1
    count = 0
    q_count = 0
    now = datetime.now()
    LCD.write(0,0,'System Normal')
    while True:
        # get and convert temperature
        analogTemp = ADC.read(0)
        Vr = 5 * float(analogTemp) / 255
        Rt = 10000 * Vr / (5 - Vr)
        temp = 1/(((math.log(Rt / 10000)) / 3950) + (1 / (273.15 + 25)))
        temp = (temp - 273.15) * 9/5 + 32
        print 'temperature = ', temp, 'F'
        # get and convert gas sensor data
        gas = ADC.read(1)
        print 'gas sensor = ', gas

        # tmp = GPIO.input(GAS_SENSOR)
        # if tmp != status:
        #     check_gas(tmp)
        #     status = tmp
        # if status == 0:
        #     count += 1
        #     if count % 2 == 0:
        #         GPIO.output(BUZZ, 1)
        #     else:
        #         GPIO.output(BUZZ, 0)
        # else:
        #     GPIO.output(BUZZ, 1)
        #     count = 0

        # get water data
        h2o = ADC.read(2)
        print "h2o sensor = " + str(h2o)
        update_LCD(temp, gas, h2o)

        if q_count > 3.5:
            updates = []
            updates.append({'type' : 'temperature', 'value': str(temp), 'timestamp': str(datetime.now())})
            updates.append({'type' : 'gas', 'value': str(ADC.read(1)), 'timestamp': str(datetime.now())})
            updates.append({'type' : 'h2o', 'value': str(h2o), 'timestamp': str(datetime.now())})
            q.put(updates)
            q_count = 0
        q_count = q_count + 1
        time.sleep(2)
コード例 #4
0
ファイル: 19_sound_sensor.py プロジェクト: HandcraftCavon/SSK
def loop():
	count = 0
	while True:
		tmp = ADC.read(0)
		if tmp < 50:
			count += 1
			print "Voice In!!  ", count
コード例 #5
0
ファイル: 18_thermistor.py プロジェクト: haloteam/halo
def loop():
	status = 1
	tmp = 1
	while True:
		analogVal = ADC.read(0)
		Vr = 5 * float(analogVal) / 255
		Rt = 10000 * Vr / (5 - Vr)
		temp = 1/(((math.log(Rt / 10000)) / 3950) + (1 / (273.15+25)))
		temp = temp - 273.15
#		temp = temp * 9/5 + 32
		print 'temperature = ', temp, 'C'

		# For a threshold, uncomment one of the code for
		# which module you use. DONOT UNCOMMENT BOTH!
		#################################################
		# 1. For Analog Temperature module(with DO)
		#tmp = GPIO.input(DO);
		# 
		# 2. For Thermister module(with sig pin)
		if temp > 33:
			tmp = 0;
		elif temp < 31:
			tmp = 1;
		#################################################

		if tmp != status:
			Print(tmp)
			status = tmp

		time.sleep(0.2)
コード例 #6
0
ファイル: RGBbar.py プロジェクト: HandcraftCavon/RGBbar
def loop():
	while True:
		tmp = ADC.read(0)
		if tmp < 44:
			R = 100
			G = map(tmp,0, 43, 0, 100)
			B = 0
		elif tmp < 86:
			R = 100-map(tmp, 44, 85, 0, 100)
			G = 100
			B = 0
		elif tmp < 128:
			R = 0
			G = 100
			B = map(tmp, 86, 127, 0, 100)
		elif tmp < 170:
			R = 0
			G = 100-map(tmp, 128, 169, 0, 100)
			B = 100
		elif tmp < 212:
			R = map(tmp, 170, 211, 0, 100)
			G = 0
			B = 100
		elif tmp < 256:
			R = 100
			G = 0
			B = 100-map(tmp, 212, 255, 0, 100)
		
		setColor(R,G,B)
		print tmp
コード例 #7
0
def read_illumination():
    global CURRENT_ILLUMINATION
    illumination = ADC.read(0)
    if (illumination > CURRENT_ILLUMINATION + TOLERANCE_ILLUMINATION or
            illumination < CURRENT_ILLUMINATION - TOLERANCE_ILLUMINATION):
        CURRENT_ILLUMINATION = illumination
        print_line('CURRENT ILLUMINATION: %0.3f' % CURRENT_ILLUMINATION)
        return True
    return False
コード例 #8
0
def loop():
    count = 0
    while True:
        tmp = ADC.read(0)
        print tmp
        time.sleep (0.4)
        if tmp < 50:
            count += 1
            print "Voice In!!  ", count
コード例 #9
0
ファイル: Halo.py プロジェクト: haloteam/halo
 def get_temperature_sensor_data(self):
     try:
         analogTemp = ADC.read(0)
         Vr = 5 * float(analogTemp) / 255
         Rt = 10000 * Vr / (5 - Vr)
         temp = 1/(((math.log(Rt / 10000)) / 3950) + (1 / (273.15 + 25)))
         self.temp = (temp - 273.15) * 9/5 + 32
         return self.temp
     except:
         print "Temp sensor read failed... analog temp = ", analogTemp
def loop():
	count = 0
	while True:
		voiceValue = ADC.read(0)
		if voiceValue:
			print 'Value:', voiceValue
			if voiceValue < 50:
				print "Voice detected! ", count
				count += 1
			time.sleep(0.2)
コード例 #11
0
def setup(gpioPort, i2cAddress):
        global initialRainIntensityReading
        global lowerBoundary
        GPIO.setmode(GPIO.BCM)
        ADC.setup(i2cAddress)
        GPIO.setup(gpioPort, GPIO.IN)
        initialRainIntensityReading = ADC.read(0)
        # set the delta zone so we dont need to recalc it every time
        lowerBoundary = initialRainIntensityReading - rainDelta
        print "initial rain intensity reading: ", initialRainIntensityReading
コード例 #12
0
def sample():
        currentRainIntensity = ADC.read(0)
        data = {}
        data['rainReading'] = currentRainIntensity
        # if any rain drop is detected
        if (lowerBoundary > currentRainIntensity) :
                data['rainDetected'] = True;
        else:
                data['rainDetected'] = False;

        return data;
def loop():
	status = 1
	count = 0
	while True:
		print ADC.read(0)
		
		tmp = GPIO.input(DO);
		if tmp != status:
			Print(tmp)
			status = tmp
		if status == 0:
			count += 1
			if count % 2 == 0:
				GPIO.output(Buzz, 1)
			else:
				GPIO.output(Buzz, 0)
		else:
			GPIO.output(Buzz, 1)
			count = 0
				
		time.sleep(0.2)
def loop():
	status = 0
	while True:
		res = ADC.read(0)
		print 'Current intensity of magnetic field : ', res
		if res - 133 < 5 and res - 133 > -5:
			tmp = 0
		if res < 128:
			tmp = -1
		if res > 138:
			tmp = 1
		if tmp != status:
			Print(tmp)
			status = tmp
		time.sleep(0.2)
def direction():	#get joystick result
	state = ['home', 'up', 'down', 'left', 'right', 'pressed']
	i = 0

	if ADC.read(0) <= 5:
		i = 1		#up
	if ADC.read(0) >= 250:
		i = 2		#down

	if ADC.read(1) >= 250:
		i = 3		#left
	if ADC.read(1) <= 5:
		i = 4		#right

	if ADC.read(2) == 0:
		i = 5		# Button pressed

	if ADC.read(0) - 125 < 15 and ADC.read(0) - 125 > -15	and ADC.read(1) - 125 < 15 and ADC.read(1) - 125 > -15 and ADC.read(2) == 255:
		i = 0
	
	return state[i]
コード例 #16
0
ファイル: BeeBot1.2.py プロジェクト: BadassHomesteader/BeeBot
def loop():
	while True:
		humidity1, temperature1 = DHT.read_retry(Sensor, humiture1)
		humidity2, temperature2 = DHT.read_retry(Sensor, humiture2)
		sound_level = ADC.read(0)
		
		if humidity1 is not None and temperature1 is not None:
			import time
			ts = time.time()

			import datetime
			st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
			
			print st + ' : T1={0:0.1f}*C  H1={1:0.1f}%'.format(temperature1, humidity1) + ' : T2={0:0.1f}*C  H2={1:0.1f}%'.format(temperature2, humidity2) + ' : S1=' + format(sound_level)
			logging.info(st + ' : T1={0:0.1f}*C  H1={1:0.1f}%'.format(temperature1, humidity1) + ' : T2={0:0.1f}*C  H2={1:0.1f}%'.format(temperature2, humidity2) + ' : S1=' + format(sound_level))
			
			time.sleep(3600) # delays in seconds (1 hours)
			
		else:
			print 'Failed to get reading. Try again!'
コード例 #17
0
def loop():
	while True:
		print ADC.read(0)
		ADC.write(ADC.read(0))
コード例 #18
0
    stateChanged = 0
    sampleCounter = 0
    lastBeatTime = 0
    firstBeat = True
    secondBeat = False
    Pulse = False
    IBI = 600
    rate = [0] * 10
    amp = 100

    lastTime = int(time.time() * 1000)

    # Main loop. use Ctrl-c to stop the code
    while True:
        # read from the ADC
        Signal = int(ADC.read(0)) * 4
        # ADC.write(255)
        curTime = int(time.time() * 1000)

        sampleCounter += curTime - lastTime
        #                   # keep track of the time in mS with this variable
        lastTime = curTime
        N = sampleCounter - lastBeatTime
        #  # monitor the time since the last beat to avoid noise
        #print N, Signal, curTime, sampleCounter, lastBeatTime

        ##  find the peak and trough of the pulse wave
        if Signal < thresh and N > (
                IBI / 5.0
        ) * 3.0:  #       # avoid dichrotic noise by waiting 3/5 of last IBI
            if Signal < T:  # T is the trough
コード例 #19
0
import RPi.GPIO as GPIO
import PCF8591 as pcf
import time
import barometre as b

relay=32
GPIO.setmode(GPIO.BOARD)
GPIO.setup(relay, GPIO.OUT)

pcf.setup(0x48)
sleepTime =1
try:
    while True:
        H, T ,P= pcf.read(1),b.degrees,b.hectopascals
        print("Humidity is: " , H,"%")
        print("temperature is: " , T, "C")
        print("Pressure is: " , P,"hPa")
        time.sleep(sleepTime)
        if(P>1000)and(int(H)>250):#condition d'arrosage
            GPIO.output(relay, GPIO.HIGH)#ouvrir l'électrovanne
            time.sleep(5)#arroser pendant 5 sec
            GPIO.output(relay, GPIO.LOW)#fermer l'électrovanne
        else:
            GPIO.output(relay, GPIO.LOW)
            
except KeyboardInterrupt:
    GPIO.output(relay, GPIO.LOW)
    GPIO.cleanup()
    
コード例 #20
0
ファイル: fullandMoisure.py プロジェクト: SMB11/ds_summer
def photoresistorSetup():
    ADC.setup(0x48)
    GPIO.setup(DO, GPIO.IN)

# start all

file = open("/home/pi/data_log.csv", "a")

photoresistorSetup()
# photoresValue = ADC.read(0)
result = read_dht11_dat()
humidity, temperature = result
# temp = read_temp()

print("Temperature: " + str(read_temp()) + " Light: " + str(ADC.read(0)) +
      " Humidity: " + str(humidity) + "  Temperature 2: " + str(temperature) +
      " Moisure 1 " + str(ADC.read(1)) + " Moisure 2 " + str(ADC.read(2)))

i = 0
if os.stat("/home/pi/data_log.csv").st_size == 0:
    file.write(
        "Time,Temperature 1,Photoresistor Value,Humidity,Temperature 2,Plant1Moisure,Plant2Moisure\n"
    )
while True:
    i = i + 1
    now = datetime.now()
    file.write(
        str(now) + "," + str(read_temp()) + "," + str(ADC.read(0)) + "," +
        str(humidity) + "," + str(temperature) + "," + str(ADC.read(1)) + "," +
        str(ADC.read(2)) + "\n")
コード例 #21
0
ファイル: startup.py プロジェクト: timothy-krock/steve
def LightsOn():
    value = ADC.read(1)
    if value < 200:
        return True
    else:
        return False
コード例 #22
0
def read_light():
    darkLevel = ADC.read(1)
    lightLevel = 255 - darkLevel
    return lightLevel
コード例 #23
0
ファイル: sensor2xively.py プロジェクト: refap3/refAP3repo
lightSensor = 1  # Ananlog In 1
soundSensor = 0  # Ananlog In 0

#setup
ADC.setup(0x48)

while True:
    # Error handling in case of problems communicating with the Sunfounder
    try:
        # Get value from temperature sensor
        [humidity, temp] = DHT.read_retry(Sensor, humiture)
        t = temp
        h = humidity

        # Get value from light sensor
        light_intensity = ADC.read(lightSensor)

        # Get sound level
        sound_level = ADC.read(soundSensor)

        # get seconds part of time
        ts = time.time()
        sec = datetime.datetime.fromtimestamp(ts).strftime('%S')

        dsTEMP.current_value = t
        dsTEMP.at = datetime.datetime.utcnow()

        dsHUM.current_value = h
        dsHUM.at = datetime.datetime.utcnow()

        dsSND.current_value = sound_level
コード例 #24
0
def loop():
    while True:
        print "Current illumination: ", ADC.read(0)
        time.sleep(0.1)
コード例 #25
0
ファイル: Halo.py プロジェクト: haloteam/halo
 def get_gas_sensor_data(self):
     self.gas = ADC.read(1)
     return self.gas
コード例 #26
0
ファイル: Halo.py プロジェクト: haloteam/halo
 def get_h2o_sensor_data(self):
     self.h2o = ADC.read(2)
     return self.h2o
コード例 #27
0
ファイル: 36_solar_cell.py プロジェクト: Chika2020/Galapagos
def voltageMon():
    while (1):
        aVal = ADC.read(1)
        V = 5 * float(aVal) / 255
        print("Voltage:", V)
コード例 #28
0
lightSensor=1   # Ananlog In 1
soundSensor=0   # Ananlog In 0

#setup 
ADC.setup(0x48)

while True:
    # Error handling in case of problems communicating with the Sunfounder
    try:
        # Get value from temperature sensor
        [humidity,temp] = DHT.read_retry(Sensor, humiture)
        t=temp
        h=humidity

        # Get value from light sensor
        light_intensity = ADC.read(lightSensor)

        # Get sound level
        sound_level = ADC.read(soundSensor)

        # get seconds part of time 
        ts = time.time()
        sec = datetime.datetime.fromtimestamp(ts).strftime('%S')

        dsTEMP.current_value = t
        dsTEMP.at = datetime.datetime.utcnow()

        dsHUM.current_value = h
        dsHUM.at = datetime.datetime.utcnow()

        dsSND.current_value = sound_level
コード例 #29
0
ファイル: 13_pcf8591.py プロジェクト: suiliyang/SensorCode_34
def loop():
    while True:
        print ADC.read(0)
        ADC.write(ADC.read(3))
コード例 #30
0
def makerobo_loop():
    makerobo_status = 1  # 状态值
    # 无限循环
    while True:
        print('Photoresistor Value: ', ADC.read(0))  # 读取AIN0的值,获取光敏模拟量值
        time.sleep(0.2)  # 延时200ms
コード例 #31
0
ファイル: run.py プロジェクト: Mikasa1997/resberry_DHT11

# 链接信息
Server,ClientId,userNmae,Password = aliLink.linkiot(DeviceName,ProductKey,DeviceSecret)

# mqtt链接
mqtt = mqttd.MQTT(Server,ClientId,userNmae,Password)
mqtt.subscribe(SET) # 订阅服务器下发消息topic
mqtt.begin(on_message,on_connect)


# 信息获取上报,每10秒钟上报一次系统参数
while True:
    time.sleep(1)
    ADC.setup(0x48)
    status = (ADC.read(0)-170)/25
    #print(status)
    if(status > 2.1):
        GPIO.output(Buzz, GPIO.LOW)
    else:
        GPIO.output(18, GPIO.HIGH)
    #获取指示灯状态
   # power_stats=int(rpi.getLed())
   # if(power_stats==0):
        #power_LED = 0
   # else:
       # power_LED = 1

    result = instance.read()
    if result.is_valid():
        get_temp  = result.temperature-6
def loop():
	status = 1
	while True:
		print 'Value:', ADC.read(0)
		
		time.sleep(0.2)
コード例 #33
0
ファイル: Smirror.py プロジェクト: MostafaAbuelnoor/Smirror
def temp(n):
    n = int(n)
    tempunit = adc.read(n)
    tempvolt = tempunit * 3.3 / 256
    tempc = tempvolt / 0.01
    return (tempc, tempunit)
コード例 #34
0
ファイル: sensor_file.py プロジェクト: Varun901/Cardio-Safe
    def run(self):
        self.mutex.acquire()
        # ADC is setup so that digital values can be read from the Thermistor
        ADC.setup(0x48)
        self.mutex.release()
        # Buzzer is set at GPIO pin 17
        buzz = Buzzer(17)
        # LED is set at GPIO pin 19
        led = LED(19)
        # LED is on to signal that the device is on and working
        led.on()
        while True:
            # A file is created and opened with the name TempOutput.txt
            out_file = open('TempOutput.txt', "a+")
            # A blank list is created called mean_value to hold the mean temperature value
            mean_value = []

            for i in range(20):
                self.mutex.acquire()
                # The Analog Value is read from the ADC
                analogVal = ADC.read(0)
                self.mutex.release()
                # The following calculations convert the analog value to temperature in degrees celsius as seen from Sunfounder
                Vr = 5 * float(analogVal) / 255
                Rt = 10000 * Vr / (5 - Vr)
                temp = 1 / (((math.log(Rt / 10000)) / 3950) + (1 / (273.15 + 25)))
                temp = temp - 273.15
                # The temp value is added on to the mean_value list
                mean_value.append(temp)
                # The following commands allow for a rolling list to ensure that a consistent average is always calculated
                if len(mean_value) > 20:
                    mean_value.remove(mean_value[0])
                sleep(0.1)
            # The average_temp variable calculates the average temperature as per the mean_value list
            average_temp = sum(mean_value)/len(mean_value)
            # The average temperature is published to the Team 28 Temp Value Topic on the MQTT Server
            self.client.publish("Team28/TempValue", average_temp)
            # The average temperature is also written to the outfile
            out_file.write(str(average_temp) + "\n")
            # Queue prevents delay in running the threads
            self.q.put_nowait(average_temp)
            # The following are if statements to classify whether or not a certain reading induces a warning
            if 36.1 <= average_temp <= 38:
                # This makes sure the buzz is off when the temperature is in the optimal range
                buzz.off()
                # A blank string is published to the Team 28 Temp Warning Topic on the MQTT Server
                self.client.publish("Team28/TempWarning", (""))
                time.sleep(10)
            elif average_temp > 38:
                # The following commands are to determine whether a warning is already in place and if so to continue the buzzer
                if buzz.is_active == False:
                    buzz.on()
                # A High Temp Warning is published to the Team 28 Temp Warning Topic on the MQTT Server
                self.client.publish("Team28/TempWarning", ("High Temperature! Risk of fever! " + "\n" + str(datetime.now())))
                # A warning will be sent to the phone number below via Twilio
                message = twilio_client.messages \
                    .create(
                        body='High Temperature WARNING',
                        from_='+15878020288',
                        to=phone_number
                    )
                print(message.sid)
                # insert name of function that reads data from sensor
            else:
                # The following commands are to determine whether a warning is already in place and if so to continue the buzzer
                if buzz.is_active == False:
                    buzz.on()
                # A Low Temp Warning is published to the Team 28 Temp Warning Topic on the MQTT Server
                self.client.publish("Team28/TempWarning", ("Low Temperature! Risk of fever! " + "\n" + str(datetime.now())))
                # A warning will be sent to the phone number below via Twilio
                message = twilio_client.messages \
                    .create(
                        body='Low Temperature WARNING',
                        from_='+15878020288',
                        to=phone_number
                    )
                print(message.sid)
                # The next line closes the outfile
            out_file.close()
            # The following lines open the TempOutput file and publishes it to the MQTT Server via the Team 28 TempOutFile Topic
            with open("TempOutput.txt", "r") as temp_file:
                self.client.publish("Team28/TempOutFile", temp_file.read())
コード例 #35
0
ファイル: startup.py プロジェクト: timothy-krock/steve
    ###############
    # BLUE DISPLAY
    ###############
    if time_sound_last_heard > i - 15:
        LCD1602.write(0, 0, 'Voice Heard')
        LCD1602.write(1, 1, 'Hello!')
    else:
        LCD1602.clear()
    #################
    # .01 Second Loop
    #################
    for j in range(10):
        ###############
        # SOUND SENSOR
        ###############
        soundVal = ADC.read(0)
        if soundVal < 100:
            time_sound_last_heard = i
        #time.sleep(.01)
        if not SERVER:
            #ip  = '10.200.17.88'
            ip = '127.0.0.1'
            TCP_IP = ip
            TCP_PORT = 5007
            BUFFER_SIZE = 2048

            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
            s.bind((TCP_IP, TCP_PORT))
            s.setblocking(0)
            global SERVER
コード例 #36
0
def loop():
    while True:
        print "Current illumination: ", ADC.read(1)
        time.sleep(0.1)
コード例 #37
0
ファイル: mainComp.py プロジェクト: SheungLu/NGCIoTHackathon
def loop():
	global Rt
	
	#start moving
	GPIO.output(BKD_PIN, False)
	#pFWD.start(50)
	#pRGT.start(0)
	
	loops =0
	sendLoops =0
	while True:
		#get sensor data
		dis = distance()
		if (dis > 120):
			dis = 120
			
		d_gas = ADC.read(2)
		d_flame = ADC.read(1)
		d_temp = ADC.read(3)
		Vr = 5 * float(d_temp) / 255
		try:
			Rt = 10000 * Vr / (5 - Vr)
		except ZeroDivisionError:
			print('temp is 255')
			
		temp = 1/(((math.log(Rt / 10000)) / 3950) + (1 / (273.15+25)))
		temp = temp - 273.15
		
		#print locally
		dstring = '{0:.2f}'.format(dis) + ' cm, Gas:' + '{}'.format(d_gas)
		print dstring
		#LCD1602.write(1, 1, dstring)
		#LCD1602.write(1, 1, 'Flame:' + '{}'.format(d_flame))
		if (dis > 30):
			setColor(0x00FF00)
		elif (dis > 20):
			setColor(0x00FFFF)
		else:
			setColor(0xFF0000)
		
		#publish
		if (sendLoops % 10==0):
			myAWSIoTMQTTClient.publish("sensor_data/temperature/", str(temp), 1)
			myAWSIoTMQTTClient.publish("sensor_data/sonar/", str(dis), 1)
			myAWSIoTMQTTClient.publish("sensor_data/gas/", str(d_gas), 1)
			myAWSIoTMQTTClient.publish("sensor_data/flame/", str(255-d_flame), 1)
			
		
		#turn right
		if(dis > 20): #if no obstacle, drive
			
			GPIO.output(FWD_PIN, True)
			GPIO.output(RGT_PIN, False)
			#if (loops ==20): #every 2 seconds turn
			#	GPIO.output(RGT_PIN, True)
			#if (loops == 30): #stop turning after .5 sec
			#	GPIO.output(RGT_PIN, False)
			#	loops = 0
			loops = loops+1
		else: #if obstacle, stop and take image
			GPIO.output(FWD_PIN, False)
			img = cam.get_image()
			pygame.image.save(img,"webcam.jpg")
			s3.upload_file(filename, bucket_name, key)

		
		
		sendLoops = sendLoops +1
		print("loop: "+str(loops))
		time.sleep(0.1)
コード例 #38
0
def loop():
    while True:
        print time.strftime('%Y-%m-%d %H:%M:%S'), ',', ADC.read(0)
        sys.stdout.flush()
        time.sleep(30)
コード例 #39
0
def loop():
    status = 1
    while True:
        print 'Value: ', ADC.read(2)

        time.sleep(0.2)
コード例 #40
0
def photoresistorSetup():
    ADC.setup(0x48)
    GPIO.setup(DO, GPIO.IN)

# start all

file = open("/home/pi/data_logSt.csv", "a")

photoresistorSetup()
# photoresValue = ADC.read(0)
resultSt = read_dht11_dat()
humiditySt, temperatureSt = resultSt
# temp = read_temp()

print("Temperature: " + str(read_temp()) + " Light: " + str(ADC.read(0)) +
      " Humidity: " + str(humiditySt) + "  Temperature 2: " +
      str(temperatureSt) + " Moisure 1 " + str(ADC.read(1)) + " Moisure 2 " +
      str(ADC.read(2)))

i = 0
if os.stat("/home/pi/data_logSt.csv").st_size == 0:
    file.write(
        "Time,Temperature 1,Photoresistor Value,Humidity,Temperature 2,Plant1Moisure,Plant2Moisure,Environment,Plant1Size,Plant2Size\n"
    )
while True:
    i = i + 1
    now = datetime.now()
    result = read_dht11_dat()

    if result:
コード例 #41
0
ファイル: rain_detection.py プロジェクト: glasgow2016/team-8
	def getRawRainValue(self):
		return ADC.read(0)