parent
ce012d179e
commit
77b788c048
13
main.py
13
main.py
|
@ -3,6 +3,8 @@ import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
|
sys.path.append('./SDL_Adafruit_ADS1x15')
|
||||||
|
import SDL_Adafruit_ADS1x15
|
||||||
try:
|
try:
|
||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
import gpiozero
|
import gpiozero
|
||||||
|
@ -15,8 +17,6 @@ except ImportError:
|
||||||
print(ImportError)
|
print(ImportError)
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
sys.path.append('./SDL_Adafruit_ADS1x15')
|
|
||||||
import SDL_Adafruit_ADS1x15
|
|
||||||
|
|
||||||
def debug_print(message: str):
|
def debug_print(message: str):
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
|
@ -72,12 +72,11 @@ def signal_handler(signal, frame):
|
||||||
signal.signal(signal.SIGINT, signal_handler)
|
signal.signal(signal.SIGINT, signal_handler)
|
||||||
|
|
||||||
def get_moisture():
|
def get_moisture():
|
||||||
ADS1115 = 0x0
|
gain = 5096
|
||||||
gain = 6144
|
|
||||||
sps = 250
|
sps = 250
|
||||||
adc = SDL_Adafruit_ADS1x15.ADS1x15(ic=ADS1115)
|
adc = SDL_Adafruit_ADS1x15.ADS1x15(ic=0x01)
|
||||||
|
print(adc.readADCSingleEnded(0, gain, sps) / 1000)
|
||||||
return adc.readADCSingleEnded(0, gain, sps) / 1000 + adc.readADCSingleEnded(1, gain, sps) / 1000 + adc.readADCSingleEnded(2, gain, sps) / 1000 + adc.readADCSingleEnded(3, gain, sps) / 1000
|
# return adc.readADCSingleEnded(0, gain, sps) / 1000 + adc.readADCSingleEnded(1, gain, sps) / 1000 + adc.readADCSingleEnded(2, gain, sps) / 1000 + adc.readADCSingleEnded(3, gain, sps) / 1000
|
||||||
|
|
||||||
#temperature
|
#temperature
|
||||||
def get_temperature():
|
def get_temperature():
|
||||||
|
|
Loading…
Reference in New Issue