예제 #1
0
 def read(self):
     try:
         sensor = TMP006.TMP006(address=self.i2c_address,
                                busnum=self.i2c_bus)
         sensor.begin()
         self._temperature_object = sensor.readObjTempC()
         self._temperature_die = sensor.readDieTempC()
     except:
         return 1
예제 #2
0
파일: tmp006.py 프로젝트: rpcjacobs/Mycodo
    def __init__(self, address, bus, testing=False):
        super(TMP006Sensor, self).__init__()
        self._temperature_die = None
        self._temperature_object = None
        self.i2c_address = address
        self.i2c_bus = bus

        if not testing:
            from Adafruit_TMP import TMP006
            self.sensor = TMP006.TMP006(address=self.i2c_address,
                                        busnum=self.i2c_bus)
예제 #3
0
    def __init__(self, input_dev,  testing=False):
        super(InputModule, self).__init__(input_dev, testing=testing, name=__name__)
        self._temperature_die = None
        self._temperature_object = None

        if not testing:
            from Adafruit_TMP import TMP006

            self.i2c_address = int(str(input_dev.i2c_location), 16)
            self.i2c_bus = input_dev.i2c_bus
            self.sensor = TMP006.TMP006(
                address=self.i2c_address,
                busnum=self.i2c_bus)
예제 #4
0
    def __init__(self, input_dev, testing=False):
        super(TMP006Sensor, self).__init__()
        self.logger = logging.getLogger("mycodo.inputs.tmp006")
        self._temperature_die = None
        self._temperature_object = None

        if not testing:
            from Adafruit_TMP import TMP006
            self.logger = logging.getLogger(
                "mycodo.inputs.tmp006_{id}".format(id=input_dev.id))
            self.i2c_address = int(str(input_dev.location), 16)
            self.i2c_bus = input_dev.i2c_bus
            self.convert_to_unit = input_dev.convert_to_unit
            self.sensor = TMP006.TMP006(address=self.i2c_address,
                                        busnum=self.i2c_bus)
예제 #5
0
파일: tmp006.py 프로젝트: Routout/Mycodo
    def __init__(self, input_dev,  testing=False):
        super(InputModule, self).__init__()
        self.setup_logger(testing=testing, name=__name__, input_dev=input_dev)
        self._temperature_die = None
        self._temperature_object = None

        if not testing:
            from Adafruit_TMP import TMP006

            self.device_measurements = db_retrieve_table_daemon(
                DeviceMeasurements).filter(
                    DeviceMeasurements.device_id == input_dev.unique_id)

            self.i2c_address = int(str(input_dev.i2c_location), 16)
            self.i2c_bus = input_dev.i2c_bus
            self.sensor = TMP006.TMP006(
                address=self.i2c_address,
                busnum=self.i2c_bus)
예제 #6
0
    def __init__(self, input_dev,  testing=False):
        super(InputModule, self).__init__()
        self.logger = logging.getLogger("mycodo.inputs.tmp006")
        self._temperature_die = None
        self._temperature_object = None

        if not testing:
            from Adafruit_TMP import TMP006
            self.logger = logging.getLogger(
                "mycodo.tmp006_{id}".format(id=input_dev.unique_id.split('-')[0]))

            self.device_measurements = db_retrieve_table_daemon(
                DeviceMeasurements).filter(
                    DeviceMeasurements.device_id == input_dev.unique_id)

            self.i2c_address = int(str(input_dev.i2c_location), 16)
            self.i2c_bus = input_dev.i2c_bus
            self.sensor = TMP006.TMP006(
                address=self.i2c_address, busnum=self.i2c_bus)
예제 #7
0
파일: tmp006.py 프로젝트: zwmyint/Mycodo
    def initialize_input(self):
        from Adafruit_TMP import TMP006

        self.sensor = TMP006.TMP006(address=int(
            str(self.input_dev.i2c_location), 16),
                                    busnum=self.input_dev.i2c_bus)
def camera_capture():
    sensor = TMP006.TMP006()
    sensor.begin()

    i = 0
    filename = "image_test"
    GPIO.setmode(GPIO.BCM)  # new
    GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)  # new

    with picamera.PiCamera() as camera:
        camera.start_preview()
        camera.preview.alpha = 128
        Run = 1
        while Run:
            GPIO.wait_for_edge(18, GPIO.FALLING)  # new
            input_state = GPIO.input(18)
            if input_state == False:
                #    new_filename = image_save(filename, i)
                #    filename2 = new_filename[0]
                #    image = '/home/pi/Desktop/'
                #    camera.capture(image+filename2)
                #if the last reading was low and this one high, print
                camera.capture('/home/pi/Desktop/image4.jpg')
                camera.stop_preview()
                Run = 0

    command = "zbarimg"
    location = "/home/pi/Desktop/image4.jpg"
    #result = run_p(command+location)
    result = ''
    try:
        result = subprocess.check_output(["zbarimg", location])
    except:
        camera_capture()
    result = ' '
    result = subprocess.check_output(["zbarimg", location])

    obj_temp = sensor.readObjTempC()

    new_result = result.split(":")
    new2_result = new_result[1].split(",")

    info_dict = {
        "Name": None,
        "Airliner": None,
        "Ticket Number": None,
        "City of Origin": None,
        "Country of Origin": None,
        "Temperature": None
    }
    info_dict["Name"] = new2_result[0]
    info_dict["Airliner"] = new2_result[1]
    info_dict["Ticket Number"] = new2_result[2]
    info_dict["City of Origin"] = new2_result[3]
    info_dict["Country of Origin"] = new2_result[4].rstrip()
    info_dict["Temperature"] = c_to_f(obj_temp)

    json_message = json.dumps(info_dict, indent=1)
    print "Sending Message"
    print json_message
    print " "

    return json_message
예제 #9
0
    return c * 9.0 / 5.0 + 32

def write_die_temp(die_1): #die temp file SENSOR 1
    with open("/home/pi/data/Sensor_1.csv", "a") as log:
        log.write("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11}\n".format(strftime("%Y-%m-%d %H:%M:%S"),"Sensor 1",str(die_1)+" F",str(obj_1)+" F",str(die_temp)+" C",str(obj_temp)+" C"," ","Sensor 2",str(die_2)+" F",str(obj_2)+" F",str(die_temp2)+" C",str(obj_temp2)+" C"))

def graph(temp):
    y.append(temp)
    x.append(time())
    plt.clf()
    plt.scatter(x,y)
    plt.plot(x,y)
    plt.draw()

# Initialze sensor
sensor = TMP006.TMP006()
sensor_2 = TMP006.TMP006()

#i2c = busio.I2C(board.SCL, board.SDA)
sensor = TMP006.TMP006(address=0x40, busnum=1) # Default i2C address is 0x40 and bus is 1.
sensor_2 = TMP006.TMP006(address=0x41, busnum =1) # change 3v to ad0

# Default rate is 16 samples per loop.
sensor.begin()
sensor_2.begin()
# Loop printing measurements every second.
print ('Press Ctrl-C to quit.')
print ('Storing data /home/pi/data')
print ('Temperature is in Fahrenheit')

예제 #10
0
def sensors():
    # Temperature Sensor 1
    # VCC - RED - 3.5v
    # GND - BLK - Ground
    # SDA - YLW - SDA
    # SCL - BRN - SCL
    sensor1 = TMP006.TMP006()
    sensor1 = TMP006.TMP006(address=0x40, busnum=1) # Default i2C address is 0x40 and bus is 1.
    sensor1.begin()
    # Accelerometer Sensor
    # 3v3 - RED - 3.5v
    # GND - BLK - Ground
    # SDA - YLW - SDA
    # SCL - BRN - SCL
    accelerometer = adafruit_adxl34x.ADXL345(i2c)
    # Distance Sensor
    # VIN - RED - 3.5v
    # GND - BLK - Ground
    # SDA - YLW - SDA
    # SCL - BRN - SCL
    vl53 = adafruit_vl53l0x.VL53L0X(i2c)

    while True:
        # Distance Sensor
        global distance
        distance = vl53.range
        print ("Range: {0}mm".format(distance))
        #ser.write (b'Range: %d '%(distance)+b' mm \n')
        time.sleep(.1)

        # Temperature Sensor 1
        global obj1
        global die1
        obj1 = sensor1.readObjTempC()
        die1 = sensor1.readDieTempC()

        # Temperature Sensor 1 Serial out
        #ser.write (b'Sensor 1 object Temperature: %d \n'%(obj1))
        #ser.write (b'Sensor 1 die Temperature: %d \n'%(die1))
        print ('Object temperature: {0:0.3F}*C / {1:0.3F}*F'.format(obj1, TempConversion(obj1)))
        print ('Die temperature: {0:0.3F}*C / {1:0.3F}*F'.format(die1, TempConversion(die1)))
        time.sleep(.1)

        # Accelerometer tupple parse
        global xAxis
        global yAxis
        global zAxis
        xAxis = (round(accelerometer.acceleration[0],1))
        yAxis = (round(accelerometer.acceleration[1],1))
        zAxis = (round(accelerometer.acceleration[2],1))

        '''
        # Accelerometer Serial out
        ser.write (b'X Axis: %d \n'%(xAxis))
        ser.write (b'Y Axis: %d \n'%(yAxis))
        ser.write (b'Z Axis: %d \n'%(zAxis))
        '''

        print ('X Axis: %d \n'%(xAxis))
        print ('Y Axis: %d \n'%(yAxis))
        print ('Z Axis: %d \n'%(zAxis))
        
        #Write all data
        write_sensors()
        time.sleep(1)
예제 #11
0
# Define a function to convert celsius to fahrenheit.
def c_to_f(c):
    return c * 9.0 / 5.0 + 32.0


# Default constructor will use the default I2C address (0x40) and pick a default I2C bus.
#
# For the Raspberry Pi this means you should hook up to the only exposed I2C bus
# from the main GPIO header and the library will figure out the bus number based
# on the Pi's revision.
#
# For the Beaglebone Black the library will assume bus 1 by default, which is
# exposed with SCL = P9_19 and SDA = P9_20.
#
# Remember this TMP006 code will work fine with the TMP007 sensor too!
sensor = TMP006.TMP006(address=0x46)

# Optionally you can override the address and/or bus number:
#sensor = TMP006.TMP006(address=0x42, busnum=2)

# Initialize communication with the sensor, using the default 16 samples per conversion.
# This is the best accuracy but a little slower at reacting to changes.
sensor.begin()

# Optionally initialize with a faster but less precise sample rate.  You can use
# any value from TMP006_CFG_1SAMPLE, TMP006_CFG_2SAMPLE, TMP006_CFG_4SAMPLE,
# TMP006_CFG_8SAMPLE, or TMP006_CFG_16SAMPLE for the sample rate.
#sensor.begin(samplerate=TMP006.CFG_1SAMPLE)

# Loop printing measurements every second.
print('Press Ctrl-C to quit.')
예제 #12
0
def write_die_temp(die_1):  #die temp file SENSOR 1
    with open("/home/pi/data/Sensor_1.csv", "a") as log:
        log.write("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11}\n".format(
            strftime("%Y-%m-%d %H:%M:%S"), "Sensor 1",
            str(die_1) + " F",
            str(obj_1) + " F",
            str(die_temp) + " C",
            str(obj_temp) + " C", " ", "Sensor 2",
            str(die_2) + " F",
            str(obj_2) + " F",
            str(die_temp2) + " C",
            str(obj_temp2) + " C"))


# Initialze sensor
sensor = TMP006.TMP006()
sensor_2 = TMP006.TMP006()

#i2c = busio.I2C(board.SCL, board.SDA)
sensor = TMP006.TMP006(address=0x40,
                       busnum=1)  # Default i2C address is 0x40 and bus is 1.
#sensor_2 = TMP006.TMP006(address=0x41, busnum =1) # change 3v to ad0

# Default rate is 16 samples per loop.
sensor.begin()
#sensor_2.begin()

# Loop printing measurements every second.
print('Press Ctrl-C to quit.')
print('Storing data /home/pi/data')
print('Temperature is in Fahrenheit')
예제 #13
0
    sleep(0.2)
    kit.servo[15].angle = 90


def Snooze():
    print("Snooze")


#SETUP INPUT

#define the sensor pins that goes to the circuit

import Adafruit_TMP.TMP006 as TMP006

sensor_temp = TMP006.TMP006(address=0x41, busnum=1)
sensor_temp.begin()


class Env(Environment):
    """ Environment for RL our agent will be able to observe"""

    # the number of action values the environment accepts - Foreward, Backward and Snooze
    indim = 2

    # the number of sensor values the environment produces - analog in photoresistor_sensor
    outdim = 165

    def getSensors(self):
        """ the currently visible state of the world (the observation may be stochastic - repeated calls returning different values) 
            :rtype: by default, this is assumed to be a numpy array of doubles
예제 #14
0
# Define serial port
ser = serial.Serial(
        port='/dev/ttyS0', #Replace ttyS0 with ttyAM0 for Pi1,Pi2,Pi0
        baudrate = 9600,
        parity=serial.PARITY_NONE,
        stopbits=serial.STOPBITS_ONE,
        bytesize=serial.EIGHTBITS,
        timeout=1
)

# Function to convert celsius (c) to fahrenhiet.
def TempConversion(c):
    return c * 9.0 / 5.0 + 32

# Initialze sensor
sensor = TMP006.TMP006()

# Default i2C address is 0x40 and bus is 1.
sensor = TMP006.TMP006(address=0x40, busnum=1)

# Default rate is 16 samples per loop.
sensor.begin()

# Loop printing measurements every second.
ser.write(b'Press Ctrl-C to quit. \n')
counter = 0
while 1:
    obj_temp = sensor.readObjTempC()
    die_temp = sensor.readDieTempC()
    #reads object temp
    #print ('Object temperature: {0:0.3F}*C / {1:0.3F}*F'.format(obj_temp, TempConversion(obj_temp)))
예제 #15
0

# Define a function to convert celsius to fahrenheit.
def c_to_f(c):
    return c * 9.0 / 5.0 + 32.0


# Default constructor will use the default I2C address (0x40) and pick a default I2C bus.
#
# For the Raspberry Pi this means you should hook up to the only exposed I2C bus
# from the main GPIO header and the library will figure out the bus number based
# on the Pi's revision.
#
# For the Beaglebone Black the library will assume bus 1 by default, which is
# exposed with SCL = P9_19 and SDA = P9_20.
sensor = TMP006.TMP006()

# Optionally you can override the address and/or bus number:
#sensor = TMP006.TMP006(address=0x42, busnum=2)

# Initialize communication with the sensor, using the default 16 samples per conversion.
# This is the best accuracy but a little slower at reacting to changes.
sensor.begin()

# Optionally initialize with a faster but less precise sample rate.  You can use
# any value from TMP006_CFG_1SAMPLE, TMP006_CFG_2SAMPLE, TMP006_CFG_4SAMPLE,
# TMP006_CFG_8SAMPLE, or TMP006_CFG_16SAMPLE for the sample rate.
#sensor.begin(samplerate=TMP006.CFG_1SAMPLE)

# Loop printing measurements every second.
print 'Press Ctrl-C to quit.'
예제 #16
0
파일: tmp006.py 프로젝트: qwekw/Mycodo
 def get_measurement(self):
     """ Gets the TMP006's temperature in Celsius """
     sensor = TMP006.TMP006(address=self.i2c_address, busnum=self.i2c_bus)
     sensor.begin()
     return sensor.readDieTempC(), sensor.readObjTempC()
예제 #17
0
#importing packages to stream to plot.ly and work with surface Temp-sensors
#tutorial: https://plot.ly/raspberry-pi/tmp36-temperature-tutorial/
import plotly.plotly as py
import json
import time
import datetime
import Adafruit_TMP.TMP006 as TMP006

#create initial file, named by date, and write first line with header
date = time.strftime("%Y%m%d")
f = open('/your/logging/directory/' + date + '-SurfTemp', 'a')
f.write('#; date; time; t_surf1; t_surf2; t_surf3\n')

#initializing temperature sensors
sensor1 = TMP006.TMP006(address=0x44)
sensor2 = TMP006.TMP006(address=0x40)
sensor3 = TMP006.TMP006(address=0x41)
sensor1.begin()
sensor2.begin()
sensor3.begin()
print('Sensors started')

#reading file with user credentials and streaming tokens for plotly
with open('/your/script/directory/config.json') as config_file:
    plotly_user_config = json.load(config_file)
    py.sign_in(plotly_user_config["plotly_username"],
               plotly_user_config["plotly_api_key"])
print('config file loaded')

#initialize plot online and get url. this contains 3 stream plots
url = py.plot([{