Skip to content

Commit

Permalink
test code
Browse files Browse the repository at this point in the history
  • Loading branch information
Sudhir committed Jun 25, 2015
0 parents commit 994d61b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions InstallAzureadk4python.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://azure.microsoft.com/en-in/documentation/articles/python-how-to-install/
25 changes: 25 additions & 0 deletions TempData2EH.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# GrovePi + Grove Temperature Sensor
import time
import grovepi
from azure.servicebus import ServiceBusService

key_name ='RootManageSharedAccessKey' # SharedAccessKeyName from Azure Portal
key_value='s2mHOGi2IoHNhHG9m2v9TDSa+atCtJtgVZb0oQi0RpI=' # SharedAccessKey from Azure Portal
sbs = ServiceBusService('asatestsn', shared_access_key_name=key_name, shared_access_key_value=key_value)
sbs.create_event_hub('hubcreationfromlinux')

# Connect the Grove Temperature Sensor to analog port D4
sensor_port = 4
deviceId = "device-1"
#Declare direction to the pin.
#grovepi.pinMode (Temp_sensor,"INPUT")
while True:
try:
[temp,hum] = grovepi.dht(sensor_port,0)
CurrentTime = str(time.localtime(time.time()).tm_hour) + ":" + str(time.localtime(time.time()).tm_min) + ":"+ str(time.localtime(time.time()).tm_sec)
print "Temperature : ", temp , "Humidity : ", hum, "RecordTime : ", CurrentTime
sbs.send_event('hubcreationfromlinux', '{ "DeviceId":"' + deviceId + '", "Temperature":"' + str(temp) +'", "Humidity":"' + str(hum) +'", "RecordTime":"' + str(CurrentTime) +'"}')
# sbs.send_event('hubcreationfromlinux', '{ "DeviceId":"' + deviceId + '", "Temperature":"' + temperature +'"}')
time.sleep(1.0)
except IOError:
print "Error"
14 changes: 14 additions & 0 deletions TemperatureSensor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# GrovePi + Grove Temperature Sensor
import time
import grovepi
# Connect the Grove Temperature Sensor to analog port A0
Temp_sensor = 0
#Declare direction to the pin.
grovepi.pinMode (Temp_sensor,"INPUT")
while True:
try:
sensor_value = grovepi.analogRead(Temp_sensor)
print "sensor_value =", sensor_value
time.sleep(.5)
except IOError:
print "Error"

0 comments on commit 994d61b

Please sign in to comment.