How to use the mcp-spi-adc.openMcp3204 function in mcp-spi-adc

To help you get started, we’ve selected a few mcp-spi-adc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-red / node-red-nodes / hardware / mcp3008 / pimcp3008.js View on Github external
this.bus = parseInt(n.bus || 0);
        this.dev = n.dev || "3008";
        var node = this;
        var cb = function (err) { if (err) { node.error("Error: "+err); } };
        var opt = { speedHz:20000, deviceNumber:node.dnum, busNumber:node.bus };
        var chans = parseInt(this.dev.substr(3));

        try {
            fs.statSync("/dev/spidev"+node.bus+"."+node.dnum);
            if (mcp3xxx.length === 0) {
                for (var i=0; i= 0) && (pay < chans)) { pin = pay; }
                    else { node.warn("Payload needs to select channel 0 to "+(chans-1)); }
                }
                else { pin = parseInt(node.pin); }
                if (pin !== null) {
                    mcp3xxx[pin].read(function (err, reading) {
                        if (err) { node.warn("Read error: "+err); }
                        else { node.send({payload:reading.rawValue, topic:"adc/"+pin}); }

mcp-spi-adc

MCP3002/4/8, MCP3202/4/8 and MCP3304 SPI analog to digital conversion

MIT
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis