You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • The app note seems like what you need. Specifically:

    int D6T_getvalue()
    {
     I2C_start();
     I2C_send1( 0x14 , 0x4C ); // 14h = { 0Ah(Addr7) : Write(0b) }
     I2C_repeatstart();
     I2C_getx( 0x15 , readbuff , 35 ); // 15h = { 0Ah(Addr7):Read },35 = 2*(1+16)+1
     I2C_stop();
     If(!D6T_checkPEC(readbuff,34)){
     return - 1; // error
     }
     tPTAT = 256*readbuff[1] + readbuff[0];
     tP[0] = 256*readbuff[3] + readbuff[2];
     tP[1] = 256*readbuff[5] + readbuff[4];
     tP[2] = 256*readbuff[7] + readbuff[6];
     tP[3] = 256*re adbuff[9] + readbuff[8];
     tP[4] = 256*readbuff[11] + readbuff[10];
     tP[5] = 256*readbuff[13] + readbuff[12];
     tP[6] = 256*readbuff[15] + readbuff[14];
     tP[7] = 256*readbuff[17] + readbuff[16];
     tP[8] = 256*readbuff[19] + readbuff[18];
     tP[9] = 256*readbuff[21] + readbuff[20];
     tP[10] = 256*readbuff[23] + readbuff[22];
     tP[11] = 256*readbuff[25] + readbuff[24];
     tP[12] = 256*readbuff[27] + readbuff[26];
     tP[13] = 256*readbuff[29] + readbuff[28];
     tP[14] = 256*readbuff[31] + readbuff[30] ;
     tP[15] = 256*readbuff[33] + readbuff[32];
     tPEC = readbuff[34];
     return 1;
    } 
    

    So it looks pretty straightforward - just sending a few bytes down I2C, reading the result back, and converting it to 16 bit. It should just be a few lines.

    Having said that it seems that it might use I2C repeated start, which I'm not sure works on Espruino just yet. There's a bug open for it. It's something I am planning to soon fix though, I'm just a bit short on time right now!

    It may be that it's not needed, but without a module to test with I can't be sure.

About

Avatar for Gordon @Gordon started