sens=digitalOp[s_no]
				l=len(sens)
				port=int(msg[l:l+1])
				state=msg[l+1:]
				jetduino.pinMode(port,"OUTPUT")
				if state=='on':
					jetduino.digitalWrite(port,1)
				else:
					jetduino.digitalWrite(port,0)
			if en_debug:
				print msg
		
		elif msg[:4].lower()=="temp".lower():
			if en_jetduino:
				port=int(msg[4:])
				[temp,humidity] = jetduino.dht(port,0)
				s.sensorupdate({'temp':temp})
			if en_debug:
				print msg
				print "temp: ",temp
		
		elif msg[:8].lower()=="humidity".lower():
			if en_jetduino:
				port=int(msg[8:])
				[temp,humidity] = jetduino.dht(port,0)
				s.sensorupdate({'humidity':humidity})
			if en_debug:
				print msg
				print "humidity:",humidity
		
		elif msg[:8].lower()=="distance".lower():
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
'''
import jetduino
from jetduino_pins import *

# Connect the Grove Temperature & Humidity Sensor Pro to digital port D4
# SIG,NC,VCC,GND
sensor = ARD_D4

while True:
    try:
        [temp,humidity] = jetduino.dht(sensor,1)
        print ("temp =", temp, " humidity =", humidity)

    except IOError:
        print ("Error")
Beispiel #3
0
temperature_sensor = ARD_D4  # port D4
led = ARD_D3                 # port D3

# Connect to Twitter
api = twitter.Api(consumer_key='YourKey',consumer_secret='YourKey',access_token_key='YourKey',access_token_secret='YourKey')
print "Twitter Connected"

jetduino.pinMode(led,"OUTPUT")

last_sound = 0

while True:
    # Error handling in case of problems communicating with the GrovePi
    try:
        # Get value from temperature sensor
        [temp,humidity] = jetduino.dht(temperature_sensor,0)
        t=temp

        # Get value from light sensor
        light_intensity = jetduino.analogRead(light_sensor)

        # Give PWM output to LED
        jetduino.analogWrite(led,light_intensity/4)

        # Get sound level
        sound_level = jetduino.analogRead(sound_sensor)
        if sound_level > 0:
            last_sound = sound_level

        # Post a tweet
        print ("DI Lab's Temp: %.2f, Light: %d, Sound: %d" %(t,light_intensity/10,last_sound))
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
'''

import time
import jetduino
import atexit

atexit.register(jetduino.dust_sensor_dis)

jetduino.dust_sensor_en()

while True:
    try:
		[new_val,lowpulseoccupancy] = jetduino.dustSensorRead()
		[temp,humidity] = jetduino.dht(4,1)
		a0 = jetduino.analogRead(0)
		a1 = jetduino.analogRead(1)
		a2 = jetduino.analogRead(2)
		print new_val,lowpulseoccupancy,"temp =", temp, " humidity =", humidity,"a0",a0,"a1",a1,"a2",a2

    except:
        print ("Error")