Dear All,
Seeking some help to interpret couple of syntax expressions used in program and failing. The
*a = Wire.read(); is used to capture data from sensor, via I2C-bus. What i cant understand what does the * multiplication sigh in front mean?
Also what is unclear for me, where does &aa, and &bb come from in expression getCN75data(&aa,&bb); and why does the bitwise ANDing done here?
Any help highly appreciated here.
:)))
The hole code is site here:
void setup()
{
Wire.begin(); // wake up I2C bus
Serial.begin(9600);
}
void getCN75data(byte *a, byte *b)
{
// move the register pointer back to the first register
Wire.beginTransmission(cn75address); // "Hey, CN75 @ 0x48! Message for you"
Wire.write(0); // "move your register pointer back to 00h"
Wire.endTransmission(); // "Thanks, goodbye..."
// now get the data from the CN75
Wire.requestFrom(cn75address, 2); // "Hey, CN75 @ 0x48 - please send me the contents of your first two registers"
*a = Wire.read(); // first received byte stored here
*b = Wire.read(); // second received byte stored here
}
void showCN75data()
{
byte aa,bb;
float temperature=0;
getCN75data(&aa,&bb);
if (aa>127) // check for below zero degrees
{
temperature=((aa-128)*-1);
if (bb==128) // check for 0.5 fraction
{
temperature-=0.5;
}
}
else // it must be above zero degrees
{
temperature=aa;
if (bb==128) // check for 0.5 fraction
{
temperature+=0.5;
}
}
Serial.print("Temperature = ");
Serial.print(temperature,1);
Serial.println(" degrees C");
delay(1000);
}
void loop()
{
showCN75data();
}