Hi
I eventually gave up on this. Having watched Omron’s advertising video, I had naively assumed that they had discovered some deep voodoo which would allow their sensor to detect 37 degrees anywhere within a room, but of course the detected temperature falls with distance and is affected by clothing, and I couldn’t find any way of consistently relating distance (using an ultrasound sensor) to temperature. As far as I went using the 1 x 8 sensor turned on its side, it would fairly reliably detect the presence of a person, and, if they moved out of the way, it would turn in the right direction, but would reliably follow them only as long as they moved obligingly slowly. So now I’m wondering if, using two sonars, I can triangulate their position and move the servo immediately to a specific angle, rather than doing an incremental sweep. I’d use the Omron sensor simply to check that the target is within a likely temperature range. Anyway, although I’ve pretty much given up, I thought I’d share what I’ve discovered in the hope that someone can make better use of it than I have.
Code samples and examples of use: sample code may be found at Thermal IR-Camera - SGMK-SSAM-WIKI and http://bmedesign.engr.wisc.edu/projects/file/?fid=3202
Harness can be purchased from http://international.switch-science.com/catalog/1305/. I placed an order online and they kindly then sent me an email explaining that the web page was only for Japanese users and how I could place an order from the UK. You can, of course, make your own with parts purchased from http://www.digikey.co.uk, but make sure you have an electron microscope handy in case you drop a bit.
Documentation is at http://www.mouser.com/pdfdocs/D6T01_ThermalIRSensorWhitepaper.pdf and http://www.farnell.com/datasheets/1675620.pdf with sample code (I don’t know what language) to talk to the sensor via I2C on page 10 of the former.
Tutorials If you are new to I2C as I was, see Jeremy Blum’s excellent tutorial at http://www.jeremyblum.com/2011/02/13/arduino-tutorial-7-i2c-and-processing/, as well as the introduction to I2C at http://tronixstuff.com/2010/10/20/tutorial-arduino-and-the-i2c-bus/.
Processing code Finally, here’s an Arduino sketch and a Processing sketch which will allow you to see on your computer what the Omron sensor detects. It’s for the 1 x 8 sensor, but, if you use the 4 x 4 sensor, you just need to increase the array size and the loop iterations (see page 10 of http://www.mouser.com/pdfdocs/D6T01_ThermalIRSensorWhitepaper.pdf)
Arduino
#include <Wire.h>
int rbuf [ 18 ] ;//the buffer storing all of the data we read from the sensor (2 bytes per cell of the column of 8, plus two bytes for the reference temperature and one for the packet error check code)
int TDATA [ 8 ] ;//contains temperature data for each cell of the sensor's matrix (each being two bytes)
int T_PTAT;//stores the reference temperature recorded from the thermal sensor ( see http://www.mouser.com/pdfdocs/D6T01_ThermalIRSensorWhitepaper.pdf page 8)
void setup(){
Serial.begin(9600);
Wire.begin();
}
void loop(){
readTemperatures();
}
void readTemperatures(){
String buf = "";
int i = 0 ;
Wire.beginTransmission(0x0A);
Wire.write(0x4C);
int writeStatus = Wire.endTransmission();
if(writeStatus != 0){
//Serial.println("Writing failed");
return;
}
delay(100);
Wire.requestFrom(0x0A, 18);
for (i = 0 ; i < 19 ; i++) {
rbuf [i] = Wire.read();
}
T_PTAT = (rbuf[0]+(rbuf[1] << 8));
for (i = 0 ; i < 8 ; i++) {
TDATA [i] = (rbuf [(i * 2 + 2)] + ( rbuf [(i * 2 + 3)] << 8 ));//offset by 2 because T_PTAT occupies the first 2 bytes
buf = buf + (TDATA[i]);
//I would have expected not to end the string with a comma,
//but if I don't add a trailing comma, the split function in the Processing sketch
//won't get the last value as an array element. C++ remains a mystery to me.
buf = buf + (",");
}
Serial.println(buf);
}
Processing
import processing.serial.*;
Serial myPort; // Create object from Serial class
int [ ] TDATA = new int[ 9 ] ;//all coming from Arduino as temp * 10, so type can be int and will display 10 times the actual detected temperature
float Tptat ;
String buf ;
color [ ] TColor = { #400040, #000080, #006060, #008000, #C0C000, #E0A000 , #E00000, #F08080};
void setup(){
size(1280,160);
Serial.list();
String portName = Serial.list()[1]; //change the 0 to a 1 or 2 etc. to match your port; 0 on Windows is normally COM1. If, say, COM4 is the second available port, you need Serial.list()[1] here.
myPort = new Serial(this, portName, 9600);
myPort.bufferUntil('\n');
}
void draw()
{
int coord = 0;
for(int i = 0; i < 8; i++){
if(TDATA[i] < 10){
fill(TColor[0]);
}
else if(TDATA[i]< 50){
fill(TColor[1]);
}
else if(TDATA[i] < 100){
fill(TColor[2]);
}
else if(TDATA[i] < 150){
fill(TColor[3]);
}
else if(TDATA[i] < 200){
fill(TColor[4]);
}
else if(TDATA[i] < 250){
fill(TColor[5]);
}
else if(TDATA[i] < 300){
fill(TColor[7]);
}
else{
fill(TColor[6]);
}
rect(coord * 160, 0, 160, 160);
textSize(20);
fill(0, 0, 0);
text(str(TDATA[i]), i*160+20, 20);
coord++;
}
}
void serialEvent(Serial myPort){
buf = myPort.readStringUntil('\n');
//println(buf);
TDATA = int(split(buf, ','));
}