def init_sensors(self): self.GAIN = 1 self.multiplex = multiplexer.multiplex(1) self.pump_sensor = MLX90614(self.bus, address=0x12) self.gps = gps.gps() self.SB_sensor = MLX90614(self.bus, address=0x19) self.co2_sensor = CO2_sensor.co2Sensor() self.o3_sensor = O3_sensor.o3Sensor()
def run(): bus = SMBus(1) ListAmbTemp = [] ListObjTemp = [] sensor = MLX90614(bus, address=0x5A) SumAmbTemp = 0 SumObjTemp = 0 AmbTemp, ObjTemp = GetTemperature.ReadSensor(sensor) # print("\nRaw Ambients ",AmbTemp) # print("\nRaw Object ",ObjTemp) for i in range(0, 10): AmbTemp, ObjTemp = GetTemperature.ReadSensor(sensor) SumAmbTemp = SumAmbTemp + AmbTemp SumObjTemp = SumObjTemp + ObjTemp # Get average value AvgAmbTemp = SumAmbTemp / 10 AvgObjTemp = SumObjTemp / 10 print("\nAmbient Temperature: ", round(AvgAmbTemp, 1), "*C") # print("\nObject Temperature: ", AvgObjTemp) EstimatedTemp = GetTemperature.EstimateRealObjectTemp( AvgAmbTemp, AvgObjTemp) ErrorIndex = 0 if (EstimatedTemp == -1000): ErrorIndex = ErrorIndex + 1 if (ErrorIndex >= 3): print( "\nOut of Measurement Range, the Ambient Temperature is too hot or too cold" ) elif (EstimatedTemp > 33): print("\nObject Temperature: ", round(EstimatedTemp - 0.5, 1), "*C") ErrorIndex = 0 bus.close()
def __init__(self): self.send_email = os.environ.get('SEND_EMAIL') self.video = cv2.VideoCapture(0) self.mid = 0 self.temp = None self.detector = dlib.get_frontal_face_detector() self.predictor = dlib.shape_predictor("models/shape_predictor_68_face_landmarks.dat") self.model = load_model('models/mask_detector.h5') self.mask_detection_completed = False self.mask_count = 0 self.temperature_check_completed = False self.operation_status_failed = False if self.send_email == 'TRUE': self.sender_email = os.environ.get('EMAIL_ID') self.receiver_email = os.environ.get('EMAIL_ID') self.password = os.environ.get('EMAIL_PWD') self.message = MIMEMultipart("alternative") self.message["Subject"] = "Alert: A New Person Entered the Premises" self.message["From"] = self.sender_email self.message["To"] = self.receiver_email self.bus = SMBus(1) self.sensor = MLX90614(self.bus, address=0x5A)
def __init__(self, trig_pin, echo_pin, i2c_bus=1, _get_state=None): self.bus = SMBus(i2c_bus) self.IRSens = MLX90614(self.bus) self.ProxSens = HCSR04.HCSR_04(trig_pin, echo_pin, self.IRSens.get_ambient()) self.VERIFICATION = 10 self._get_state = _get_state
def run(self): thermometer_address = 0x5a thermometer = MLX90614(thermometer_address) values = [0] * 10 i = 0 sum1 = 0 time.sleep(2) self.WelcomeBox.setStyleSheet("background-color: rgb(254, 220, 151);") self.TextView.setText( "Kindly wait while the device calculates the result.") while (i < 3): time.sleep(2) l = thermometer.get_obj_temp() time.sleep(1) sum1 = sum1 + l i = i + 1 avg = sum1 / 3 body_temp = ((avg * (9 / 5)) + 32) self.TextView.setText( " Body Temperature") self.SensorValue.setText(str(round(body_temp, 2))) self.SignView.setText("°F")
def __init__(self, config): SensorWrapper.__init__(self, config) # Additional config option for i2c address, default to 0x5A self.address = int(config.get('address', "0x5A"), 16) # I2C bus self.bus = SMBus(1) # Create sensor object self.sensor = MLX90614(self.bus, address=self.address)
def get_Temperature(): bus = SMBus(1) sensor = MLX90614(bus, address=0x5A) print "Ambient Temperature :", sensor.get_ambient() print "Object Temperature :", sensor.get_object_1() temp = sensor.get_object_1() bus.close() return temp
def ambiente(): bus = SMBus(1) sensor = MLX90614(bus, address=0x5A) am = sensor.get_ambient() float(am) print("TA,", am) print('\n') bus.close() time.sleep(0.005) return am
def main(): bus = SMBus(1) # This is the I2C bus used IRSens = MLX90614(bus) while True: #print(f"Ambient Temperature = {IRSens.get_ambient():.2f}") print(f" IR Temperature = {1.02*IRSens.get_object_1():.2f}") # print(f"T_obj2 = {IRSens.get_object_2()}") time.sleep(0.3)
def init_RPi(self): self.lock_conf = self.conf['LOCK_CONF'] self.lock_pin = int(self.lock_conf['lock_pin']) self.lock_in_pin = int(self.lock_conf['lock_in_pin']) self.sensor_conf = self.conf['SENSOR_CONF'] self.max_temp = int(self.sensor_conf['max_temp']) bus = SMBus(1) self.temp_sensor = MLX90614(bus, address=0x5A) GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.setup(self.lock_pin, GPIO.OUT) GPIO.output(self.lock_pin, GPIO.LOW) GPIO.setup(self.lock_in_pin, GPIO.IN)
def __init__(self): self.servoxPIN = 32 self.servoyPIN = 33 self.camera = PiCamera() self.camera.framerate = 32 self.camera.rotation = 180 self.rawCapture = PiRGBArray(self.camera) # allow the camera to warmup time.sleep(0.1) self.send_email = os.environ.get('SEND_EMAIL') self.mid = 0 self.temp = None self.detector = dlib.get_frontal_face_detector() self.predictor = dlib.shape_predictor( "models/shape_predictor_68_face_landmarks.dat") self.model = load_model('models/mask_detector.h5') self.mask_detection_completed = False self.mask_count = 0 self.temperature_check_completed = False self.operation_status_failed = False if self.send_email == 'TRUE': self.sender_email = os.environ.get('EMAIL_ID') self.receiver_email = os.environ.get('EMAIL_ID') self.password = os.environ.get('EMAIL_PWD') self.message = MIMEMultipart("alternative") self.message[ "Subject"] = "Alert: A New Person Entered the Premises" self.message["From"] = self.sender_email self.message["To"] = self.receiver_email self.servoX = Servo(self.servoxPIN) self.servoY = Servo(self.servoyPIN) self.servoX.setAngle(90) self.servoY.setAngle(90) self.bus = SMBus(1) self.sensor = MLX90614(self.bus, address=0x5A)
def temp(): bus = SMBus(1) sensor = MLX90614(bus, address=0x5A) while True: temp_list = [] print('ambient : ', sensor.get_ambient()) print('object : ', sensor.get_object_1()) if int(sensor.get_ambient()) < int(sensor.get_object_1()): for i in range(20): print("Ambient Temperature :", sensor.get_ambient()) temp_list.append(sensor.get_object_1()) bus.close() return sum(temp_list) / len(temp_list)
def read_temp(): while True: bus = SMBus(1) sensor = MLX90614(bus, address=0x5A) global temp # print (sensor.get_ambient()) temp = sensor.get_object_1() # print (temp) byte_value = bytearray(struct.pack("f", temp)) send_mesaj(byte_value) time.sleep(0.1) bus.close() return temp
def objeto(): #se declara la funcion bus = SMBus(1) #parte de la biblioteca para el sensor sensor = MLX90614(bus, address=0x5A) #parte de la biblioteca para el sensor ob = sensor.get_object_1( ) # el objeto que se ocupa para el sensor lo asignamos a una variable float( ob ) #hacemos un cast para hacerlo float y podemos ocuparlo en funciones posteriores print("TO,", ob) #lo imprimimos print('\n') bus.close() #parte de la biblioteca para el sensor time.sleep(0.005) return ob #retornamos el valor de ob para poder ocuparlo en otras fucniones
def temp(): bus = SMBus(1) sensor = MLX90614(bus, address=0x5A) print ("Ambient Temperature :", sensor.get_ambient()) print ("Object Temperature :", sensor.get_object_1()) temp=sensor.get_object_1() bus.close() if temp>35: print("High Temperature") GPIO.output(buzzer,GPIO.HIGH) print("Buzzer ON") time.sleep(5) else: print("Normal temperature") Process() time.sleep(5)
def _read_sensor(self, ts): """Reads data from the sensor Args: **ts (int)**: timestamp of when the data was read """ self._bus = SMBus(self._bus_id) self._sensor = MLX90614(self._bus, address=self._address) data = { "ambient": self._sensor.get_ambient(), "object": self._sensor.get_object_1() } self._bus.close() return data
def obstacle_detected(self, state): try: if state and self.status_bar.value() == 66: m = MLX90614() temp = round(m.get_obj_temp() * 1.18, 1) if 35.5 < temp < 37.0: self.status_bar.setValue(100) self.status_bar.repaint() self.person_name_label.setText(f"{temp}") self.person_name_label.repaint() for _ in range(3): pixels.fill((0, 255, 0)) time.sleep(0.5) pixels.fill((0, 0, 0)) time.sleep(0.5) self.reset() except Exception as e: print("[ERROR] No mlx90614 found") quit()
def load_data(self): data = None try: data = {} sensor = MLX90614(self.i2c_address,int(self.i2c_bus)) # we cannot cache data here.... as both are 'temperature' values if 'object' == self.temp_type: data['temperature'] = float(sensor.get_obj_temp()) elif 'ambient' == self.temp_type: data['temperature'] = float(sensor.get_amb_temp()) else: data = None except Exception as ex: print(ex) return data
def mlx(sensor): bus = SMBus(1) sensor = MLX90614(bus, address=0x5A) bus.close() time.sleep(0.005) return (bus, sensor)
def tempfun(): bus = SMBus(1) sensor = MLX90614(bus, address=0x5A) obj_cel = sensor.get_object_1() + 2 bus.close() return pytemperature.c2f(obj_cel)
def __init__(self, bus): self.sensor = MLX90614(bus, address=0x5A)
menu_name = "MLX90614" from mlx90614 import MLX90614 from ui import Refresher sensor = MLX90614() def show_temp(): try: amb_temp = round(sensor.read_amb_temp(), 1) obj_temp = round(sensor.read_obj_temp(), 1) except IOError: amb_temp = None obj_temp = None data = [ "Ambient:" + str(amb_temp).rjust(o.cols - len("Ambient:")), "Object:" + str(obj_temp).rjust(o.cols - len("Object:")) ] return data #Callback global for pyLCI. It gets called when application is activated in the main menu #Some globals for us i = None #Input device o = None #Output device def callback():
#!/usr/bin/env python """ script para leer temperatura cada 5 segundos """ from time import sleep from mlx90614 import MLX90614 sensor1 = MLX90614(0x2f) sensor2 = MLX90614(0x5b) sensor3 = MLX90614(0x5c) while True: print '2F [amb= ', print(sensor1.get_amb_temp()), print ' | obj = ', print(sensor1.get_obj_temp()), print '] ', print '5B [amb= ', print(sensor2.get_amb_temp()), print ' | obj = ', print(sensor2.get_obj_temp()), print '] ', print '5C [amb= ', print(sensor1.get_amb_temp()), print ' | obj = ', print(sensor1.get_obj_temp()), print ']' sleep(2)
import smbus import time from mlx90614 import MLX90614 from Adafruit_BNO055 import BNO055 BNO_ADDR_A = 0x28 IR_ADDR = 0x5B SLEEPTIME = 0.01 therm = MLX90614(IR_ADDR) IMU_Nose = BNO055.BNO055(None, BNO_ADDR_A) bus = smbus.SMBus(1) def medianFilter(data): data.sort return data[2] def filteredData(): rawTemp = [] noseX = [] noseY = [] noseZ = [] accel = [] for x in range(0, 5): try: rawTemp.append(therm.get_obj_temp_C()) except IOError: rawTemp.append(0) try: noseOrientation = IMU_Nose.read_euler()
def setup(self): """Sets up sensor configurations that should happen after loading from the database""" self._address = int(self._parameters['address'], 16) self._bus_id = int(self._parameters['bus_id']) self._bus = SMBus(self._bus_id) self._sensor = MLX90614(self._bus, address=self._address)
from smbus2 import SMBus from mlx90614 import MLX90614 import time bus = SMBus(1) sensor = MLX90614(bus, address=0x5A) while True: time.sleep(2) print("Object Temperature : {0:.2f}".format(sensor.get_object_1())) bus.close()
from mlx90614 import MLX90614 import datetime from influxdb import InfluxDBClient import time thermometer_address = 0x5a thermometer = MLX90614(thermometer_address) print(thermometer.get_amb_temp()) print(thermometer.get_obj_temp()) def main(): tempObj = thermometer.get_obj_temp() tempAmb = thermometer.get_amb_temp() print("TemperatureSky : ", tempObj, "C") print("TemperatureAmb : ", tempAmb, "C") mydate = datetime.datetime.utcnow() myTime = mydate.strftime('%Y-%m-%dT%H:%M:%SZ') print("Zeit ", myTime) json_body = [{ "measurement": "SkyTemp", "tags": { "location": "Berlin, Tempelhof", }, "time": myTime, "fields": { "Skytemp": (tempObj),
import sys sys.path.append("../../hardware") import smbus from mlx90614 import MLX90614 # Get SMBus object try: bus = smbus.SMBus(1) except: print("Failed to get bus object.", file=sys.stderr) sys.exit(1) # Create sensor driver object s = MLX90614(bus) # # Test 1: ambient temperature sanity # a_temp = s.get_ambient_temp() print(f"Ambient temperature: {a_temp:.2f} °C") if a_temp == None or a_temp < 10.0 or a_temp > 30.0: print("Ambient temperature looks fishy!", file=sys.stderr) sys.exit(1) print("Looks good!\n") # # Test 2: raise ambient temp
import time from time import sleep import Adafruit_BBIO.GPIO as GPIO #import Adafruit_BBIO.ADC as ADC from Adafruit_BBIO.Encoder import RotaryEncoder, eQEP2 from mlx90614 import MLX90614 myEncoder = RotaryEncoder(eQEP2) myEncoder.enable() sensor = MLX90614(address=0x5a, bus_num=2) #ADC.setup() #analogPin="P9_39" Act = 'P8_7' #Actt = 'P8_9' Fan = 'P8_9' #Fann = 'P8_15' GPIO.setup(Act, GPIO.OUT) #GPIO.setup(Actt, GPIO.OUT) GPIO.setup(Fan, GPIO.OUT) #GPIO.setup(Fann, GPIO.OUT) GPIO.output(Act, GPIO.HIGH) GPIO.output(Fan, GPIO.HIGH) f = raw_input('file name : ') filename = f + '.txt' tdata = open(filename, 'a+') tdata.write("Test start,start,start,start\n") a = 0 R = 0
Potentiometer is wired to A0 on ADS """ import smbus from time import sleep from mlx90614 import MLX90614 import Adafruit_ADS1x15 from Adafruit_BNO055 import BNO055 #initalize SMBus on i2c-1 i2c = smbus.SMBus(1) #MUX address MUX = 0x70 #close all MUX channels i2c.write_byte(MUX, 0) #initialize IR thermometer i2c addr 0x5B on channel 0 i2c.write_byte(MUX, (1 << 0)) IR = MLX90614(0x5B) #initialize IMU i2c addr 0x28 on channel 2 i2c.write_byte(MUX, (1 << 2)) IMU = BNO055(0x28) IMU.begin() #initialize ADC i2c addr 0x48 on channel 7 i2c.write_byte(MUX, (1 << 7)) ADC = Adafruit_ADS1x15.ADS1115(address=0x48) #conversion for ADC read CONVERT = (6.144 / 32767) def tempRead(): #select channel 0 i2c.write_byte(MUX, (1 << 0)) data = IR.get_obj_temp_C()