def phSensor_read(channel):
for i in range(sample):
adc = adc_read(channel)
sampleValue.append(adc)
time.sleep(0.10)
sampleValue.sort()
avg = 0
for i in range(2, 8):
avg += sampleValue[i]
phValue = float(avg * 5 / 1024 /6)
phValue = float(3.5 * phValue)
sampleValue.clear()
return phValue
Turbidity Sensor
def turbidity_read(channel):
sampleValue = []
for i in range(sample):
adc = adc_read(channel)
voltage = adc * (5.0 / 1024.0)
sampleValue.append(voltage)
sampleValue.sort()
avg = 0
for i in range(2, 8):
avg += sampleValue[i]
voltage = avg / 6
return voltage