Example #1
0
    def initialize(self):
        import adafruit_shtc3
        from adafruit_extended_bus import ExtendedI2C

        try:
            self.sensor = adafruit_shtc3.SHTC3(
                ExtendedI2C(self.input_dev.i2c_bus))
        except:
            self.logger.exception("Setting up sensor")
Example #2
0
    def __init__(self):
        self.i2c = busio.I2C(board.SCL, board.SDA)
        self.station_id = "Amsterdam"

        self.cpu = CPUTemperature()
        self.sht = adafruit_shtc3.SHTC3(self.i2c)
        self.lps = adafruit_lps2x.LPS22(self.i2c, 0x5c)

        self.tcs = adafruit_tcs34725.TCS34725(self.i2c)
        self.tcs.integration_time = 200

        self.icm = adafruit_icm20x.ICM20948(self.i2c, 0x68)
        self.ads = ADS.ADS1015(self.i2c)
Example #3
0
    def read(self, SIO):

        try:
            if self.sens is None:
                i2c = busio.I2C(board.SCL, board.SDA,
                                frequency=100000)  # freq slower for pm25
                self.sens = adafruit_shtc3.SHTC3(i2c)

            self.t = time.time()
            self.T, self.RH = self.sens.measurements

        except:
            traceback.print_exc()
            self.sens = None
            return

        print("SHTC3", self.t, self.T, "C,\t", self.RH, " % Humidity")

        SIO.log_readout(self.T_id, self.T, self.t)
        SIO.log_readout(self.RH_id, self.RH, self.t)
Example #4
0
def pHECT():
    global temperature
    global pH
    global EC
    global TDS
    global S
    global SG
    global pHVar
    global ECVar
    GPIO.setmode(GPIO.BCM)
    while True:
        now = datetime.now()
        now = now.strftime("%Y-%m-%d %H:%M:%S")
        try:
            pH = Atlas(99, "r")
        except:
            pass
        while pH == "Error 254" or pH == "Error 255" or pH == "?I,pH,1.96":
            pH = Atlas(99, "r")
        pH = pH.rstrip('\x00')
        ECs = Atlas(100, "r")
        while ECs == "Error 254" or ECs == "Error 255" or ECs == "?I,EC,2.12":
            ECs = Atlas(100, "r")
        try:
            ECs.split(',')
            Ec, TDS, S, SG = ECs.split(',')
            EC = float(float(Ec.rstrip('\x00')) / 1.0)
            TDS = float(float(TDS.rstrip('\x00')) / 1.0)
            S = float(float(S.rstrip('\x00')) * 1000)
            SG = float(float(SG.rstrip('\x00')) / 1.0)
        except:
            pass  #ECs == "Error 254"
        i2c = busio.I2C(board.SCL, board.SDA)
        sht = adafruit_shtc3.SHTC3(i2c)
        temperature, rh = sht.measurements
        if temperature > 26:
            if not GPIO.input(20):
                GPIO.output(20, GPIO.HIGH)
                LogString = "Fan: temperature: " + str(
                    temperature) + "C, RH: " + str(rh) + "%, Fan STARTED"
                LogString = str(LogString)
                syslog.syslog(syslog.LOG_INFO, LogString)
        elif temperature < 25:
            if GPIO.input(20):
                GPIO.output(20, GPIO.LOW)
                LogString = "Fan: temperature: " + str(
                    temperature) + "C, RH: " + str(rh) + "%, Fan STOPPED"
                LogString = str(LogString)
                syslog.syslog(syslog.LOG_INFO, LogString)
        last = dbRead('H2O')
        LDate = last[0]
        date = datetime.now()
        SinceLast = date - LDate
        SinceLastSec = SinceLast.seconds
        if SinceLastSec > 5:
            Farm = mysql.connector.connect(host="192.168.1.14",
                                           user="******",
                                           passwd="a-51d41e",
                                           database="Farm")
            H2O = Farm.cursor()
            sql = "INSERT INTO Farm.H2O (date,temp,RH,pH,EC,TDS,S,SG) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)"
            val = (now, temperature, rh, pH, Ec, TDS, S, SG)
            H2O.execute(sql, val)
            H2O.close
            Farm.commit()
            Farm.close
        LogString = str("pHECT: temperature: ") + str(temperature) + str(
            " ,RH: ") + str(rh) + str("% ,pH: ") + str(pH) + " ,EC: " + str(
                EC) + " ,TDS: " + str(TDS) + " ,S: " + str(S) + " ,SG: " + str(
                    SG)
        LogString = str(LogString)
        syslog.syslog(syslog.LOG_INFO, LogString)
        time.sleep(25)
Example #5
0
# SPDX-FileCopyrightText: Copyright (c) 2020 Bryan Siepert for Adafruit Industries
#
# SPDX-License-Identifier: MIT
import time
import busio
import board
import adafruit_shtc3

i2c = busio.I2C(board.SCL, board.SDA)
sht = adafruit_shtc3.SHTC3(i2c)

while True:
    temperature, relative_humidity = sht.measurements
    print("Temperature: %0.1f C" % temperature)
    print("Humidity: %0.1f %%" % relative_humidity)
    print("")
    time.sleep(1)
Example #6
0
import time
import ssl
import json
import alarm
import board
import socketpool
import wifi
import adafruit_minimqtt.adafruit_minimqtt as MQTT
import adafruit_shtc3

PUBLISH_DELAY = 60
MQTT_TOPIC = "state/temp-sensor"
USE_DEEP_SLEEP = True

# Connect to the Sensor
sht = adafruit_shtc3.SHTC3(board.I2C())

# Add a secrets.py to your filesystem that has a dictionary called secrets with "ssid" and
# "password" keys with your WiFi credentials. DO NOT share that file or commit it into Git or other
# source control.
# pylint: disable=no-name-in-module,wrong-import-order
try:
    from secrets import secrets
except ImportError:
    print("WiFi secrets are kept in secrets.py, please add them there!")
    raise

wifi.radio.connect(secrets["ssid"], secrets["password"])
print("Connected to %s!" % secrets["ssid"])

# Create a socket pool
Example #7
0
import busio
import board
import adafruit_shtc3
import adafruit_sht31d
import time

"""Encapsulating the sensor readings here"""

i2c = busio.I2C(board.SCL, board.SDA)
topSensor = adafruit_shtc3.SHTC3(i2c)
botSensor = adafruit_sht31d.SHT31D(i2c)

# number of samples to average during calibration
_CALIBRATION_SAMPLES = 15
# amount of seconds between successive calibration sample
_CALIBRATION_TIME = .5

_TOP_SENSOR_CALIBRATION_VAL = 0
_BOT_SENSOR_CALIBRATION_VAL = 0

def c2f(temperature):
    # Convert input temperature in C to F
    # 9/5C+32
    f = float(temperature) * 9 / 5 + 32
    # round to hundredths
    f = int(100*f + 50) / 100
    return f

def tempC():
    """get the temperature from the sensor as C"""
    return topSensor.temperature
Example #8
0
 def __init__(self):
     self._shtc3 = adafruit_shtc3.SHTC3(i2c)