Exemplo n.º 1
0
        return safefn


grovepi.read_i2c_block = protect(grovepi.read_i2c_block)
grovepi.write_i2c_block = protect(grovepi.write_i2c_block)

#patch grove_rgb_lcd
for x in dir(grove_rgb_lcd.bus):
    if '12c' in x or 'read' in x or 'write' in x:
        print('patching->', x)
        fn = grove_rgb_lcd.bus.__getattribute__(x)
        grove_rgb_lcd.bus.__setattr__(x, protect(fn))
"""This if-statement checks if you are running this python file directly. That 
is, if you run `python3 grovepi_sensors.py` in terminal, this if-statement will 
be true"""
t = grove_i2c_temp_hum_mini.th02()
t.getTemperature = protect(t.getTemperature)
t.getHumidity = protect(t.getHumidity)

if __name__ == '__main__':
    PORT = 4  # D4
    PORTR = 0
    PORTW = 1
    ldis = -1
    lsen = -1
    while True:
        #So we do not poll the sensors too quickly which may introduce noise,
        #sleep for a reasonable time of 200ms between each iteration.
        time.sleep(0.8)
        #try:
        temp = t.getTemperature()
Exemplo n.º 2
0
import math

# Import grovepi
import grovepi

# Import library for the light sensor
import light_library

# Import temperature humidity sensor library
import grove_i2c_temp_hum_mini

import sparksrabbit
import influx

# Create the object for humidity and light
temperature_sensor = grove_i2c_temp_hum_mini.th02()
light_sensor = light_library.light()

# digital inputs for PowerOff/On the temperature&humidty sensor
TH02_power = 4
grovepi.pinMode(TH02_power, "OUTPUT")

# values for loudness sensor
ref_SPL = 94
sensitivity = 3.16
loudness_sensor = 0


def main():
    # Power off the temperature & humidity sensor
    grovepi.digitalWrite(TH02_power, 1)
Exemplo n.º 3
0
Copyright (C) 2017  Dexter Industries

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
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.
'''
#################################################################################################################################################
# NOTE:
# The software for this sensor is still in development and might make your GrovePi unuable as long as this sensor is connected with the GrovePi
#################################################################################################################################################
import grove_i2c_temp_hum_mini
import time

t= grove_i2c_temp_hum_mini.th02()
while True:
	print("Temp: %.2fC\tHumidity:%.2f" %(t.getTemperature(),t.getHumidity()),"%") 
	time.sleep(.5)
Exemplo n.º 4
0
import time
import grove_i2c_temp_hum_mini
import grove_i2c_adc

#Ambience Sensors
alive = 1
ht_sensor = grove_i2c_temp_hum_mini.th02()
ambience_sensor_enabled = 0
ambience_temp = 25
ambience_humidity = 80

#Tempepature Sensors Peltier, heater block
# You can initialize with a different address too: grove_i2c_adc.ADC(address=0x56)
adc1 = grove_i2c_adc.ADC1()
adc2 = grove_i2c_adc.ADC2()
adc3 = grove_i2c_adc.ADC3()
adc1_sensor_enabled = 0  #AC
adc1_temp_cur = 20
adc1_temp_old = 20
adc2_sensor_enabled = 0  #Cold block
adc2_temp_cur = 20
adc2_temp_old = 20
adc3_sensor_enabled = 0  #hot end
adc3_temp_cur = 20
adc3_temp_old = 20

#SemiTec 104GT2 Lookuptable
temperaturetable = [[-50, 8], [-40, 16], [-30, 32], [-20, 60], [-10, 107],
                    [0, 183], [10, 299], [20, 465], [30, 687], [40, 962],
                    [50, 1276], [60, 1606], [70, 1926], [80, 2216], [90, 2466],
                    [100, 2671], [110, 2835], [120, 2963], [130, 3062],
Exemplo n.º 5
0
import time
import grove_i2c_temp_hum_mini
import grove_i2c_adc

#Ambience Sensors
alive = 1
ht_sensor = grove_i2c_temp_hum_mini.th02()
ambience_sensor_enabled = 0
ambience_temp = 25
ambience_humidity = 80

#Tempepature Sensors Peltier, heater block
# You can initialize with a different address too: grove_i2c_adc.ADC(address=0x56)
adc1 = grove_i2c_adc.ADC1()
adc2 = grove_i2c_adc.ADC2()
adc3 = grove_i2c_adc.ADC3()
adc1_sensor_enabled = 0 #AC
adc1_temp_cur = 20
adc1_temp_old = 20
adc2_sensor_enabled = 0 #Cold block
adc2_temp_cur = 20
adc2_temp_old = 20
adc3_sensor_enabled = 0 #hot end
adc3_temp_cur = 20
adc3_temp_old = 20

#SemiTec 104GT2 Lookuptable
temperaturetable = [[-50,8],[-40,16],[-30,32],[-20,60],[-10,107],[0,183],[10,299],[20,465],[30,687],[40,962],[50,1276],[60,1606],[70,1926],[80,2216],[90,2466],[100,2671],[110,2835],[120,2963],[130,3062],[140,3138],[150,3196],[160,3241],[170,3276],[180,3302],[190,3323],[200,3340],[210,3353],[220,3363],[230,3372],[240,3378],[250,3384],[260,3388],[270,3392],[280,3395],[290,3398],[300,3400]]

def read_sensors(threadName):
	print("Starting " + threadName)