johnny-five
Version:
Firmata based Arduino Programming Framework.
85 lines (52 loc) • 1.55 kB
Markdown
Run with:
```bash
node eg/tinkerkit-thermistor.js
```
```javascript
var five = require("johnny-five");
(function() {
var adcres, beta, kelvin, rb, ginf;
adcres = 1023;
// Beta parameter
beta = 3950;
// 0°C = 273.15 K
kelvin = 273.15;
// 10 kOhm
rb = 10000;
// Ginf = 1/Rinf
ginf = 120.6685
global.Thermistor = {
c: function( raw ) {
var rthermistor, tempc;
rthermistor = rb * (adcres / raw - 1);
tempc = beta / ( Math.log( rthermistor * ginf ) );
return tempc - kelvin;
},
f: function( raw ) {
return ( this.c(raw) * 9 ) / 5 + 32;
}
};
}());
new five.Board().on("ready", function() {
new five.Sensor("I0").on("change", function() {
console.log( "F: ", Thermistor.f(this.value) );
console.log( "C: ", Thermistor.c(this.value) );
});
});
```
<img src="https://raw.github.com/rwldrn/johnny-five/master/docs/breadboard/tinkerkit-thermistor.png">
- http://www.tinkerkit.com/thermistor/
- http://www.tinkerkit.com/shield/
_(Nothing yet)_
All contributions must adhere to the [Idiomatic.js Style Guide](https://github.com/rwldrn/idiomatic.js),
by maintaining the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [grunt](https://github.com/cowboy/grunt).
_(Nothing yet)_
Copyright (c) 2012 Rick Waldron <waldron.rick@gmail.com>
Licensed under the MIT license.