Setting up D6T-44L-06 For Human Presence detection

I need help to set up d6t-44l-06 sensor. Am trying to configure the sensor to detect human presence and light up an LED ON and OFF ten times. I was trying to modify the code from MIT but i dont understand most of its parts...Help ASAP

#include <Wire.h>

/* defines */
#define D6T_ADDR 0x0A  // for I2C 7bit address
#define D6T_CMD 0x4C  // for D6T-44L-06/06H, D6T-8L-09/09H, for D6T-1A-01/02

#define N_ROW 4
#define N_PIXEL (4 * 4)
#define N_READ ((N_PIXEL + 1) * 2 + 1)
const int led = 7;

uint8_t rbuf[N_READ];
double ptat;
double pix_data[N_PIXEL];

uint8_t calc_crc(uint8_t data) {
    int index;
    uint8_t temp;
    for (index = 0; index < 8; index++) {
        temp = data;
        data <<= 1;
        if (temp & 0x80) {data ^= 0x07;}
    }
    return data;
}

/** <!-- D6T_checkPEC {{{ 1--> D6T PEC(Packet Error Check) calculation.
 * calculate the data sequence,
 * from an I2C Read client address (8bit) to thermal data end.
 */
bool D6T_checkPEC(uint8_t buf[], int n) {
    int i;
    uint8_t crc = calc_crc((D6T_ADDR << 1) | 1);  // I2C Read address (8bit)
    for (i = 0; i < n; i++) {
        crc = calc_crc(buf[i] ^ crc);
    }
    bool ret = crc != buf[n];
    if (ret) {
        Serial.print("PEC check failed:");
        Serial.print(crc, HEX);
        Serial.print("(cal) vs ");
        Serial.print(buf[n], HEX);
        Serial.println("(get)");
    }
    return ret;
}

/** <!-- conv8us_s16_le {{{1 --> convert a 16bit data from the byte stream.
 */
int16_t conv8us_s16_le(uint8_t* buf, int n) {
    uint16_t ret;
    ret = (uint16_t)buf[n];
    ret += ((uint16_t)buf[n + 1]) << 8;
    return (int16_t)ret;   // and convert negative.
}

/** <!-- setup {{{1 -->
 * 1. Initialize 
       - initialize a Serial port for output.
     - initialize I2C.
 */
void setup() {
    Serial.begin(9600);  // Serial baudrate = 9600bps
    Wire.begin();  // i2c master
  delay(620);
  pinMode(led, OUTPUT);
}

/** <!-- loop - Thermal sensor {{{1 -->
 * 2. read data.
 */
void loop() {
    int i = 0;
  int16_t itemp = 0;
  
  // Read data via I2C
  // I2C buffer of "Arduino MKR" is 256 buffer. (It is enough)
    memset(rbuf, 0, N_READ);
    Wire.beginTransmission(D6T_ADDR);  // I2C slave address
    Wire.write(D6T_CMD);               // D6T register
    Wire.endTransmission();
    delay(1);
    Wire.requestFrom(D6T_ADDR, N_READ);
    while (Wire.available()) {
        rbuf[i++] = Wire.read();
    }
    D6T_checkPEC(rbuf, N_READ - 1);

    //Convert to temperature data (degC)
    ptat = (double)conv8us_s16_le(rbuf, 0) / 10.0;
  for (i = 0; i < N_PIXEL; i++) {
    itemp = conv8us_s16_le(rbuf, 2 + 2*i);
    pix_data[i] = (double)itemp / 10.0;
  }
    
    //Output results
    Serial.print("PTAT:");
    Serial.print(ptat, 1);
    Serial.print(" [degC], Temperature: ");
  for (i = 0; i < N_PIXEL; i++) {
      Serial.print(pix_data[i], 1);
    Serial.print(", ");
  } 
    Serial.println(" [degC]"); 
    
    if(pix_data[i]==30){
     for(int h=0;h<10;h++){
       digitalWrite(led, HIGH);
       delay(100);
        digitalWrite(led, LOW);
        delay(100);
     }
    }
}
// vi: ft=arduino:fdm=marker:et:sw=4:tw=80

Hi
Link to data/specs d6t-44l-06 sensor.

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

D6T-OMRON.pdf (1.6 MB)

Hi,
Have you Goolged;

d6t-44l-06 sensor arduino

Tom.... :smiley: :+1: :coffee: :australia:

Yeah but the problem is that am failing to set it up to detect huamn being.All I need I code that detects a human being coz I r eally dnt know more about this. sensor and its libraries