Beispiel #1
0
def setBME280FormColours(bme280, *args, **kwargs):
    blynk, _log = setFormBlynkLogObjects (blynkObj=kwargs.get('blynkObj', None), loggerObj=kwargs.get('loggerObj', None))  
    _log.debug("setBME280FormColours : start fx")
    blynk.run()
    blynk.set_property(1, 'color', drone.getTempColour(_log,int(bme280.temperature*10))) 
    blynk.set_property(2, 'color', drone.colours['OFFLINE']) 
    blynk.set_property(3, 'color', drone.getTempColour(_log,int(bme280.humidity))) 
    blynk.set_property(4, 'color', drone.colours['ONLINE']) 
    blynk.set_property(5, 'color', drone.colours['ONLINE']) 
    blynk.set_property(11, 'color', drone.colours['ONLINE']) 
Beispiel #2
0
    def processSensors():
        global rowIndex, nutrientMix, sensors
        for sensor in sensors:
            if sensor is not None:
                sensor.read()

        try:
            drone.pubSensorReadingsToGoolgeCloud(sensors, _log)
            drone.pubSensorReadingsToThingSpeak(sensors, _log)
        except:
            _log.critical("except logging readings to Google")

        try:
            sensors[0].color = drone.getTempColour(
                _log, int(round(float(sensors[0].value) * 10, 0)))
            sensors[1].color = drone.getECColour(
                _log, round(float(sensors[1].value), 0))
            sensors[2].color = drone.getPHColour(
                _log, round(float(sensors[2].value) * 10, 0))
            _log.debug("sensors[0].value = " + str(sensors[0].value))
            _log.debug("sensors[1].value = " + str(sensors[1].value))
            _log.debug("sensors[2].value = " + str(sensors[2].value))
            _log.debug("sensors[0].colour = " + str(
                drone.getTempColour(
                    _log, int(round(float(sensors[0].value) * 10, 0)))))
            _log.debug("sensors[1].colour = " + str(
                drone.getECColour(_log, round(float(sensors[1].value), 0))))
            _log.debug("sensors[2].colour = " + str(
                drone.getPHColour(_log, round(float(sensors[2].value) *
                                              10, 0))))
        except:
            _log.critical("Working out sensor colour crashed")
            _log.critical("sensors[0].value = " + str(sensors[0].value))
            _log.critical("sensors[1].value = " + str(sensors[1].value))
            _log.critical("sensors[2].value = " + str(sensors[2].value))
            _log.critical("sensors[0].colour = " + str(
                drone.getTempColour(
                    _log, int(round(float(sensors[0].value) * 10, 0)))))
            _log.critical("sensors[1].colour = " + str(
                drone.getECColour(_log, round(float(sensors[1].value), 0))))
            _log.critical("sensors[2].colour = " + str(
                drone.getPHColour(_log, round(float(sensors[2].value) *
                                              10, 0))))

        for sensor in sensors:
            if sensor is not None:
                sensor.display(blynk)
Beispiel #3
0
def processSensors():
    for sensor in sensors:
        if sensor is not None:
            sensor.read()

    try:
        sensors[0].color = drone.getTempColour(
            _log, int(round(float(sensors[0].value) * 10, 0)))
    except:
        _log.critical("Working out sensor colour crashed")

    for sensor in sensors:
        if sensor is not None:
            sensor.display(blynk)
Beispiel #4
0
    def processSensors():
        for sensor in sensors:
            if sensor is not None:
                sensor.read()

        try:
            drone.pubSensorReadingsToGoolgeCloud(sensors, _log)
        except:
            _log.critical("except logging readings to Google")

        try:
            sensors[0].color = drone.getTempColour(
                _log, int(round(float(sensors[0].value) * 10, 0)))
        except:
            _log.critical("Working out sensor colour crashed")

        for sensor in sensors:
            if sensor is not None:
                sensor.display(blynk)
Beispiel #5
0
sensors = []
if (str(device_sensor_type) == "PH"):
    sensors = drone.buildSensors(sensors, _log)
else:
    sensors = drone.buildMonitorSensors(sensors, _log)
_log.info("All Monitor Sensors created")

for sensor in sensors:
    if sensor is not None:
        _log.critical("Going to read the " + sensor.name)
        sensor.read()
        _log.critical("The " + sensor.name + " is " + str(sensor.value))
        _log.critical("The " + sensor.name + " probe calibration is  " +
                      str(sensor.currenCalibration()))

try:
    _log.info("Going to call drone.getTempColour")
    sensors[0].color = drone.getTempColour(
        _log, int(round(float(sensors[0].value) * 10, 0)))
except:
    _log.critical("Working out sensor colour crashed")

_log.info("Going to call drone.getTempColour")
payload = ''
payload = drone.buildPayload(sensors, _log, payload)
_log.info("payload for google is = " + payload)

_log.info("Going to call drone.pubToGoolgeCloud")
drone.pubSensorReadingsToGoolgeCloud(sensors, _log)
_log.info("Completed call drone.pubToGoolgeCloud")
Beispiel #6
0
    for i in range(0, 9):
        blynk.virtual_write(98, str(q.stdout.readline()) + '\n')

_log.debug("Just about to get boot timestamp and change system LED")
now = datetime.now()
blynk.virtual_write(99, now.strftime("%d/%m/%Y %H:%M:%S"))
blynk.virtual_write(97, "add", rowIndex, "Reboot",
                    now.strftime("%d/%m/%Y %H:%M:%S"))
blynk.virtual_write(29, rowIndex + 1)
blynk.virtual_write(systemLED, 255)
_log.debug("Main fx:- calling drone.setFormOnline to remove blue")
drone.setFormOnlineColours(blynkObj=blynk, loggerObj=_log)
blynk.virtual_write(255, 0)
_log.info("--------------------------Completed Boot--------------------------")
_log.debug("droneAir : drone.getTempColour(_log,int(10)) = " +
           str(drone.getTempColour(_log, 100)))

while True:
    try:
        blynk.run()
        timer.run()
    except:
        _log.error("in main loop except")
        blynk.virtual_write(250, "Crashed")
        drone.setFormOfflineColours(blynkObj=blynk, loggerObj=_log)
        if (parser.get('logging', 'logLevel',
                       fallback=logging.DEBUG) == "CRITICAL"):
            #       blynk.notify("Production blynk crashed and is auto-restarting; hostname " +  drone.gethostname() + " at: " + now.strftime("%d/%m/%Y %H:%M:%S"))
            #      blynk.email(drone.TARGET_EMAIL, 'Production Blynk Crash', "Production blynk crashed and is auto-restarting; hostname " +  drone.gethostname() + " at: " + now.strftime("%d/%m/%Y %H:%M:%S"))
            os.system('sh /home/pi/updateDroneponics.sh')
            os.system('sudo reboot')