def __init__(self, parent=None): super(Worker, self).__init__(parent) self.runFlag = False self.i2c = busio.I2C(board.SCL, board.SDA) self.adc = ADS1115(self.i2c) GPIO.setmode(GPIO.BCM) GPIO.setup(self.Relay_1, GPIO.OUT) GPIO.output(self.Relay_1, GPIO.HIGH) GPIO.output(self.Relay_1, GPIO.LOW)
import time import board import busio import matplotlib.pyplot as plt import numpy as np from adafruit_ads1x15.single_ended import ADS1115 f = open('air.csv', 'a') # Create the I2C bus i2c = busio.I2C(board.SCL, board.SDA) # Create the ADC object using the I2C bus adc = ADS1115(i2c) # Print header header = " ts CHAN 0 CHAN 1 CHAN 2 CHAN 3" print(header) print("{:>15}\t{:>5}\t{:>5}\t{:>5}\t{:>5}\t{:>5}\t{:>5}\t{:>5}\t{:>5}".format( '', 'raw', 'v', 'raw', 'v', 'raw', 'v', 'raw', 'v')) while True: # Get raw readings for each channel r0 = adc[0].value r1 = adc[1].value r2 = adc[2].value r3 = adc[3].value # Get voltage readings for each channel v0 = adc[0].volts v1 = adc[1].volts v2 = adc[2].volts
def __init__(self): self.DoorStatus = "Open" self.GAIN = 2 / 3 self.i2c = busio.I2C(board.SCL, board.SDA) self.adc = ADS1115(self.i2c)