herosdevices.hardware.raspberrypi.waveshare

Driver for Waveshare SBC/microcontroller extension boards.

Module Contents

class herosdevices.hardware.raspberrypi.waveshare.WaveshareADS1256(pos_pin: str = 'AIN0', neg_pin: str = 'AINCOM', spi_bus: int = 0, spi_device: int = 0, gain: int = 1, drate: str = '30000SPS', vref: float = 5.0, samples: int = 1)

Bases: herosdevices.interfaces.atomiq.ADCChannel

This class represents one channel of the Waveshare ADS1256 ADC board.

Multiple instances of this class can run in the same interpreter to access multiple channels. The configuration of the ADC will performed by the first instance. This means, gain data rate and reference voltage are only taken from the first instance.

Parameters:
  • posPin – Name of the pin receiving the positive voltage. I.e. AIN0 … AIN7 or AINCOM

  • negPin – Name of the pin receiving the negative voltage. I.e. AIN0 … AIN7 or AINCOM. For non-differential measurements this is usually AINCOM.

  • spi_bus – number of the SPI bus

  • spi_device – number of the SPI device in bus.

  • gain – gain to set in the PGIA

  • drate – conversion rate of the ADS1256. See .ads1256.ADS1256_DRATE for valid values

  • vref – Reference voltage given to the ADC. Usually 3.3V or 5V

  • samples – number of samples to average when sending out measured values as heros datasource

posPin
negPin
gain
drate
vref = 5.0
samples = 1
measure(samples: int = 1, channel: str = '') float

Measure the voltage by averaging multiple ADC samples.

Parameters:
  • samples (int) – Number of samples to average.

  • channel (str) – Not used in this implementation.

Returns:

Measured voltage in volts.

Return type:

float