pyupm_adc121c021 module¶
-
class
pyupm_adc121c021.
ADC121C021
(bus, address=85, vref=3.0)[source]¶ Bases:
object
API for the ADC121C021 I2C Analog-to-Digital Converter.
ID: adc121c021
Name: I2C 12-bit Analog to Digital Converter with Alert Pin
Other Names: Grove I2C ADC
Category: electric
Manufacturer: seeed
Link:http://www.seeedstudio.com/depot/Grove-I2C-ADC-p-1580.html
Connection: i2c UPM module for the ADC121C021 12-bit analog-to- digital converter (ADC). By constantly providing a reference voltage, this sensor helps increase the accuracy of a value collected from an analog sensor.
C++ includes: adc121c021.hpp
-
alertHighTriggered
()[source]¶ bool alertHighTriggered()
Returns the current value of m_alertHigh. You must call getAlertStatus() to update this value.
Current status of the alert high flag
-
alertLowTriggered
()[source]¶ bool alertLowTriggered()
Returns the current value of m_alertLow. You must call getAlertStatus() to update this value.
Current status of the alert low flag
-
clearAlertStatus
()[source]¶ void clearAlertStatus()
Clears the alert low and alert high flags. This also clears the last stored alert values.
-
clearHighestConversion
()[source]¶ mraa_result_t clearHighestConversion()
Clears the highest conversion value recorded so far.
0 (MRAA_SUCCESS) if successful; non-zero otherwise
-
clearLowestConversion
()[source]¶ mraa_result_t clearLowestConversion()
Clears the lowest conversion value recorded so far.
0 (MRAA_SUCCESS) if successful; non-zero otherwise
-
enableAlertFlag
(enable)[source]¶ void enableAlertFlag(bool enable)
Enables or disables the alert flag functionality. If enabled, when the measured value exceeds the low or high limits configured, the alert flag is set. Use getAlertStatus() to access these values.
enable: If true, enables the alert flag; otherwise, disables the alert flag
-
enableAlertHold
(enable)[source]¶ void enableAlertHold(bool enable)
Enables or disables the alert hold functionality. When the alert hold is enabled, the alert status remains until manually cleared via clearAlertStatus(). Otherwise, the alert self-clears when the value moves into the defined limits if alerts are enabled via enableAlertFlag().
enable: If true, enables the alert hold; otherwise, disables the alert hold
-
enableAlertPin
(enable)[source]¶ void enableAlertPin(bool enable)
Enables or disables the alert pin functionality.
enable: If true, enables the alert pin; otherwise, disables the alert pin
-
enableAlertPinPolarityHigh
(enable)[source]¶ void enableAlertPinPolarityHigh(bool enable)
If the alert pin is enabled, defines the active polarity of the pin in an alert condition. Enabling this sets the pin to active high in an alert condition; otherwise, active low is used.
enable: If true, the alert pin is active high; otherwise, active low
-
getAlertStatus
()[source]¶ bool getAlertStatus()
Reads the current status of the alert flag. If the flag is set, the low or high alert indicators are set as appropriate, and you can access these values with alertLowTriggered() or alertHighTriggered().
True if the alert flag is set
-
getHighestConversion
()[source]¶ uint16_t getHighestConversion()
Returns the highest conversion value recorded so far. This value is only updated by the converter when the automatic conversion mode is enabled.
Highest conversion value
-
getLowestConversion
()[source]¶ uint16_t getLowestConversion()
Returns the lowest conversion value recorded so far. This value is only updated by the converter when the automatic conversion mode is enabled.
Lowest conversion value
-
readByte
(reg)[source]¶ uint8_t readByte(uint8_t reg)
Reads the byte value from the register
reg: Register location to read from
Value in the specified register
-
readWord
(reg)[source]¶ uint16_t readWord(uint8_t reg)
Reads the word value from the register
reg: Register location to read from
Value in the specified register
-
setAlertHighLimit
(limit)[source]¶ mraa_result_t setAlertHighLimit(uint16_t limit)
Sets the alert high limit. If alerts are enabled and the measured conversion value is higher than the high limit, an alert is triggered.
limit: Alert high limit
0 (MRAA_SUCCESS) if successful; non-zero otherwise
-
setAlertLowLimit
(limit)[source]¶ mraa_result_t setAlertLowLimit(uint16_t limit)
Sets the alert low limit. If alerts are enabled and the measured conversion value is lower than the low limit, an alert is triggered.
limit: Alert low limit
0 (MRAA_SUCCESS) if successful; non-zero otherwise
-
setAutomaticConversion
(cycleTime)[source]¶ void setAutomaticConversion(ADC121C021_CYCLE_TIME_T cycleTime)
Enables or disables the automatic conversion mode. When enabled, the ADC samples and updates the conversion value independently. It is disabled by default, so conversion is only done by calling value().
cycleTime: Sets the cycle time for automatic conversion
-
setHysteresis
(limit)[source]¶ mraa_result_t setHysteresis(uint16_t limit)
Sets the hysteresis value. If a high or low alert condition is triggered, the conversion result must move within the high or low limit by more than this value to clear the alert condition. If the alert hold is set, the alert doesn’t self-clear regardless of this value.
limit: Hysteresis limit
0 (MRAA_SUCCESS) if successful; non-zero otherwise
-
valueToVolts
(val)[source]¶ float valueToVolts(uint16_t val)
Converts a supplied value to voltage based on the set vref
val: Value of conversion (from value())
Value of conversion in volts
-