function HP03S(option, onReady) {

    // Datasheet says "delay for 40ms minimum", but results are unstable
    // with 50ms → stable results
    this.WAIT_FOR_RESULT_MILLISECONDS = 50;

    // Check wiring parameters
    if (!option.i2c || !option.mclk || !option.xclr) {
        throw new Error("Missing i2c, mclk oder xclr configuration");
    }

    this.i2c = option.i2c;
    this.xclr = option.xclr;

    // 32 kHz output → MCLK; allowed frequency ：30K---35K
    analogWrite(option.mclk, 0.5, { freq: 32768 });

    digitalWrite(option.xclr, 0); // XCLR = 0

    // Read compensation coefficients - like 24C02
    var i2cAddress = 0x50;
    this.i2c.writeTo(i2cAddress, 16); // 16..EEPROM ADDRESS
    var d = this.i2c.readFrom(i2cAddress, 18); // 18 - count of bytes

    var C1 = d[0] << 8 | d[1]; // Sensitivity coefficient
    var C2 = d[2] << 8 | d[3]; // // Offset coefficient
    var C3 = d[4] << 8 | d[5]; // Temperature Coefficient of Sensitivity
    var C4 = d[6] << 8 | d[7]; // Temperature Coefficient of Offset
    this.C5 = d[8] << 8 | d[9]; // Reference Temperature
    var C6 = d[10] << 8 | d[11]; // Temperature Coefficient of Temperature
    var C7 = d[12] << 8 | d[13]; // Offset Fine Tuning

    // Precalculate coefficients
    this.m1 = (C6 / (1 << 16) - 1 / (1 << d[17])) / 10;
    var cTemp = 1 << (14 + d[16]);
    this.m2 = d[14] / cTemp;
    this.m3 = d[15] / cTemp;
    this.m4 = 25 / (1 << 17) * C1;
    this.m5 = 25 / (1 << 27) * C3;
    this.m6 = -175 / (1 << 17) * C3 - 25 / 32768 * C4 + 25 / 32;
    this.m7 = 10 * C7 - 12.5 * C2 - 175 / 128 * C1;

    // After first power on, the first read data should be disregarded, and only the second value
    // should be used. This can assure that any unstable data after reset can be filtered out.
    this.getPressure(function () { return onReady && onReady(); });
}
/**
 * Creates a new HP03S sensor instance
 * @constructor
 */
Creates a new HP03S sensor instance
@constructor
Creates a new HP03S sensor instance @constructor
function HP03S(option, onReady) {
    this.WAIT_FOR_RESULT_MILLISECONDS = 50;
    if (!option.i2c || !option.mclk || !option.xclr) {
        throw new Error("Missing i2c, mclk oder xclr configuration");
    }
    this.i2c = option.i2c;
    this.xclr = option.xclr;
    analogWrite(option.mclk, 0.5, { freq: 32768 });
    digitalWrite(option.xclr, 0); 
    var i2cAddress = 0x50;
    this.i2c.writeTo(i2cAddress, 16); 
    var d = this.i2c.readFrom(i2cAddress, 18); 
    var C1 = d[0] << 8 | d[1]; 
    var C2 = d[2] << 8 | d[3]; 
    var C3 = d[4] << 8 | d[5]; 
    var C4 = d[6] << 8 | d[7]; 
    this.C5 = d[8] << 8 | d[9]; 
    var C6 = d[10] << 8 | d[11]; 
    var C7 = d[12] << 8 | d[13]; 
    this.m1 = (C6 / (1 << 16) - 1 / (1 << d[17])) / 10;
    var cTemp = 1 << (14 + d[16]);
    this.m2 = d[14] / cTemp;
    this.m3 = d[15] / cTemp;
    this.m4 = 25 / (1 << 17) * C1;
    this.m5 = 25 / (1 << 27) * C3;
    this.m6 = -175 / (1 << 17) * C3 - 25 / 32768 * C4 + 25 / 32;
    this.m7 = 10 * C7 - 12.5 * C2 - 175 / 128 * C1;
    this.getPressure(function () { return onReady && onReady(); });
}
function HP03S ( option , onReady ) { this . WAIT_FOR_RESULT_MILLISECONDS = 50 ; if ( ! option . i2c || ! option . mclk || ! option . xclr ) { throw new Error ( "Missing i2c, mclk oder xclr configuration" ) ; } this . i2c = option . i2c ; this . xclr = option . xclr ; analogWrite ( option . mclk , 0.5 , { freq : 32768 } ) ; digitalWrite ( option . xclr , 0 ) ; var i2cAddress = 0x50 ; this . i2c . writeTo ( i2cAddress , 16 ) ; var d = this . i2c . readFrom ( i2cAddress , 18 ) ; var C1 = d [ 0 ] << 8 | d [ 1 ] ; var C2 = d [ 2 ] << 8 | d [ 3 ] ; var C3 = d [ 4 ] << 8 | d [ 5 ] ; var C4 = d [ 6 ] << 8 | d [ 7 ] ; this . C5 = d [ 8 ] << 8 | d [ 9 ] ; var C6 = d [ 10 ] << 8 | d [ 11 ] ; var C7 = d [ 12 ] << 8 | d [ 13 ] ; this . m1 = ( C6 / ( 1 << 16 ) - 1 / ( 1 << d [ 17 ] ) ) / 10 ; var cTemp = 1 << ( 14 + d [ 16 ] ) ; this . m2 = d [ 14 ] / cTemp ; this . m3 = d [ 15 ] / cTemp ; this . m4 = 25 / ( 1 << 17 ) * C1 ; this . m5 = 25 / ( 1 << 27 ) * C3 ; this . m6 = - 175 / ( 1 << 17 ) * C3 - 25 / 32768 * C4 + 25 / 32 ; this . m7 = 10 * C7 - 12.5 * C2 - 175 / 128 * C1 ; this . getPressure ( function ( ) { return onReady && onReady ( ) ; } ) ; }
Creates a new HP03S sensor instance
 @constructor
Creates a new HP03S sensor instance @constructor
// Datasheet says "delay for 40ms minimum", but results are unstable // with 50ms → stable results // Check wiring parameters // 32 kHz output → MCLK; allowed frequency ：30K---35K // XCLR = 0 // Read compensation coefficients - like 24C02 // 16..EEPROM ADDRESS // 18 - count of bytes // Sensitivity coefficient // // Offset coefficient // Temperature Coefficient of Sensitivity // Temperature Coefficient of Offset // Reference Temperature // Temperature Coefficient of Temperature // Offset Fine Tuning // Precalculate coefficients // After first power on, the first read data should be disregarded, and only the second value // should be used. This can assure that any unstable data after reset can be filtered out.