Forgot your password?
No account? Register one!
January 9, 2012
Product SEN-09570 |
about 10 months ago
I really wanted to use this sensor with a Teensy 3.0 (ARM based) board, but all the working code I could find uses the i2cmaster library and is dependent on the microcontroller being AVR based. I never used I2C before this project so I still can’t get it to run in PWM mode, but I did manage to get the sensor to communicate successfully using Wire.h included in Arduino 1.0.5 and print a readable temperature using some code from the bildr tutorial. I hope this will be of help to someone.
#define LED_pin 13
#define slaveAddress 0x00
// An LED will blink to indicate when we have successfully read the temperature
// Store the two relevant bytes of data for temperature
byte dataLow = 0x00;
byte dataHigh = 0x00;
Wire.write(0x07); // This is the command to view object temperature in the sensor's RAM
dataLow = Wire.read();
dataHigh = Wire.read();
digitalWrite(13, HIGH); // Blink the LED to indicate a successful reading
double tempFactor = 0.02; // 0.02 degrees per LSB (measurement resolution of the MLX90614)
double tempData = 0x0000; // zero out the data
int frac; // data past the decimal point
// This masks off the error bit of the high byte, then moves it left 8 bits and adds the low byte.
tempData = (double)(((dataHigh & 0x007F)
tempData = (tempData * tempFactor)-0.01;
float celcius = tempData - 273.15;
float fahrenheit = (celcius*1.8) + 32;
No public wish lists :(