Adafruit MCP3421 Arduino Library
Public Member Functions | List of all members
Adafruit_MCP3421 Class Reference

Class representing the Adafruit MCP3421 ADC breakout. More...

#include <Adafruit_MCP3421.h>

Public Member Functions

 Adafruit_MCP3421 ()
 Construct a new Adafruit_MCP3421::Adafruit_MCP3421 object. Initialize the I2C device and configuration structure.
 
boolean begin (uint8_t i2c_addr=0x68, TwoWire *wire=&Wire)
 Initialize the MCP3421 sensor. More...
 
void setGain (mcp3421_gain gain)
 Set the gain of the MCP3421. More...
 
mcp3421_gain getGain ()
 Get the current gain setting of the MCP3421. More...
 
void setResolution (mcp3421_resolution res)
 Set the resolution of the MCP3421. More...
 
mcp3421_resolution getResolution ()
 Get the current resolution setting of the MCP3421. More...
 
void setMode (mcp3421_mode mode)
 Set the operational mode of the MCP3421. More...
 
mcp3421_mode getMode ()
 Get the current operational mode of the MCP3421. More...
 
bool isReady ()
 Check if the MCP3421 has completed a conversion, can be used in continuous or one-shot mode. More...
 
bool startOneShotConversion ()
 Start a one-shot conversion on the MCP3421. More...
 
int32_t readADC ()
 Read the ADC value from MCP3421. More...
 

Detailed Description

Class representing the Adafruit MCP3421 ADC breakout.

Member Function Documentation

◆ begin()

boolean Adafruit_MCP3421::begin ( uint8_t  i2c_addr = 0x68,
TwoWire *  wire = &Wire 
)

Initialize the MCP3421 sensor.

Parameters
i2c_addrThe I2C address of the sensor.
wireThe I2C interface to use.
Returns
true if initialization is successful, false otherwise.

◆ setGain()

void Adafruit_MCP3421::setGain ( mcp3421_gain  gain)

Set the gain of the MCP3421.

Parameters
gainThe gain setting.

◆ getGain()

mcp3421_gain Adafruit_MCP3421::getGain ( )

Get the current gain setting of the MCP3421.

Returns
mcp3421_gain The current gain setting.

◆ setResolution()

void Adafruit_MCP3421::setResolution ( mcp3421_resolution  res)

Set the resolution of the MCP3421.

Parameters
resThe resolution setting.

◆ getResolution()

mcp3421_resolution Adafruit_MCP3421::getResolution ( )

Get the current resolution setting of the MCP3421.

Returns
mcp3421_resolution The current resolution setting.

◆ setMode()

void Adafruit_MCP3421::setMode ( mcp3421_mode  mode)

Set the operational mode of the MCP3421.

Parameters
modeThe operational mode.

◆ getMode()

mcp3421_mode Adafruit_MCP3421::getMode ( )

Get the current operational mode of the MCP3421.

Returns
mcp3421_mode The current operational mode.

◆ isReady()

bool Adafruit_MCP3421::isReady ( )

Check if the MCP3421 has completed a conversion, can be used in continuous or one-shot mode.

Returns
true if conversion is complete, false otherwise.

◆ startOneShotConversion()

bool Adafruit_MCP3421::startOneShotConversion ( )

Start a one-shot conversion on the MCP3421.

Returns
true if the I2C write is successful, false otherwise.

◆ readADC()

int32_t Adafruit_MCP3421::readADC ( )

Read the ADC value from MCP3421.

Returns
int32_t The ADC value as a differential reading.

The documentation for this class was generated from the following files: