def __init__(self):
     threading.Thread.__init__(self)
     self.daemon = True
     self.adc = ADS1015()
     self.channel = 0
     self.percentage = 0
     self.start()
Ejemplo n.º 2
0
 def __init__(self):
     self.address = 0x74  #Fixed i2c PCA9539 address
     self.i2c = machine.I2C(sda=machine.Pin(14), scl=machine.Pin(27))
     self.i2c.start()
     #start condition for i2c
     self.adc_ = ADS1015(
         machine.I2C(sda=machine.Pin(14), scl=machine.Pin(27)),
         72)  # ADS1015 is at i2c address 72
Ejemplo n.º 3
0
def ready_check():
    adc = ADS1015()

    counter = 0
    for _ in range(30):
        values = [0] * 4
        for i in range(4):
            values[i] = adc.read_adc(i, gain=1)

        measures = values[2]

        if measures <= 1400:
            counter += 1

        time.sleep(0.05)

    if counter <= 5:
        return True
    else:
        return False
Ejemplo n.º 4
0
# Simple demo of continuous ADC conversion mode for channel 0 of the ADS1x15 ADC.
# Author: Tony DiCola
# License: Public Domain
import time

# Import the ADS1x15 module.
from ADS1x15 import ADS1015

# Create an ADS1115 ADC (16-bit) instance.
# adc = ADS1115()

# Or create an ADS1015 ADC (12-bit) instance.
adc = ADS1015()

# Note you can change the I2C address from its default (0x48), and/or the I2C
# bus by passing in these optional parameters:
#adc = ADS1015(address=0x49, busnum=1)

# Choose a gain of 1 for reading voltages from 0 to 4.09V.
# Or pick a different gain to change the range of voltages that are read:
#  - 2/3 = +/-6.144V
#  -   1 = +/-4.096V
#  -   2 = +/-2.048V
#  -   4 = +/-1.024V
#  -   8 = +/-0.512V
#  -  16 = +/-0.256V
# See table 3 in the ADS1015/ADS1115 datasheet for more info on gain.
GAIN = 1

# Start continuous ADC conversions on channel 0 using the previously set gain
# value.  Note you can also pass an optional data_rate parameter, see the simpletest.py