++ed by:
SREZIC CREDO BINJOY
1 non-PAUSE user
Author image Gligan Calin Horea
and 1 contributors

NAME

RPi::PIGPIO::Device::ADC::MCP300x - access the ADC convertor MCP3004 or MCP3008

DESCRIPTION

Communicate with the MCP3004 or MCP3008 analog-to-digital convertors

This convertors offer 10 bit conversions (range 0-1023) for 4 or 8 chanels

Comunication is done via harware SPI so MAKE SURE YOU ENABLED SPI on your RPi (use raspi-config command and go to "Advanced")

See https://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus

SYNOPSIS

    use feature 'say';
    use RPi::PIGPIO;
    use RPi::PIGPIO::Device::ADC::MCP300x;

    my $pi = RPi::PIGPIO->connect('192.168.1.10');

    my $mcp = RPi::PIGPIO::Device::ADC::MCP300x->new(0);

    say "Sensor 1: " .$mcp->read(0);
    say "Sensor 2: " .$mcp->read(1);

METHODS

new

Create a new object

Usage:

    my $mcp = RPi::PIGPIO::Device::ADC::MCP300x->new(0);

Arguments: $pi - an instance of RPi::PIGPIO $spi_channel - SPI channel from which you want to read (0 or 1 corresponding to SPI CE0 / GPIO8 or SPI CE1 / GPIO 7) $baud - clock speed for SPI communication (optional, defaults to 32K)

read

Read the value for a sensor connected to MCP3004 or MCP3008

Usage :

    my $value = $mcp->read(0);