Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor fixes. #3

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 02_digital_sensor/myDHT.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def getHum(DHT_PIN):
return 'FAILED '

def getHumString(DHT_PIN):
return 'Humidity = ' + str(humidity) + '%'

return 'Humidity = ' + str(getHum(DHT_PIN)) + '%'
def getTemp(DHT_PIN):
temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)[1]
temperature = temperature * 9/5.0 + 32 ## Convert temp to Fahrenheit
Expand Down
2 changes: 1 addition & 1 deletion 03_analog_sensor/myDHT.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def getHum(DHT_PIN):
return 'FAILED '

def getHumString(DHT_PIN):
return 'Humidity = ' + str(humidity) + '%'
return 'Humidity = ' + str(getHum(DHT_PIN)) + '%'

def getTemp(DHT_PIN):
temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)[1]
Expand Down
2 changes: 1 addition & 1 deletion 03_analog_sensor/myMCP.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
mcp = Adafruit_MCP3008.MCP3008(spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE))

def getLux(LUX_MCP):
return mcp.read_adc(LUX_ADC, gain=1)
return mcp.read_adc(LUX_MCP)

def getLuxString(LUX_MCP):
return 'Light = ' + str(getLux(LUX_MCP))
2 changes: 1 addition & 1 deletion 04_button/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
LED_PIN = 17 ## GPIO pin the LED is attached to
DHT_PIN = 21 ## GPIO pin the DHT sensor is attached to
LUX_MCP = 0 ## ADC pin the Photoresistor is attached to
BTN_PIN = 27 ## GPIO pin the button is attached to
BTN_PIN = 04 ## GPIO pin the button is attached to

## Exercise 04 - triggered by a button press
GPIO.setup(BTN_PIN,GPIO.IN,pull_up_down=GPIO.PUD_UP) ## Setup GPIO pin as an input
Expand Down
2 changes: 1 addition & 1 deletion 04_button/myDHT.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def getHum(DHT_PIN):
return 'FAILED '

def getHumString(DHT_PIN):
return 'Humidity = ' + str(humidity) + '%'
return 'Humidity = ' + str(getHum(DHT_PIN)) + '%'

def getTemp(DHT_PIN):
temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)[1]
Expand Down
4 changes: 2 additions & 2 deletions 04_button/myMCP.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
mcp = Adafruit_MCP3008.MCP3008(spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE))

def getLux(LUX_MCP):
return mcp.read_adc(LUX_ADC, gain=1)

return mcp.read_adc(LUX_MCP)
def getLuxString(LUX_MCP):
return 'Light = ' + str(getLux(LUX_MCP))
4 changes: 2 additions & 2 deletions 05_cloud/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
LED_PIN = 17 ## GPIO pin the LED is attached to
DHT_PIN = 21 ## GPIO pin the DHT sensor is attached to
LUX_MCP = 0 ## ADC pin the Photoresistor is attached to
BTN_PIN = 27 ## GPIO pin the button is attached to
BTN_PIN = 04 ## GPIO pin the button is attached to

## Exercise 04 - triggered by a button press
GPIO.setup(BTN_PIN,GPIO.IN,pull_up_down=GPIO.PUD_UP) ## Setup GPIO pin as an input
Expand All @@ -27,7 +27,7 @@
## Exercise 05 - send data to Hologram's cloud through WiFi
lightOn(LED_PIN)

message = json.dumps({'h': getHum(DHT_PIN), 't': getTemp(DHT_PIN), 'l': getLux(LUX_MCP)})
message = json.dumps({'h': getHum(DHT_PIN), 't': getTemp(DHT_PIN), 'l': getLuxString(LUX_MCP)})
sent = hologram.sendMessage(message)

lightOff(LED_PIN)
Expand Down
4 changes: 2 additions & 2 deletions 05_cloud/myDHT.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def getHum(DHT_PIN):
return 'FAILED '

def getHumString(DHT_PIN):
return 'Humidity = ' + str(humidity) + '%'

return 'Humidity = ' + str(getHum(DHT_PIN)) + '%'
def getTemp(DHT_PIN):
temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)[1]
temperature = temperature * 9/5.0 + 32 ## Convert temp to Fahrenheit
Expand Down
2 changes: 1 addition & 1 deletion 05_cloud/myMCP.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
mcp = Adafruit_MCP3008.MCP3008(spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE))

def getLux(LUX_MCP):
return mcp.read_adc(LUX_ADC, gain=1)
return mcp.read_adc(LUX_MCP)

def getLuxString(LUX_MCP):
return 'Light = ' + str(getLux(LUX_MCP))
6 changes: 3 additions & 3 deletions 06_cellular/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import RPi.GPIO as GPIO ## Import GPIO library
from myLED import lightOn, lightOff ## Import blink function
from myDHT import getTemp, getHum ## Import temperature and humidity functions
from myMCP import getLux ## Import photoresistor function
from myMCP import getLuxString ## Import photoresistor function
from Hologram.HologramCloud import HologramCloud ## Import Hologram cloud library
import json ## Import library to create and read JSON

Expand All @@ -10,7 +10,7 @@
LED_PIN = 17 ## GPIO pin the LED is attached to
DHT_PIN = 21 ## GPIO pin the DHT sensor is attached to
LUX_MCP = 0 ## ADC pin the Photoresistor is attached to
BTN_PIN = 27 ## GPIO pin the button is attached to
BTN_PIN = 04 ## GPIO pin the button is attached to

## Exercise 04 - triggered by a button press
GPIO.setup(BTN_PIN,GPIO.IN,pull_up_down=GPIO.PUD_UP) ## Setup GPIO pin as an input
Expand All @@ -31,7 +31,7 @@
## Exercise 05 - send data to Hologram's cloud through WiFi
lightOn(LED_PIN)

message = json.dumps({'h': getHum(DHT_PIN), 't': getTemp(DHT_PIN), 'l': getLux(LUX_MCP)})
message = json.dumps({'h': getHum(DHT_PIN), 't': getTemp(DHT_PIN), 'l': getLuxString(LUX_MCP)})
sent = hologram.sendMessage(message)

lightOff(LED_PIN)
Expand Down
4 changes: 2 additions & 2 deletions 06_cellular/myDHT.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def getHum(DHT_PIN):
return 'FAILED '

def getHumString(DHT_PIN):
return 'Humidity = ' + str(humidity) + '%'

return 'Humidity = ' + str(getHum(DHT_PIN)) + '%'
def getTemp(DHT_PIN):
temperature = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_PIN)[1]
temperature = temperature * 9/5.0 + 32 ## Convert temp to Fahrenheit
Expand Down
2 changes: 1 addition & 1 deletion 06_cellular/myMCP.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
mcp = Adafruit_MCP3008.MCP3008(spi=SPI.SpiDev(SPI_PORT, SPI_DEVICE))

def getLux(LUX_MCP):
return mcp.read_adc(LUX_ADC, gain=1)
return mcp.read_adc(LUX_MCP)

def getLuxString(LUX_MCP):
return 'Light = ' + str(getLux(LUX_MCP))