コード例 #1
0
def get_devices():
    device = AtlasI2C()
    device_address_list = device.list_i2c_devices()
    device_list = []
    for i in device_address_list:
		device.set_i2c_address(i)
		response = device.query("I")
		moduletype = response.split(",")[1] 
		response = device.query("name,?").split(",")[1]
		device_list.append(AtlasI2C(address = i, moduletype = moduletype, name = response))
    return device_list 
コード例 #2
0
 def __init__(self, SensorId, name, DisplayPin, _log, *args, **kwargs):
     _log.info("__init__ for " + name)
     self._log = _log
     self.sensor = AtlasI2C(SensorId)
     self.sensorId = SensorId
     self.name = name
     self.high = 26
     self.low = 15
     self.displayPin = DisplayPin
     self.displayPin2 = kwargs.get('value2DisplayPin', None)
     self.DisplayPin2Label = kwargs.get('DisplayPin2Label', None)
     self.displayPin3 = kwargs.get('value3DisplayPin', None)
     self.DisplayPin3Label = kwargs.get('DisplayPin3Label', None)
     self.displayPin4 = kwargs.get('value4DisplayPin', None)
     self.DisplayPin4Label = kwargs.get('DisplayPin4Label', None)
     self.target = kwargs.get('Target', None)
     self.mode = 1  # 1 = off 2 = on 3 = auto
     self.value = None
     self.value2 = None
     self.value3 = None
     self.value4 = None
     self.oldValue = None
     self.lowAlarm = kwargs.get('LowAlarm', None)
     self.highAlarm = kwargs.get('HighAlarm', None)
     self.color = None
     self.Cal = None
     self.CalPoint = None
     self.HighCalPoint = None
     self.MidCalPoint = None
     self.LowCalPoint = None
コード例 #3
0
def get_devices():
    device = AtlasI2C()
    device_address_list = device.list_i2c_devices()
    device_list = []

    for i in device_address_list:
        device.set_i2c_address(i)
        response = device.query("I")
        try:
            module_type = response[1].split(",")[1]
            response = device.query("name,?")[1].split(",")[1]
        except (IndexError, AttributeError):
            # device is not an Atlas I2C sensor
            continue
        device_list.append(
            AtlasI2C(address=i, moduletype=module_type, name=response))
    return device_list
コード例 #4
0
 def send_command(location, cmd):
     from AtlasI2C import AtlasI2C
     device = AtlasI2C()
     device.set_i2c_address(int(location))
     setting_output = device.query(cmd)
     text_out = setting_output.strip().strip('\x00')
     print(text_out)
     return text_out
コード例 #5
0
def get_devices():
    device = AtlasI2C()
    device_address_list = device.list_i2c_devices()
    device_list = []

    for i in device_address_list:
        device.set_i2c_address(i)
        response = device.query("i")
        
        # check if the device is an EZO device
        checkEzo = response.split(",")
        if len(checkEzo) > 0:
            if checkEzo[0].endswith("?I"):
                # yes - this is an EZO device
                moduletype = checkEzo[1]
                response = device.query("name,?").split(",")[1]
                device_list.append(AtlasI2C(address = i, moduletype = moduletype, name = response))
    return device_list
コード例 #6
0
ファイル: sensor.py プロジェクト: ben700/droneponics
 def __init__(self, SensorId, name="", 
              _valuePayloadName = None,
              _value2PayloadName = None,
              _value3PayloadName = None,
              _value4PayloadName = None                
             ):
     self.sensor = AtlasI2C(SensorId)
     self.sensorId = SensorId
     self.name = name
     self.value = None
     self.value2 = None
     self.value3 = None
     self.value4 = None
     self.valuePayloadName = _valuePayloadName
     self.value2PayloadName = _value2PayloadName
     self.value3PayloadName = _value3PayloadName
     self.value4PayloadName = _value4PayloadName
     self.Cal= None
     self.CalPoint= None
コード例 #7
0
def read_sensor(location="", extra="", sensor_name="", *args):
    # Try importing the modules then give-up and report to user if it fails
    import datetime
    import time
    try:
        from AtlasI2C import AtlasI2C
    except:
        print("Unable to import AtlasI2C, make sure this is installed")
        print("Clone from https://github.com/Atlas-Scientific/Raspberry-Pi-sample-code.git")
        sys.exit()

    device = AtlasI2C()
    device.set_i2c_address(int(location))
    #device_address_list = device.list_i2c_devices()
    read_attempt = 1
    valid_result = "None"
    while read_attempt < 5:
        try:
            ph = device.query("R")
            if "Success" in ph:
                valid_result = "True"
                ph = ph.split(":")[1].strip()
                if "\00" in ph:
                    ph = ph.split("\00")[0]
            #
            if valid_result == "None":
                print("--problem reading Atlas Scientific EZO ph, try " + str(read_attempt))
                time.sleep(2)
                read_attempt = read_attempt + 1
            else:
                logtime = datetime.datetime.now()
                data = [['time',logtime], ['ph', ph]]
                return data
        except Exception as e:
            print("--exception while reading Atlas Scientific EZO ph, try " + str(read_attempt))
            print(" -- " + str(e))
            time.sleep(2)
            read_attempt = read_attempt + 1
    return None
コード例 #8
0
    sys.path.append('/home/pi/droneponics')
    from AtlasI2C import (AtlasI2C)
    import blynklib
    import blynktimer

    import subprocess
    import re

    # tune console logging
    _log = logging.getLogger('BlynkLog')
    logFormatter = logging.Formatter(
        "%(asctime)s [%(levelname)s]  %(message)s")
    consoleHandler = logging.StreamHandler()
    consoleHandler.setFormatter(logFormatter)
    _log.addHandler(consoleHandler)
    _log.setLevel(logging.DEBUG)

    # Initialize the sensor.
    try:
        do = AtlasI2C(97)

        _log.info("sensor created")
    except:
        _log.info("Unexpected error: Atlas")
    else:
        try:
            print(do.query("O,?"))

        except:
            _log.info("Expected error: Use Atlas Error")
コード例 #9
0
    import os
    sys.path.append('/home/pi/droneponics')
    from AtlasI2C import (AtlasI2C)

    # tune console logging
    _log = logging.getLogger('BlynkLog')
    logFormatter = logging.Formatter(
        "%(asctime)s [%(levelname)s]  %(message)s")
    consoleHandler = logging.StreamHandler()
    consoleHandler.setFormatter(logFormatter)
    _log.addHandler(consoleHandler)
    _log.setLevel(logging.DEBUG)

    # Initialize the sensor.
    try:
        ph = AtlasI2C(99)
        _log.info("sensor created")
    except:
        _log.info("Unexpected error: Atlas")
    else:
        try:
            oPH = -9
            cPH = ph.query("R").split(":")[1]
            while (cPH != oPH):
                oPH = cPH
                time.sleep(1)
                cPH = ph.query("R").split(":")[1]
                _log.info("Waiting for ph to be stable. It's now :" +
                          str(cPH) + '\n')

        except:
コード例 #10
0
    import logging
    from datetime import datetime
    import sys
    import os
    import RPi.GPIO as GPIO
    sys.path.append('/home/pi/droneponics')
    from AtlasI2C import (AtlasI2C)
    import blynklib
    import blynktimer

    import subprocess
    import re
    import drone

    # tune console logging
    _log = logging.getLogger('BlynkLog')
    logFormatter = logging.Formatter(
        "%(asctime)s [%(levelname)s]  %(message)s")
    consoleHandler = logging.StreamHandler()
    consoleHandler.setFormatter(logFormatter)
    _log.addHandler(consoleHandler)
    _log.setLevel(logging.DEBUG)

    # Initialize the sensor.
    try:
        # Create the I2C bus
        pump = AtlasI2C(103)
        _log.info(pump.query("I2C,15"))
    except:
        _log.info("Unexpected error: Atlas")
コード例 #11
0
    import os
    sys.path.append('/home/pi/droneponics')
    from AtlasI2C import (AtlasI2C)

    # tune console logging
    _log = logging.getLogger('BlynkLog')
    logFormatter = logging.Formatter(
        "%(asctime)s [%(levelname)s]  %(message)s")
    consoleHandler = logging.StreamHandler()
    consoleHandler.setFormatter(logFormatter)
    _log.addHandler(consoleHandler)
    _log.setLevel(logging.DEBUG)

    # Initialize the sensor.
    try:
        ec = AtlasI2C(100)
        _log.info("sensor created")
    except:
        _log.info("Unexpected error: Atlas")
    else:
        try:
            while True:
                reading = ec.query("R")
                doseLogic = reading.split(":")[1].strip().rstrip('\x00')
                newLogic = reading.split(":")[1].split(",")[0].strip().rstrip(
                    '\x00')
                try:
                    newLogicppm = reading.split(":")[1].split(
                        ",")[1].strip().rstrip('\x00')
                except:
                    newLogicppm = "None"
コード例 #12
0
##!/usr/bin/env python3
import time
import sys
import os

sys.path.append('/home/pi/droneponics/droneAirAtlas')
from AtlasI2C import (AtlasI2C)

CO2 = AtlasI2C(105)
HUM = AtlasI2C(111)

#CO2.write("R")
#time.sleep(2)
#print(CO2.read())

#time.sleep(1)

print(CO2.query("R"))
コード例 #13
0
    import logging
    from datetime import datetime
    import sys
    import os
    import RPi.GPIO as GPIO
    sys.path.append('/home/pi/droneponics')
    from AtlasI2C import (AtlasI2C)
    import blynklib
    import blynktimer

    import subprocess
    import re
    import drone

    # tune console logging
    _log = logging.getLogger('BlynkLog')
    logFormatter = logging.Formatter(
        "%(asctime)s [%(levelname)s]  %(message)s")
    consoleHandler = logging.StreamHandler()
    consoleHandler.setFormatter(logFormatter)
    _log.addHandler(consoleHandler)
    _log.setLevel(logging.DEBUG)

    # Initialize the sensor.
    try:
        # Create the I2C bus
        pump = AtlasI2C(11)
        _log.info(pump.query("TV,?"))
    except:
        _log.info("Unexpected error: Atlas")
コード例 #14
0
 def __init__(self, device_name, temp_sensor):
     super(PHSensor, self).__init__(device_type='ph',
                                    device_name=device_name)
     self.__sensor = AtlasI2C(address=99)
     self.__temp_sensor = temp_sensor
コード例 #15
0
    import subprocess
    import re

    # tune console logging
    _log = logging.getLogger('BlynkLog')
    logFormatter = logging.Formatter(
        "%(asctime)s [%(levelname)s]  %(message)s")
    consoleHandler = logging.StreamHandler()
    consoleHandler.setFormatter(logFormatter)
    _log.addHandler(consoleHandler)
    _log.setLevel(logging.DEBUG)

    # Initialize the sensor.
    try:
        orp = AtlasI2C(98)
        _log.info("sensor created")
    except:
        _log.info("Unexpected error: Atlas")
    else:
        if True:
            oORP = orp.query("R").split(":")[1].strip().rstrip('\x00')
            answer = input("Are you sure you want to calibrate ORP (y/n)")
            if answer == 'y':
                answer = input(
                    "Going to calibrate ORP to 225 oxidation/reduction potential. Enter y when you are ready(y/n)"
                )
                if answer == 'y':
                    orp.query("Cal,clear")
                    cORP = orp.query("R").split(":")[1].strip().rstrip('\x00')
                    while (cORP != oORP):
コード例 #16
0
ファイル: atlasECCalK10.py プロジェクト: ben700/droneponics
    import subprocess
    import re

    # tune console logging
    _log = logging.getLogger('BlynkLog')
    logFormatter = logging.Formatter(
        "%(asctime)s [%(levelname)s]  %(message)s")
    consoleHandler = logging.StreamHandler()
    consoleHandler.setFormatter(logFormatter)
    _log.addHandler(consoleHandler)
    _log.setLevel(logging.DEBUG)

    # Initialize the sensor.
    try:
        temp = AtlasI2C(102)
        ec = AtlasI2C(100)
        ph = AtlasI2C(99)

        _log.info("sensor created")
    except:
        _log.info("Unexpected error: Atlas")
    else:
        try:
            oEC = ec.query("R").split(":")[1]
            answer = input("Are you sure you want to calibrate EC (y/n)")
            if answer == 'y':
                answer = input(
                    "Going to calibrate ec DRY. Enter y when you are ready(y/n)"
                )
                if answer == 'y':
コード例 #17
0
ファイル: atlasFlowCal.py プロジェクト: ben700/droneponics
    # tune console logging
    _log = logging.getLogger('BlynkLog')
    logFormatter = logging.Formatter("%(asctime)s [%(levelname)s]  %(message)s")
    consoleHandler = logging.StreamHandler()
    consoleHandler.setFormatter(logFormatter)
    _log.addHandler(consoleHandler)
    _log.setLevel(logging.DEBUG)

    answer = input("Are you sure you want to calibrate flow? (y/n)")
    if answer is None or answer != 'y':
        _log.info("User Exit")
        quit()
  
    # Initialize the sensor.
    try:
        flow = AtlasI2C(104)
        _log.info("sensor created")
    except:
        _log.info("Unexpected error: Atlas")
    else:
        try:	
             flow.query("Set,3/8")
             flow.query("Clear")
             flow.query("Frp,h")
                      
        except:
            _log.info("Expected error: Use Atlas Error")
            
 
コード例 #18
0
def tempStep1():
    temp = AtlasI2C(102)
    info__message.text ="Current Temp reading is " + temp.query("R").split(":")[1]
コード例 #19
0
def phStep1():
    ph = AtlasI2C(99)
    info__message.text ="Current pH reading is " + ph.query("R").split(":")[1] + '/n' + "Press button to continue calibration"
    temp__message = Text(app, text="Enter Temperature or i will use 19.5", size=40, font="Times new roman", color="lightblue")
    phProbe.command = phStep2 
コード例 #20
0
# tune console logging
_log = logging.getLogger('BlynkLog')
logFormatter = logging.Formatter("%(asctime)s [%(levelname)s]  %(message)s")
consoleHandler = logging.StreamHandler()
consoleHandler.setFormatter(logFormatter)
_log.addHandler(consoleHandler)
_log.setLevel(parser.get('logging', 'logLevel', fallback=logging.DEBUG))
_log.critical("critical")
_log.error("error")
_log.warning("warning")
_log.info("info")
_log.debug("debug")

_log.info("/home/pi/droneponics/config/configOxy/" + drone.gethostname() +
          ".ini")

droneGUI.nutrientMix = drone.buildOxyMix(nutrientMix, _log)

nutrientMix[0].pump = AtlasI2C(nutrientMix[0].pumpId)
label1Text = nutrientMix[0].pump.query("Cal,?").strip().rstrip('\x00')
print(label1Text)
label2Text = nutrientMix[0].pump.query("Cal,clear").strip().rstrip('\x00')
print(label2Text)
nutrientMix[0].pump.query("D,10")
time.sleep(10)
label3Text = nutrientMix[0].pump.query("Cal,10").strip().rstrip('\x00')
print(label3Text)
label4Text = nutrientMix[0].pump.query("Cal,?").strip().rstrip('\x00')
print(label4Text)
コード例 #21
0
ファイル: tempTest.py プロジェクト: ben700/droneponics
    import os
    sys.path.append('/home/pi/droneponics')
    from AtlasI2C import (AtlasI2C)

    # tune console logging
    _log = logging.getLogger('BlynkLog')
    logFormatter = logging.Formatter(
        "%(asctime)s [%(levelname)s]  %(message)s")
    consoleHandler = logging.StreamHandler()
    consoleHandler.setFormatter(logFormatter)
    _log.addHandler(consoleHandler)
    _log.setLevel(logging.DEBUG)

    # Initialize the sensor.
    try:
        temp = AtlasI2C(102)
        _log.info("Temp Sensor Info = " + temp.query("i"))
        _log.info("Temp Sensor Calibration = " + temp.query("cal,?"))
        _log.info("Temp Sensor Status = " + temp.query("Status"))
        _log.info("Temp Sensor Scale = " + temp.query("S,?"))
    except:
        _log.info("Unexpected error: Atlas")
    else:
        try:
            oTemp = -999
            cTemp = temp.query("R").split(":")[1]
            while (cTemp != oTemp):
                oTemp = cTemp
                time.sleep(1)
                cTemp = temp.query("R").split(":")[1]
                _log.info("Waiting for temp to be stable. It's now :" +
コード例 #22
0
ファイル: atlasMonitor.py プロジェクト: ben700/droneponics
    _log.setLevel(logging.DEBUG)

    sensors = drone.buildSensors(sensors, _log)

    # Initialize Blynk
    blynk = blynklib.Blynk(BLYNK_AUTH)
    timer = blynktimer.Timer()

    blynk.run()
    blynk.set_property(systemLED, 'color', colours['ONLINE'])

    # Initialize the sensor.
    try:
        # Create the I2C bus
        for sensor in sensors:
            sensor.sensor = AtlasI2C(sensor.sensorId)
            blynk.set_property(sensor.displayPin, 'color', colours['ONLINE'])
            blynk.set_property(sensor.displayPin, 'label', sensor.name)
        blynk.virtual_write(98, "Sensors created" + '\n')
    except:
        blynk.virtual_write(98, "Unexpected error: atlas" + '\n')
        _log.info("Unexpected error: Atlas")

    @blynk.handle_event('write V255')
    def rebooter(pin, value):
        _log.info("User reboot")
        blynk.virtual_write(98, "User Reboot " + '\n')
        for sensor in sensors:
            blynk.set_property(sensor.displayPin, 'color', colours['OFFLINE'])
        blynk.set_property(systemLED, 'color', colours['OFFLINE'])
        os.system('sh /home/pi/updateDroneponics.sh')
コード例 #23
0
def ecStep1():
    ec = AtlasI2C(100)
    info__message.text ="Current EC reading is " + ec.query("R").split(":")[1]
コード例 #24
0
    import re
    import drone

    # tune console logging
    _log = logging.getLogger('BlynkLog')
    logFormatter = logging.Formatter(
        "%(asctime)s [%(levelname)s]  %(message)s")
    consoleHandler = logging.StreamHandler()
    consoleHandler.setFormatter(logFormatter)
    _log.addHandler(consoleHandler)
    _log.setLevel(logging.DEBUG)

    # Initialize the sensor.
    try:
        # Create the I2C bus
        pump = AtlasI2C(0x10)
        _log.info(pump.query("I2C,11"))

        pump = AtlasI2C(0x11)
        _log.info(pump.query("I2C,12"))

        pump = AtlasI2C(0x12)
        _log.info(pump.query("I2C,13"))

        pump = AtlasI2C(0x13)
        _log.info(pump.query("I2C,14"))

        pump = AtlasI2C(0x14)
        _log.info(pump.query("I2C,15"))

        pump = AtlasI2C(0x15)
コード例 #25
0
import sys
import fcntl
import time
import copy
import string
from AtlasI2C import (
         AtlasI2C
)

def print_devices(device_list, device):
    for i in device_list:
        if(i == device):
            print("--> " + i.get_device_info())
        else:
            print(" - " + i.get_device_info())
            
for n in range (10):
    i = 0
    x = 0
    while (i ==0):
        device = AtlasI2C()
        device_address_list = device.list_i2c_devices()
        i = len(device_address_list)
        if(i==0):
            x=x+1
            continue
        output = "On test cycle " + str(n) +" Found " + str(i) + " and that took " + str(x) + " trys. Ids of atlas devices found ar$
        for y in device_address_list:
            output += str(y) + ","
        print(output[0:-1])
コード例 #26
0
ファイル: CO2Test.py プロジェクト: ben700/droneponics
    import os
    sys.path.append('/home/pi/droneponics')
    from AtlasI2C import (AtlasI2C)

    # tune console logging
    _log = logging.getLogger('BlynkLog')
    logFormatter = logging.Formatter(
        "%(asctime)s [%(levelname)s]  %(message)s")
    consoleHandler = logging.StreamHandler()
    consoleHandler.setFormatter(logFormatter)
    _log.addHandler(consoleHandler)
    _log.setLevel(logging.DEBUG)

    # Initialize the sensor.
    try:
        CO2 = AtlasI2C(105)
        _log.info("sensor created")
    except:
        _log.info("Unexpected error: Atlas")
    else:
        try:
            oCO2 = -9
            cCO2 = CO2.query("R").split(":")[1]
            while (cCO2 != oCO2):
                oCO2 = cCO2
                time.sleep(1)
                cCO2 = CO2.query("R").split(":")[1]
                _log.info("Waiting for CO2 to be stable. It's now :" +
                          str(cCO2) + '\n')

        except:
コード例 #27
0
import datetime
import time
from datetime import datetime
import sys
import os
sys.path.append('/home/pi/droneponics')
from AtlasI2C import (AtlasI2C)


colour = AtlasI2C(112)

try:
    print(colour.query("R").rstrip('\x00') + '\n')       
except:
    print("except")
コード例 #28
0
ファイル: droneDoser.py プロジェクト: ben700/droneponics
    _log.info("all senses created")

    # Initialize Blynk
    blynk = blynklib.Blynk(parser.get('droneDoser', 'BLYNK_AUTH'))
    timer = blynktimer.Timer()
    blynk.run()
    #blynk.virtual_write(98, "clr")
    blynk.set_property(systemLED, 'color', colours['ONLINE'])
    _log.info("Blynk created")

    # Initialize the sensor.
    try:
        # Create the I2C bus
        labelPin = 70
        for dosage in nutrientMix:
            dosage.pump = AtlasI2C(dosage.pumpId)
            _log.info("Created Pump" + str(dosage.pumpId))
            blynk.set_property(labelPin, 'label', dosage.name)
            labelPin = labelPin + 1
        blynk.virtual_write(98, "Pumps created" + '\n')
        for sensor in sensors:
            sensor.sensor = AtlasI2C(sensor.sensorId)
            blynk.set_property(sensor.displayPin, 'color', colours['ONLINE'])
            blynk.set_property(sensor.displayPin, 'label', sensor.name)
        blynk.virtual_write(98, "Sensors created" + '\n')
    except:

        blynk.virtual_write(98, "Unexpected error: atlas" + '\n')
        _log.info("Unexpected error: Atlas")
    else:
        try:
コード例 #29
0
    _log.addHandler(consoleHandler)
    _log.setLevel(logging.DEBUG)

    nutrientMix = []
    nutrientMix = drone.buildNutrientMix(nutrientMix, _log)

    answer = input("Are you sure you want to reset (y/n)")
    if answer is None or answer != 'y':
        _log.info("User Exit")
        quit()

    # Initialize the sensor.
    try:
        # Create the I2C bus
        for dosage in nutrientMix:
            dosage.pump = AtlasI2C(dosage.pumpId)
        _log.info("pump created")
    except:
        _log.info("Unexpected error: Atlas")
    else:
        try:
            _log.info("Try Use Pump")
            for dosage in nutrientMix:
                if (dosage.pump is not None):
                    answer = input("Are you sure you want to reset pump " +
                                   dosage.name + "(y/n)")
                    if answer is None or answer != 'y':
                        _log.info("User Skiped resetting this pump")
                        continue
                    else:
                        dosage.pump.query("Facory")
コード例 #30
0
import sys
import os
sys.path.append('/home/pi/droneponics')
from AtlasI2C import (AtlasI2C)

# Create the I2C bus
device = AtlasI2C(102)
device.query("i")