Giter VIP home page Giter VIP logo

simple-mcp3008's Introduction

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");

simple-mcp3008's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.