Thermal Camera (Thermo AI Device TiD) Python D6T-44L-06 Edition

The temperature data of OMRON MEMS non-contact temperature sensor D6T-44L-06 is acquired by I2C communication.


  1. Introduction
  2. Sensor
  3. Sensor case
  4. Raspberry Pi
  5. Python 5.1 Form 5.2 OMRON Non-contact Temperature Sensor D6T-44L-06 Edition 5.3 Pololu ranging sensor VL53L0X edition 5.4 BOSCH Temperature / Humidity / Barometric Pressure Sensor BME280 5.5 Shutdown / Reboot Switch Edition 5.6 OpenCV 5.7 Speedup

d6t.jpg

Use the smbus module to control I2C in Python on the Raspberry Pi. If the smbus module is not installed, install it with the following command.

pip install smbus

Although d6t_44l_06.py is imported and used as a package, temperature data can be obtained by itself for testing. d6t_44l_06.py (compressed with ZIP)

#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
D6T-44L-06 script.
==================
Temperature measure 5 times/second.
Human-detectable distance: MAX 7[m]
5.0[V] I2C(0Ah)
4x4 array 5~45[deg]
***
2020/9/7
* Remake def pixels().
* Previous def result[0] is device temperature.
* Sometime temperature is 41degC over.
* Max temperature set 40degC.
"""
import threading
import time

import numpy as np
i2c_enable = False
try:
    import smbus
    i2c_enable = True
except:
    i2c_enable = False

ADDRESS = 0x0a
REGISTER = 0x4c


class Sensor():
    def __init__(self, *args, **kwargs):
        self.avg_count = 10
        self.enable = False
        self._previous_result = None
        self._shutdowning = False
        self.temperature = 0.0

        self.i2c_enable = i2c_enable
        self._pixels_data = None

        if self.i2c_enable:
            self.enable = True
            self._i2c = smbus.SMBus(1)

        thread = threading.Thread(
            name='D6T-44L-06_Measuring',
            target=self.thread,
        )
        thread.daeom = True
        thread.start()

    @property
    def array(self):
        return (self.x, self.y)

    def avg(self, pixels):
        if self._pixels_data is None:
            self._pixels_data = [pixels]
        elif len(self._pixels_data) < self.avg_count:
            self._pixels_data = np.append(
                self._pixels_data, [pixels], axis=0)
        elif len(self._pixels_data) == self.avg_count:
            self._pixels_data = np.delete(
                self._pixels_data, 0, axis=0)
            self._pixels_data = np.append(
                self._pixels_data, [pixels], axis=0)

    def __del__(self):
        self._shutdowning = True

    @property
    def high(self):
        return 45.0

    @property
    def low(self):
        return 5.0

    @property
    def name(self):
        return 'D6T-44L-06'

    @property
    def pixels(self):
        result = None
        if self._pixels_data is not None:
            result = np.average(self._pixels_data, axis=0)
        return result

    def stop(self):
        self._shutdowning = True

    def thread(self):
        if self._shutdowning:
            return

        # for parent Thermo class.
        result = None

        if self.enable:
            result = []
            try:
                data = self._i2c.read_i2c_block_data(
                    ADDRESS,
                    REGISTER,
                    32)
            except:
                self.i2c_enable = False
                self.enable = False
                return

            self.temperature = (data[1]*256 + data[0]) / 10.0

            data.pop(0)
            data.pop(0)

            if data[1] < 250 :
                for i in range(4):
                    for j in range(4):
                        temperature \
                            = int((data[i*2*j+1])*256 + data[i*2*j]) / 10.0

                        if temperature > 41.0:
                            break

                        result.append(temperature)

            if len(result) != 16:
                result = self._previous_result
            else:
                self._previous_result = result

        self.avg(result)

        time.sleep(0.2)

        thread = threading.Thread(
            name='D6T-44L-06_Measuring',
            target=self.thread,
        )
        thread.daeom = True
        thread.start()

    @property
    def x(self):
        return 4

    @property
    def y(self):
        return 4

if __name__ == '__main__':
    import time
    sensor = Sensor()
    while True:
        tmp = sensor.pixels
        if tmp is not None:
            print(tmp)
            #print(max(tmp), min(tmp))
        time.sleep(1)
    pass

YouTube: Thermal Camera (Thermo AI Device TiD) Python Edition web: Thermo AI device TiD Python D6T (URL is subject to change.)

Recommended Posts

Thermal Camera (Thermo AI Device TiD) Python D6T-44L-06 Edition
Thermal Camera (Thermo AI Device TiD) Python OpenCV Edition
Thermal camera (thermo AI device TiD) Python VL53L0X edition
Thermal Camera (Thermo AI Device TiD) Python Form
Thermal Camera (Thermo AI Device TiD) Python Acceleration
Thermal camera (Thermo AI device TiD) Python BME280
Thermal Camera (Thermo AI Device TiD) Raspberry Pi Edition
Thermal Camera (Thermo AI Device TiD) Introduction
Thermal Camera (Thermo AI Device TiD) Raspberry Pi Edition
Thermal Camera (Thermo AI Device TiD) Python OpenCV Edition
Thermal camera (thermo AI device TiD) Python VL53L0X edition
Thermal Camera (Thermo AI Device TiD) Python D6T-44L-06 Edition
Thermal Camera (Thermo AI Device TiD) Introduction
Thermal Camera (Thermo AI Device TiD) Python Form
Thermal Camera (Thermo AI Device TiD) Python Acceleration
Thermal camera (Thermo AI device TiD) Python BME280
Raspberry Pi Security Infrared Camera (Python Edition)