#include <Wire.h>
#include "WireExt.h"
#define D6T_addr 0x0A
#define D6T_cmd 0x4C
int rbuf[35];
float tdata[16];
float t_PTAT;
void setup()
{
Wire.begin();
Serial.begin(9600);
Serial.flush();
}
void loop()
{
Wire.beginTransmission(D6T_addr);
Wire.write(D6T_cmd);
Wire.endTransmission();
if (WireExt.beginReception(D6T_addr) >= 0) {
for (int i = 0; i < 35; i++) {
rbuf[i] = WireExt.get_byte();
}
WireExt.endReception();
t_PTAT = (rbuf[0]+(rbuf[1]<<8));
for (int i = 0; i < 16; i++) {
tdata[i]=(rbuf[(i*2+2)]+(rbuf[(i*2+3)]<<8))-t_PTAT;
}
output_csv(); // CSVで出力
delay(500); // 500ミリ秒待つ
}
}
// CSVで温度を出力
void output_csv() {
for (int i = 0; i < 16; i++) {
Serial.print(tdata[i]);
if (i < 15) {
Serial.print(",");
}
else {
Serial.println();
}
}
}
|