Thermal IR-Camera: Difference between revisions
Jump to navigation
Jump to search
(Created page with "320px") |
No edit summary |
||
| Line 1: | Line 1: | ||
[[File:ThermalCam_PD.png|320px]] | [[File:ThermalCam_PD.png|320px]] | ||
=== Parts === | |||
=== Arduino === | |||
The Arduino Code | |||
<syntaxhighlight lang="c"> | |||
#include <Wire.h> | |||
void setup() | |||
{ | |||
Wire.begin(); // join i2c bus (address optional for master) | |||
Serial.begin(9600); // start serial communication at 9600bps | |||
} | |||
int reading = 0; | |||
int count=0; | |||
char buf[3]; | |||
void loop() | |||
{ | |||
// step 3: instruct sensor to return a particular echo reading | |||
Wire.beginTransmission(0x0a); | |||
Wire.write(byte(0x4c)); // sets register pointer to echo #1 register (0x02) | |||
Wire.endTransmission(false); // stop transmitting | |||
// step 4: request reading from sensor | |||
Wire.requestFrom(0x0a, 32); // request 2 bytes from slave device #112 | |||
// step 5: receive reading from sensor | |||
count=0; | |||
while(count<32) | |||
{ | |||
if(2 <= Wire.available()) // if two bytes were received | |||
{ | |||
reading = Wire.read(); // receive high byte (overwrites previous reading) | |||
reading+= Wire.read()<<8; | |||
Serial.print(reading); // print the reading | |||
Serial.print(" "); | |||
count+=2; | |||
} | |||
} | |||
//while(Wire.available()<1); | |||
//reading = Wire.read(); | |||
Serial.println(); | |||
} | |||
</syntaxhighlight> | |||
=== PD === | |||
Revision as of 16:59, 17 September 2013
Parts
Arduino
The Arduino Code
#include <Wire.h>
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial communication at 9600bps
}
int reading = 0;
int count=0;
char buf[3];
void loop()
{
// step 3: instruct sensor to return a particular echo reading
Wire.beginTransmission(0x0a);
Wire.write(byte(0x4c)); // sets register pointer to echo #1 register (0x02)
Wire.endTransmission(false); // stop transmitting
// step 4: request reading from sensor
Wire.requestFrom(0x0a, 32); // request 2 bytes from slave device #112
// step 5: receive reading from sensor
count=0;
while(count<32)
{
if(2 <= Wire.available()) // if two bytes were received
{
reading = Wire.read(); // receive high byte (overwrites previous reading)
reading+= Wire.read()<<8;
Serial.print(reading); // print the reading
Serial.print(" ");
count+=2;
}
}
//while(Wire.available()<1);
//reading = Wire.read();
Serial.println();
}