Go Down

Topic: Melexis SMBus IR Thermometer - NFI (Read 20 times) previous topic - next topic

Jungorend

Thank you for all the help with connecting the Melexis MLX90614. I have not been getting a response from the device whatsoever. By going through your code, I found that the code never progresses beyond the code line "i2c_start_wait(dev+I2C_WRITE);" I've yet to get a response by the MLX90614 any other method, and I would be very gracious if anyone could help explain to me what I'm doing wrong. Thanks!

Ccalvin

I have been trying to get the i2cmaster.h library to work in my arduino development board with no success.  I renamed the twinmaster.c to a .cpp file and changed the F_CPU definition as well as the SCL_CLOCK . . . However, when I include i2cmaster.h, I am not able to even get a "Hello World" program to work . . . here is some example code:

#include <i2cmaster.h>

void setup(){
Serial.begin(9600);
Serial.println("Hello World!");
i2c_init();
Serial.println("Return from i2c_init");
PORTC = (1 << PORTC4) | (1 << PORTC5);
}

Anyone have any idea why I am not able to println and have something show up on the serial monitor?

Ccalvin

Quote
Make a folder in /{arduino root}/hardware/libraries and extract the
i2cmaster.h and twimaster.c files. Now rename the .c file of twimaster to .cpp (YES I KNOW IT SOUNDS WIERD BUT RENAME AND MAKE SURE THESE FILES ARE IN THE RIGHT LOCATION I.E. IN THE LIBRARIES FOLDER OF THE ARDUINO CODE)


Did you mean /{arduino root}/libraries ?  Because there is no /{arduino root}/hardware/libraries folder . . . only /{arduino root}/hardware/arduino and /{arduino root}/hardware/tools

Neil C

If you have a Arduino MEGA connect the SCL and SDA pins to 20 and 21.

Do not use Analogue pins 4 and 5.

This is just in case there is anyone else out there wondering why there comms isn´t working when the circuit and software is correct.

There must be another idiot like me??? wasted an hour on that.

The info on this thread is fantastic I would like to thank everyone who posted as it saved me a lot of time.

Neil C

nishad

Hey

I have the Melexis 90614ACC (That is the 5v version) of the sensor and i tried to read temp data from it using the i2c master library and dave eatons code as follows:

#include <i2cmaster.h>

void setup()
{
Serial.begin(9600);
Serial.println("Hello!");
i2c_init(); //Initialise the i2c bus
Serial.println("Return from i2c_init");
PORTC = (1 << PORTC4) | (1 << PORTC5);//enable pullups
}
void loop()
{
int dev = 0x5A<<1;
int data_low = 0;
int data_high = 0;
int pec = 0;
i2c_start_wait(dev+I2C_WRITE);
i2c_write(0x07);


i2c_rep_start(dev+I2C_READ);
data_low = i2c_readAck(); //Read 1 byte and then send ack
data_high = i2c_readAck(); //Read 1 byte and then send ack
pec = i2c_readNak();
i2c_stop();

//This converts high and low bytes together and processes temperature, MSB is a error bit and is ignored for temps
double tempFactor = 0.02; // 0.02 degrees per LSB
double tempData = 0x0000;
int frac;

// This masks off the error bit of the high byte, then moves it left 8 bits and adds the low byte.
tempData = (double)(((data_high & 0x007F) << 8) + data_low);
tempData = (tempData * tempFactor)-0.01;
tempData = tempData - 273.15;
Serial.print((int)tempData); //Print temp in degrees C to serial
Serial.print(".");
tempData=tempData-(int)tempData;
frac=tempData*100;
Serial.println(frac);
delay(100);  
}


Is there any reason the code isnt working? i tried using Serial.println to see till what stage the program executes and it stops before

i2c_rep_start(dev+I2C_READ);

doesnt go beyond that
Any ideas?
Also does the 5v version require me to pull-up to 5v or 3.3because thts SMBus spec?
Also the melexis datasheet gives a figure which shows the pin configurations and is labelled "TOP VIEW"
Does that mean it shows the pins coming out of the page or the other way round??
Im confused

Go Up