herosdevices.hardware.raspberrypi.waveshare¶
Driver for Waveshare SBC/microcontroller extension boards.
Module Contents¶
- class herosdevices.hardware.raspberrypi.waveshare.WaveshareADS1256(spi_bus: int = 0, spi_device: int = 0, rst_pin: int = 18, drdy_pin: int = 17, gain: int = 1, drate: str = '2000SPS', vref: float = 5.0, channel_name_map: dict[str, str] | None = None)[source]¶
Bases:
herosdevices.interfaces.atomiq.ADCThis class represents one channel of the Waveshare ADS1256 ADC board.
Note
Concurrent access to the SPI device is not possible. This means only one object with a given spi_bus and spi_device can exist.
If you would like to access individual channels of this ADC consider creating objects of :class:WaveshareADS1256Channel in addition to an object of this class.
- Parameters:
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
channel_name_map – dict to map the internal names of the pin (AIN0…AIN7) to user-definable names. The names are used if the operated as HEROS datasource. Example: {“AIN0”: “my_voltage”, “AIN2”: “custom_sensor_3”}
- gain¶
- drate¶
- vref = 5.0¶
- channel_name_map¶
- channel_name_map_reverse¶
- get_samples(samples: int = 1, channel: str = '', neg_pin: str = 'AINCOM') → list[float][source]¶
Measure the given number of samples from the given channel.
- Parameters:
samples (int) – Number of samples.
channel (str) – Name of the pin where the positive end of the voltage is applied
neg_pin (str) – Name of the pin where the negative end of the voltage is applied
- Returns:
Measured voltage in volts.
- Return type:
float
- measure(samples: int = 1, channel: str = '', neg_pin: str = 'AINCOM') → float[source]¶
Measure the voltage by averaging multiple ADC samples.
- Parameters:
samples (int) – Number of samples to average.
channel (str) – Name of the pin where the positive end of the voltage is applied
neg_pin (str) – Name of the pin where the negative end of the voltage is applied
- Returns:
Measured voltage in volts.
- Return type:
float
- class herosdevices.hardware.raspberrypi.waveshare.WaveshareADS1256Channel(waveshare_ads1256: WaveshareADS1256, pos_pin: str, neg_pin: str = 'AINCOM', samples: int = 1)[source]¶
Bases:
herosdevices.interfaces.atomiq.ADCChannelA Single Channel of the Waveshare ADS1256 ADC board.
- Parameters:
waveshare_ads1256 – Object or HERO of class WaveshareADS1256
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.
- adc¶
- pos_pin¶
- neg_pin = 'AINCOM'¶
- samples = 1¶