Hi, All
Any help, please, with porting lib code:
Lib source:
This my code always returns 65535:
Arduino's sketch works OK, returned 15000+ that is calculated later to 30 Celcius degrees...
What is incorrect in B4R code ?
Any help, please, with porting lib code:
Lib source:
B4X:
/*********************************************************************/
uint16_t Adafruit_MLX90614::read16(uint8_t a) {
uint16_t ret;
Wire.beginTransmission(_addr); // start transmission to device
Wire.write(a); // sends register address to read from
Wire.endTransmission(false); // end transmission
Wire.requestFrom(_addr, (size_t)3); // send data n-bytes read
ret = Wire.read(); // receive DATA
ret |= Wire.read() << 8; // receive DATA
uint8_t pec = Wire.read();
return ret;
}
This my code always returns 65535:
B4X:
'Public SlaveAddress As Byte = 0x5A 'I2C address of the chipset.
'Public const MLX90614_TOBJ1 = 0x07
Sub readObjectTempC As Double
wire.WriteTo(SlaveAddress, Array As Byte(MLX90614_TOBJ1))
Dim b() As Byte = wire.RequestFrom(SlaveAddress, 3) '3 bytes
raf.Initialize(b, True)
Dim b3 As UInt = raf.ReadUInt16(0)
Log("b3=", b3)
't = b3 * 0.02 - 273.15
Return t
End Sub
Arduino's sketch works OK, returned 15000+ that is calculated later to 30 Celcius degrees...
What is incorrect in B4R code ?