|
|
|
|
$ uname -a Linux raspberrypi 4.14.34-v7+ #1110 SMP Mon Apr 16 15:18:51 BST 2018 armv7l GNU/Linux
![]() Conta サーモグラフィー AMG8833搭載 ASIN: B079BMKRW7 |
![]() 赤外線アレイ・サーモ・センサモジュール ASIN: B079N943NT |

i2cdetect -y 1
pi@raspberrypi:~ $ i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
・i2cdetectコマンドで AMG8833の接続を確認
i2cdump -y 1 0x68
pi@raspberrypi:~ $ i2cdump -y 1 0x68
No size specified (using byte-data access)
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: 00 00 00 00 02 00 00 00 00 00 00 00 00 00 da 01 ....?.........??
10: bb bb 7d 5f 7c b0 7f fd 00 00 00 00 00 00 00 00 ??}_|???........
20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
80: 74 00 75 00 74 00 72 00 74 00 73 00 75 00 75 00 t.u.t.r.t.s.u.u.
90: 74 00 74 00 75 00 75 00 74 00 73 00 74 00 74 00 t.t.u.u.t.s.t.t.
a0: 73 00 74 00 73 00 74 00 75 00 74 00 70 00 75 00 s.t.s.t.u.t.p.u.
b0: 70 00 74 00 72 00 73 00 73 00 73 00 73 00 72 00 p.t.r.s.s.s.s.r.
c0: 75 00 73 00 74 00 74 00 72 00 73 00 74 00 71 00 u.s.t.t.r.s.t.q.
d0: 72 00 73 00 73 00 73 00 71 00 71 00 74 00 73 00 r.s.s.s.q.q.t.s.
e0: 71 00 72 00 70 00 74 00 73 00 72 00 71 00 72 00 q.r.p.t.s.r.q.r.
f0: 72 00 72 00 72 00 6f 00 71 00 71 00 73 00 72 00 r.r.r.o.q.q.s.r.
i2cset -y 1 0x68 0x00 0x10
i2cdump -y 1 0x68
pi@raspberrypi:~ $ i2cset -y 1 0x68 0x00 0x10
pi@raspberrypi:~ $ i2cdump -y 1 0x68
No size specified (using byte-data access)
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
i2cset -y 1 0x68 0x00 0x00
i2cdump -y 1 0x68
pi@raspberrypi:~ $ i2cset -y 1 0x68 0x00 0x00
pi@raspberrypi:~ $ i2cdump -y 1 0x68
No size specified (using byte-data access)
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: 00 00 00 00 02 00 00 00 00 00 00 00 00 00 d7 01 ....?.........??
10: ff ff fa cf c5 aa fd 9f 00 00 00 00 00 00 00 00 ..??????........
20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
80: 70 00 72 00 70 00 70 00 71 00 70 00 6f 00 6f 00 p.r.p.p.q.p.o.o.
90: 70 00 6f 00 72 00 72 00 72 00 72 00 70 00 70 00 p.o.r.r.r.r.p.p.
a0: 71 00 72 00 71 00 70 00 72 00 72 00 70 00 72 00 q.r.q.p.r.r.p.r.
b0: 71 00 73 00 70 00 71 00 72 00 6f 00 73 00 72 00 q.s.p.q.r.o.s.r.
c0: 72 00 71 00 72 00 71 00 70 00 71 00 71 00 6e 00 r.q.r.q.p.q.q.n.
d0: 72 00 73 00 73 00 72 00 72 00 6e 00 71 00 71 00 r.s.s.r.r.n.q.q.
e0: 70 00 70 00 71 00 71 00 6f 00 6e 00 72 00 73 00 p.p.q.q.o.n.r.s.
f0: 6f 00 71 00 72 00 70 00 72 00 72 00 71 00 72 00 o.q.r.p.r.r.q.r.
pi@raspberrypi:~ $ i2cget -y 1 0x68 0x0e w 0x01d7 0x01d7をデータシートの計算式に当てはめると約 29.44℃となります。 0x01d7 * 0.0625 = 471 * 0.0625 = 29.4375℃
pi@raspberrypi:~ $ i2cset -y 1 0x68 0x02 0x00 pi@raspberrypi:~ $ i2cget -y 1 0x68 0x02 0x00 pi@raspberrypi:~ $ i2cset -y 1 0x68 0x02 0x01 pi@raspberrypi:~ $ i2cget -y 1 0x68 0x02 0x01
pi@raspberrypi:~ $ i2cget
Usage: i2cget [-f] [-y] I2CBUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]
I2CBUS is an integer or an I2C bus name
ADDRESS is an integer (0x03 - 0x77)
MODE is one of:
b (read byte data, default)
w (read word data)
c (write byte/read byte)
Append p for SMBus PEC
pi@raspberrypi:~ $ i2cset
Usage: i2cset [-f] [-y] [-m MASK] [-r] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE]
I2CBUS is an integer or an I2C bus name
ADDRESS is an integer (0x03 - 0x77)
MODE is one of:
c (byte, no value)
b (byte data, default)
w (word data)
i (I2C block data)
s (SMBus block data)
Append p for SMBus PEC
pi@raspberrypi:~ $ i2cdump
Error: No i2c-bus specified!
Usage: i2cdump [-f] [-y] [-r first-last] I2CBUS ADDRESS [MODE [BANK [BANKREG]]]
I2CBUS is an integer or an I2C bus name
ADDRESS is an integer (0x03 - 0x77)
MODE is one of:
b (byte, default)
w (word)
W (word on even register addresses)
s (SMBus block)
i (I2C block)
c (consecutive byte)
Append p for SMBus PEC

#include <stdio.h>
/*
gcc ESC_COLOR.c -o ESC_COLOR
./ESC_COLOR
*/
void printEscapeRgbColor(int r, int g, int b)
{
int rgb = (r * 36 + g * 6 + b) + 16;
printf("\x1b[48;5;%dm %3d", rgb, rgb);
}
int main(int argc, char *argv[])
{
int r, g, b;
printf("\x1b[39m");
printf("\x1b[49m");
printf("\x1b[2J");
printf("\x1b[0;0f");
printf("\n");
for (int r=0; r<6; ++r)
{
printf("R = %d: B= 0, 1, 2, 3, 4, 5\n", r);
for (int g=0; g<6; ++g)
{
printf("G = %d: ", g);
if (g >= 3)
{
printf("\x1b[38;5;00m");
}
for (int b=0; b<6; ++b)
{
printEscapeRgbColor(r, g, b);
}
printf("\x1b[39m");
printf("\x1b[49m");
printf("\n");
}
}
return (0);
}
#include <stdio.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <linux/i2c-dev.h>
#include <pigpio.h>
/*
gcc -o AMG8833 AMG8833.c -lpigpio -lpthread
sudo ./AMG8833
*/
/*
Connect Pi I2C to AMG8833
3V3 - VCC
Ground - Ground
SDA - SDA
SCL - SCL
*/
#define AMG8833_I2C_ADDR 0x68
#define ENABLE_BICUBIC 1
// Temperature vs Color
// DIY Thermal Imaging Camera FREE CODE by Kris Kasprzak
// https://youtu.be/A9F1ezGgaC4?t=2m
#if 0
#define temp_min 20.0f
#define temp_a 25.0f
#define temp_b 30.0f
#define temp_c 33.0f
#define temp_d 50.0f
#define temp_max 80.0f
#else
#define temp_min 26.0f
#define temp_max 36.0f
#define temp_a (temp_min + (temp_max - temp_min) * 0.2121f)
#define temp_b (temp_min + (temp_max - temp_min) * 0.3182f)
#define temp_c (temp_min + (temp_max - temp_min) * 0.4242f)
#define temp_d (temp_min + (temp_max - temp_min) * 0.8182f)
#endif
// array for the 8 x 8 measured pixels
float pixels[64];
// array for the interpolated array
float HDTemp[40][40];
void printTempColor(float temp)
{
int r = 0;
int g = 0;
int b = 255;
if (temp < temp_min)
{
r = 0;
}
else if (temp < temp_a)
{
r = 0;
}
else if (temp < temp_b)
{
r = 0;
}
else if (temp < temp_c)
{
r = (temp - temp_b) * 255.0f / (temp_c - temp_b);
}
else if (temp < temp_d)
{
r = 255;
}
else if (temp < temp_max)
{
r = 255;
}
else
{
r = 255;
}
if (temp < temp_min)
{
g = 0;
}
else if (temp < temp_a)
{
g = (temp - temp_min) * 255.0f / (temp_a - temp_min);
}
else if (temp < temp_b)
{
g = 255;
}
else if (temp < temp_c)
{
g = 255;
}
else if (temp < temp_d)
{
g = (temp_d - temp) * 255.0f / (temp_d - temp_c);
}
else if (temp < temp_max)
{
g = 0;
}
else
{
g = 0;
}
if (temp < temp_min)
{
b = 255;
}
else if (temp < temp_a)
{
b = 255;
}
else if (temp < temp_b)
{
b = (temp_b - temp) * 255.0f / (temp_b - temp_a);
}
else if (temp < temp_c)
{
b = 0;
}
else if (temp < temp_d)
{
b = 0;
}
else if (temp < temp_max)
{
b = (temp - temp_d) * 255.0f / (temp_max - temp_d);
}
else
{
b = 255;
}
// 256 pallete 0x10-0xE7 rgb:0-5
r = (int)(r * 6.0f / 256.0f);
g = (int)(g * 6.0f / 256.0f);
b = (int)(b * 6.0f / 256.0f);
int rgb = (r * 36 + g * 6 + b) + 16;
printf("\x1b[48;5;%dm ", rgb);
}
void InterpolateRows() {
// interpolate the 8 rows (interpolate the 70 column points between the 8 sensor pixels first)
for (int row = 0; row < 8; ++row) {
for (int col = 0; col < 35; ++col) {
// get the first array point, then the next
// also need to bump by 8 for the subsequent rows
int aLow = col / 5 + (row * 8);
int aHigh = (col / 5) + 1 + (row * 8);
// get the amount to interpolate for each of the 10 columns
// here were doing simple linear interpolation mainly to keep performace high and
// display is 5-6-5 color palet so fancy interpolation will get lost in low color depth
float intPoint = (( pixels[aHigh] - pixels[aLow] ) / 5.0f);
// determine how much to bump each column (basically 0-9)
int incr = col % 5;
// find the interpolated value
float val = (intPoint * incr) + pixels[aLow];
// store in the 70 x 70 array
// since display is pointing away, reverse row to transpose row data
HDTemp[(7 - row) * 5][col] = val;
}
}
}
void InterpolateCols() {
// then interpolate the 70 rows between the 8 sensor points
for (int col = 0; col < 35; ++col) {
for (int row = 0; row < 35; ++row) {
// get the first array point, then the next
// also need to bump by 8 for the subsequent cols
int aLow = (row / 5 ) * 5;
int aHigh = aLow + 5;
// get the amount to interpolate for each of the 10 columns
// here were doing simple linear interpolation mainly to keep performace high and
// display is 5-6-5 color palet so fancy interpolation will get lost in low color depth
float intPoint = (( HDTemp[aHigh][col] - HDTemp[aLow][col] ) / 5.0f);
// determine how much to bump each column (basically 0-9)
int incr = row % 5;
// find the interpolated value
float val = (intPoint * incr ) + HDTemp[aLow][col];
// store in the 70 x 70 array
HDTemp[row][col] = val;
}
}
}
void DisplayGradient() {
// rip through 70 rows
for (int row = 0; row < 35; ++row) {
// then rip through each 70 cols
for (int col = 0; col < 35; ++col) {
printTempColor(HDTemp[row][col]);
}
printf("\n");
}
}
int main(int argc, char *argv[])
{
int handle;
if (gpioInitialise() < 0) return 1;
// int i2cOpen(unsigned i2cBus, unsigned i2cAddr, unsigned i2cFlags)
handle = i2cOpen(1, AMG8833_I2C_ADDR, 0);
// int i2cWriteByteData(unsigned handle, unsigned i2cReg, unsigned bVal)
i2cWriteByteData(handle, 0x00, 0x00);
// Sleep 50ms
usleep(100000);
// Initial Reset
i2cWriteByteData(handle, 0x01, 0x3F);
// Sleep 2ms
usleep(100000);
// Flag Reset
i2cWriteByteData(handle, 0x01, 0x30);
// Frame rate 10 fps
i2cWriteByteData(handle, 0x02, 0x00);
// mode Average
i2cWriteByteData(handle, 0x1F, 0x50);
i2cWriteByteData(handle, 0x1F, 0x45);
i2cWriteByteData(handle, 0x1F, 0x57);
// mode Average twice moving average output mode
i2cWriteByteData(handle, 0x07, 0x20);
// mode Average normal
// i2cWriteByteData(handle, 0x07, 0x00);
i2cWriteByteData(handle, 0x1F, 0x00);
// int i2cReadI2CBlockData(unsigned handle, unsigned i2cReg, char *buf, unsigned count)
char buf[128]; // 128 bytes(8 x 8 x Word = 128)
char c;
int temp;
float tempf;
printf("\x1b[2J");
while (1)
{
// Temperature register 0x80-0xFF
i2cReadI2CBlockData(handle, 0x80, &buf[0], 32);
i2cReadI2CBlockData(handle, 0xA0, &buf[32], 32);
i2cReadI2CBlockData(handle, 0xC0, &buf[64], 32);
i2cReadI2CBlockData(handle, 0xE0, &buf[96], 32);
// TTH Thermistor register 0.0625
// TTHL
c = i2cReadByteData(handle, 0x0E);
temp = c;
// TTHH
c = i2cReadByteData(handle, 0x0F);
temp += ((c & 0x07)<<8);
printf("\x1b[49m");
printf("\x1b[0;0f");
printf("Thermistor: %5.2f", temp * 0.0625);
printf("\n");
for (int x=0; x<8; ++x)
{
for (int y=0; y<8; ++y)
{
int idx = ((x<<3)+y)<<1;
int t = ((buf[idx + 1] & 0x07) << 8) + buf[idx];
// printf("%04X ", t);
tempf = (t * 0.25f);
#if ENABLE_BICUBIC
pixels[x*8+y] = tempf;
#else
printTempColor(tempf);
#endif
}
#if ENABLE_BICUBIC
#else
printf("\n");
#endif
}
#if ENABLE_BICUBIC
// now that we have an 8 x 8 sensor array
// interpolate to get a bigger screen
InterpolateRows();
// now that we have row data with 70 columns
// interpolate each of the 70 columns
// forget Arduino..no where near fast enough..Teensy at > 72 mhz is the starting point
InterpolateCols();
// display the 70 x 70 array
DisplayGradient();
#endif
}
i2cClose(handle);
gpioTerminate();
return (0);
}






![]() KKmoon ハンドヘルド サーモグラフィカメラ 熱画像カメラ 赤外線放射温度計 -20〜300°C / -4〜572°F カラースクリーン サーマルカメラ ASIN: B0798N1XH3 |
![]() FLIR(フリアー) サーマルイメージ放射温度計ミニ TG130 ASIN: B01ALSO84E |
![]() 【国内正規品】FLIR(フリアー) ONE for iOS Personal Thermal Imager (iPhone/iPad対応) ASIN: B073RG5SDZ |
![]() 超高性能 携帯型サーモグラフィーカメラ FLIR(フリアー) C2 ★コンパクトサイズ★【並行輸入品】 ASIN: B00T9RANUC |
| 加速度センサ | MMA7455L NXP | 使い方の説明 | 0x1D | (W:0x32 R:0x33) | MMA7455 三軸加速度センサモジュール AQM0802Aと一緒に使えない相性? |
| 地磁気センサ | HMC5883L Honeywell | 使い方の説明 | 0x1E | (W:0x3C R:0x3D) | CJ-M49 デジタルコンパスモジュール 3軸地磁気センサ |
| RFID NFCリーダライタ | NXP PN532 | 使い方の説明 | 0x24 | (W:0x48 R:0x49) | ELECHOUSE NFC MODULE V3 |
| 8ビット I/Oエクスパンダ | PCF8574 Texas Instruments | 使い方の説明 | 0x2F | (W:0x5E R:0x5F) | FC-113 PCF8574 キャラクタ液晶モジュール接続用 |
| キャラクタ液晶 8文字x2行 | 秋月 AQM0802A ST7032 Sitronix | 使い方の説明 | 0x3E | (W:0x7E R:0x7F) | 秋月の AQM0802液晶はラズパイ側の回路が原因の癖が有ります。 MMA7455と一緒に使えない相性? PCA9515AD I2Cバスリピーターとの併用を推奨 |
| キャラクタ液晶モジュール 16文字×2行 | 秋月 AQM1602A ST7032 Sitronix | 使い方の説明 | 0x3E | (W:0x7E R:0x7F) | 秋月の AQM1602A液晶モジュール |
| 湿度センサ | HTU21D TE Connectivity | 使い方の説明 | 0x40 | (W:0x80 R:0x81) | GY-21 温度、湿度センサーモジュール |
| AD/DA変換 | PCF8591 NXP | 使い方の説明 | 0x48 | (W:0x90 R:0x91) | YL-40 8ビットA/D & D/Aコンバータ |
| 温度センサ | LM75A Texas Instruments | 使い方の説明 | 0x4F A0-A2=H | (W:0x9E R:0x9F) | A0~A2を "H"に設定で 0x4F デフォルト 0x48 |
| 3軸加速度センサ | ADXL345 Analog Devices | 使い方の説明 | 0x53 | (W:0xA6 R:0xA7) | GY-291 3軸加速度センサモジュール |
| I2Cメモリ | AT24C32 (4KBメモリ) | 0x57 | (W:0xAE R:0xAF) | ZS-042 下記の RTCモジュールに搭載 | |
| RTC リアルタイムクロック | DS3231 現 Maxim 旧 Dallas Semiconductor | 使い方の説明 | 0x68 | (W:0xD0 R:0xD1) | ZS-042 温度補償水晶発振器(TCXO)および水晶を内蔵する低コスト、 超高精度 I2Cリアルタイムクロック(RTC) |
| 赤外線アレイセンサ | AMG8833 Panasonic | 使い方の説明 | 0x68 | (W:0xD0 R:0xD1) | AMG8833 赤外線アレイセンサ Grid-EYEモジュール サーモグラフィーごっこが可能 |
| 6軸 ジャイロ+加速度センサ | MPU-6050 InvenSense | 使い方の説明 | 0x68 ADO=L | (W:0xD0 R:0xD1) | GY-521 三軸加速度センサ・三軸ジャイロセンサモジュール、 AD0端子 プルアップ時=0x69、 AD0端子 プルダウン時=0x68 |
| 9軸 ジャイロ+加速度+地磁気センサ | MPU-9150 InvenSense | 0x69 | (W:0xD0 R:0xD1) | MPU-6050に地磁気センサーを追加した最強センサー | |
| 9軸 ジャイロ+加速度+地磁気センサ | MPU-9250 InvenSense | 0x69 | (W:0xD0 R:0xD1) | MPU-9150の改良型、3軸加速度 + 3軸ジャイロ + 3軸コンパス | |
| 気圧/気温/高度センサ | BMP180 Bosch Sensortec | 0x77 | (W:0xEE R:0xEF) | BMP085の改良型 | |
| 気圧/温度/高度センサ | BMP280 Bosch Sensortec | 使い方の説明 | 0x76 SDO=L | (W:0xEC R:0xED) | BMP180の改良型、温度・気圧(高度)センサー SDO端子 プルアップ時=0x77、 SDO端子 プルダウン時=0x76 |
| 湿度/気圧/温度/高度センサ | BME280 Bosch Sensortec | 0x76 SDO=L | (W:0xEC R:0xED) | BMP280の進化型、湿度・温度・気圧(高度)の 4種類の環境情報を取得できる(湿度が追加になった) SDO端子 プルアップ時=0x77、 SDO端子 プルダウン時=0x76 | |
| 照度、近接センサ | APDS-9930 Broadcom | 使い方の説明 | 0x39 | (W:0x72 R:0x73) | |
| RGB色センサ、ジェスチャー、照度、近接センサ | APDS-9960 Broadcom | 使い方の説明 | 0x39 | (W:0x72 R:0x73) | |
| RGB色センサ | TCS34725 TAOS | 使い方の説明 | 0x29 | (W:0x52 R:0x53) | |
| 12点 静電タッチセンサ | MPR121 Freescale Semiconductor | 使い方の説明 | 0x5A | (W:0xB4 R:0xB5) | |
| 有機LEDモジュール 128x64 0.96インチ | SSD1306 SOLOMON SYSTECH | 使い方の説明 | 0x3C | (W:0x78 R:0x79) | DC='L'で 0x3C、DC='H'で 0x3D |