Hi! I have changed getInt16 () and getUint16 (xx, true), according to Doc
function DataView.getUint16 (byteOffset, littleEndian)
byteOffset - The offset in bytes to read from
littleEndian - (optional) Whether to read in little endian - if false or undefined data is read as big endian
So now, temperature, pressure and humidity show the same as my Ruuvitag.
Gas resistance is very high so I do not know if it is correct! 12,535,991.64395217411.
If I try with upython on a Wipy, the number is negative.
The next thing I want to try is on a RaspberryPi.
BME680.prototype.get_calib_data = function() {
var coefs = new Uint8Array(C.COEFF_ADDR1_LEN+C.COEFF_ADDR2_LEN);
coefs.set(this.r(C.COEFF_ADDR1,C.COEFF_ADDR1_LEN));
coefs.set(this.r(C.COEFF_ADDR2,C.COEFF_ADDR2_LEN),C.COEFF_ADDR1_LEN);
var vc = new DataView(coefs.buffer);
// everything is little endian
this.cal={};
/* Temperature related coefficients */
this.cal.par_t = [,vc.getUint16(C.T1_LSB_REG, true) // PB
,vc.getInt16(C.T2_LSB_REG, true) // PB
,vc.getInt8(C.T3_REG)];
/* Pressure related coefficients */
this.cal.par_p = [,vc.getUint16(C.P1_LSB_REG, true) // PB
,vc.getInt16(C.P2_LSB_REG, true) // PB
,vc.getInt8(C.P3_REG)
,vc.getInt16(C.P4_LSB_REG, true) // PB
,vc.getInt16(C.P5_LSB_REG, true) // PB
,vc.getInt8(C.P6_REG)
,vc.getInt8(C.P7_REG)
,vc.getInt16(C.P8_LSB_REG, true) // PB
,vc.getInt16(C.P9_LSB_REG, true) // PB
,vc.getUint8(C.P10_REG)];
/* Humidity related coefficients */
this.cal.par_h = [,(vc.getUint8(C.H1_MSB_REG) << C.HUM_REG_SHIFT_VAL) |
(vc.getUint8(C.H1_LSB_REG) & C.BIT_H1_DATA_MSK)
,(vc.getUint8(C.H2_MSB_REG) << C.HUM_REG_SHIFT_VAL) |
(vc.getUint8(C.H2_LSB_REG) >> C.HUM_REG_SHIFT_VAL)
,vc.getInt8(C.H3_REG)
,vc.getInt8(C.H4_REG)
,vc.getInt8(C.H5_REG)
,vc.getUint8(C.H6_REG)
,vc.getInt8(C.H7_REG)];
/* Gas heater related coefficients */
this.cal.par_gh = [,vc.getInt8(C.GH1_REG)
,vc.getInt16(C.GH2_LSB_REG, true) // PB
,vc.getInt8(C.GH3_REG)];
/* Other coefficients */
this.cal.res_heat_range = (this.r(C.ADDR_RES_HEAT_RANGE_ADDR,1)[0]&C.RHRANGE_MSK)/16;
this.cal.res_heat_val = this.r(C.ADDR_RES_HEAT_VAL_ADDR,1)[0];
this.cal.range_sw_err = (this.r(C.ADDR_RANGE_SW_ERR_ADDR,1)[0]&C.RSERROR_MSK)/16;
};
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi! I have changed getInt16 () and getUint16 (xx, true), according to Doc
So now, temperature, pressure and humidity show the same as my Ruuvitag.
Gas resistance is very high so I do not know if it is correct! 12,535,991.64395217411.
If I try with upython on a Wipy, the number is negative.
The next thing I want to try is on a RaspberryPi.