The only problem with including trtn.temp and trtn.fault in the same variable is the way the chip works. It supplies a 14 bit word that has temperature and fault information. Therefore when the fault flag is raised it still gives a temperature, just the wrong temperature. I included the if else statement in the earlier code to account for this. Maybe someone can suggest a way to accomplish with the trtn.temp and trtn.falut included in the same variable.
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.
I tried out the code and it sort of works!
The only problem with including trtn.temp and trtn.fault in the same variable is the way the chip works. It supplies a 14 bit word that has temperature and fault information. Therefore when the fault flag is raised it still gives a temperature, just the wrong temperature. I included the if else statement in the earlier code to account for this. Maybe someone can suggest a way to accomplish with the trtn.temp and trtn.falut included in the same variable.
{"temp":2047.75,"fault":1,
"faultstring":"No probe detected"
}
see the example above where no probe is detected yet the temperature is reported back as 2047.75C.
Ideally I think what is needed for simple example temperature measurement is the correct temperature or the fault condition.