2.1.1 • Published 4 days ago

@iiot2k/mcp3424 v2.1.1

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
4 days ago

@iiot2k/mcp3424

platform

mcp3424 analog to digital converter library

Installation

npm install @iiot2k/mcp3424

or add in your package.json:

"dependencies": {
    "@iiot2k/mcp3424": "latest"
},

View on npm View on GitHub

mcp3424 18bit analog to digital converter

  • 12..18bit Conversion Resolution.
  • Four Analog Inputs.
  • Internal Voltage Reference.
  • Internal Oscillator.
  • Programmable Resolution with Data Rate 3.75 SPS (18bits) to 240 SPS (12bits).
  • The PGA offers input ranges from ±256 mV to ±2048 V.
  • I2C Interface with eight Pin-Selectable Addresses.
  • Works also for mcp3421..mcp3428

Usage

  • This library works on Raspberry Pi with 32bit or 64bit OS.
  • The output value is mV or adc raw data.
  • Enable I2C with raspi-config.
  • In this case i2c-1 is enabled (port=1).
  • If you use i2c-0 port add dtparam=i2c_vc=on to /boot/config.txt, then Pin27=SDA, Pin28=SCK.
  • For other ports add this to /boot/config.txt.

API

API functions are explained in documents API.md

C++ libraries and examples

Report any issues here

Address Pin Connection

I2C AddressADR0 PinADR1 Pin
68HOpenOpen
68HGNDGND
69HGNDOpen
6AHGNDVCC
6BHVCCGND
6CHVCCOpen
6DHVCCVCC
6EHOpenGND
6FHOpenVCC

Supported Devices

Type# ChannelMax. Resol.Address-Range
mcp3421118bit68H
mcp3422218bit68H
mcp3423218bit68H-6FH
mcp3424418bit68H-6FH
mcp3425116bit68H
mcp3426216bit68H
mcp3427216bit68H-6FH
mcp3428416bit68H-6FH

Example

// example reads single adc input
"use strict";

const mcp3424 = require("@iiot2k/mcp3424");

mcp3424.read(
    1, // i2c-1
    mcp3424.ADR_68, // address 0x68
    mcp3424.CH_1, // CH1
    mcp3424.AI_12BIT, // 12 bit res.
    mcp3424.GAIN_2048, // 2048mV input
    false, // no rawdata
    function(data) {
        if (data === undefined)
            console.log(ads1115.error_text());
        else
            console.log(data, "mV");
    });

Examples are on examples folder.