Skip to content
This repository has been archived by the owner on Jul 1, 2018. It is now read-only.
/ simple-mcp3008 Public archive

MCP 3008 SPI analog to digital conversion with Node.js on raspberry boards.

License

Notifications You must be signed in to change notification settings

toliger/simple-mcp3008

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-mcp3008

MCP 3008 SPI analog to digital conversion with Node.js on raspberry boards.

npm package

Contents

Installation

npm install simple-mcp3008

Usage

// (SPICLK, SPIMISO, SPIMOSI, SPICS, Voltage)
var mcp = require('simple-mcp3008')(18,24,4,25,3.3);

for(var i = 0; i < 8; i++){
	console.log("pin #" + i + " = " + mcp.pins[i].getDecimalValue() + "/1024");
}
var mcp = require('simple-mcp3008')(18,24,4,25,3.3);
var temp_pin = mcp.pins[0];

/* MJSTS-103-3950-1-600-3D  [celcius degre, ohm]*/
var temp_sensor_resistances = [[-30, 173755],[-29, 163652.4],[-20, 97420.46],[-10, 55801.49],[0, 32997.68],[10, 20068.96],[20, 12513.07],[30, 8070.342],[40, 5320.219],[50, 3583.472],[60, 2490.09]];

console.log("pin value = " + temp_pin.getDecimalValue() + "/1024");
console.log("pin #0 voltage = " + temp_pin.getVoltage());

console.log("Define type + constant resistance to pin 0");
temp_pin.setType("temp");
temp_pin.setConstantResistance(10000 - 5000);

console.log("constant resistance = " + temp_pin.resistance);
console.log("New voltage = " + temp_pin.getVoltage() + " V");
console.log("Sensor resistance = " + temp_pin.getSensorResistance() + " Ohm");

temp_pin.setResistanceTab(temp_sensor_resistances);
console.log("temp = " + temp_pin.getCelciusDegre() + " °C");

About

MCP 3008 SPI analog to digital conversion with Node.js on raspberry boards.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published