Hello,
I started with arduino a few days aago, but and i want to learn more :P.
I connected an tc74 temperature sensor on arduino, wrote the code, but the programm don't do nothing.
TC74A0:
i think the address is 0x48
CODE:
i saw this code on a toturial that include an i2c device and made some modifications, i made some prints to see where the problem is and the program just print 123
#include "Wire.h"
void setup()
{
Wire.begin(0x4D); // wake up I2C bus Serial.begin(9600);
Serial.begin(9600);
}
void getCN75data(byte *a)
{
Serial.print(1);
// move the register pointer back to the first register
Wire.beginTransmission(0x4D); // "Hey, CN75 @ 0x48! Message for you"
Serial.print(2);
Wire.send(0); // "move your register pointer back to 00h"
Serial.print(3);
Wire.endTransmission(); // "Thanks, goodbye..."
// now get the data from the CN75
Serial.print(4);
Wire.requestFrom(0x4D, 1); // "Hey, CN75 @ 0x48 - please send me the contents of your first two registers"
Serial.print(5);
*a = Wire.receive(); // first received byte stored here
Serial.print(6);
}
void showCN75data()
{
float temperature=0;
byte aa;
getCN75data(&aa);
if (aa>127) // check for below zero degrees
{
temperature=((aa-128)*-1);
} else // it must be above zero degrees
{
temperature=aa;
}
Serial.print("Temperature = ");
Serial.print(temperature,1);
Serial.println(" degrees C");
delay(1000);
}
void loop()
{
showCN75data();
}
Please help, sorry about my english :S
Thanks in advance