Jul-03-2017, 11:27 AM
(This post was last modified: Jul-03-2017, 11:27 AM by hunnimonstr.)
Hi all i could use a few pointers in the right directions.
I am trying to automate the patio plant care, and automatically water plants as they need it.
using the miflora plant sensors which broadcast information via Btooth BLE and a raspberry pi Zer0-W which will use gpio pins to switch on/off water pumps.
So far so good.. things sort of work ;)
But i need to add in a bit more complexity and im not sure about the best way to go.
I intend to run a python script via cron scheduled job every 30 mins or so
firstly i want to log the data collected, local file vs iot server??
next i want to incorporate some warnings and alarms such as Low battery ?? MQTT?
then the decision to water or not really needs to check the last time water was applied and raise warnings if it was applied on the last cycle, look up in logs or retain some persistent data??
called from
I intend to read up on enumeration and catch/try next by enumerating the Btooth addy's i can loose the plantid variable
any pointers provided regarding the best way to log data, and or retain some persistent data between runs will be greatly appreciated.
if im not using a python vocabulary yet, be patient ;)
I am trying to automate the patio plant care, and automatically water plants as they need it.
using the miflora plant sensors which broadcast information via Btooth BLE and a raspberry pi Zer0-W which will use gpio pins to switch on/off water pumps.
So far so good.. things sort of work ;)
But i need to add in a bit more complexity and im not sure about the best way to go.
I intend to run a python script via cron scheduled job every 30 mins or so
firstly i want to log the data collected, local file vs iot server??
next i want to incorporate some warnings and alarms such as Low battery ?? MQTT?
then the decision to water or not really needs to check the last time water was applied and raise warnings if it was applied on the last cycle, look up in logs or retain some persistent data??
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
from miflora.miflora_poller import MiFloraPoller, \ MI_CONDUCTIVITY, MI_MOISTURE, MI_LIGHT, MI_TEMPERATURE, MI_BATTERY import datetime # for logging / timestamp import time # for sleep function def sensortest(plantid, saddr, iopin): """ my first function..""" poller = MiFloraPoller(saddr) if poller.parameter_value(MI_MOISTURE) < 30 : GPIO.output(iopin, 0 ) # turn on pump1 time.sleep( 15 ) GPIO.output(iopin, 1 ) # turn off pump1 # debug/test output print ( " info on plant : " , plantid) print ( " Temperature: {}" . format (poller.parameter_value( "temperature" ))) print ( " Moisture: {}" . format (poller.parameter_value(MI_MOISTURE))) print ( " Light: {}" . format (poller.parameter_value(MI_LIGHT))) print ( " Conductivity: {}" . format (poller.parameter_value(MI_CONDUCTIVITY))) print ( "Battery: {}" . format (poller.parameter_value(MI_BATTERY))) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
from miflora.miflora_poller import MiFloraPoller, \ MI_CONDUCTIVITY, MI_MOISTURE, MI_LIGHT, MI_TEMPERATURE, MI_BATTERY import RPi.GPIO as GPIO import datetime import time import myfunc1 GPIO.setmode(GPIO.BCM) # set board mode to Broadcom GPIO.setup( 17 , GPIO.OUT) # set up pin 17 GPIO.setup( 27 , GPIO.OUT) # set up pin 27 GPIO.setup( 22 , GPIO.OUT) # set up pin 22 GPIO.setup( 23 , GPIO.OUT) # set up pin 23 GPIO.setup( 24 , GPIO.OUT) # set up pin 24 GPIO.setup( 25 , GPIO.OUT) # set up pin 25 GPIO.output( 17 , 1 ) # turn on pin 17 GPIO.output( 27 , 1 ) # turn on pin 27 GPIO.output( 22 , 1 ) # turn on pin 22 GPIO.output( 23 , 1 ) # turn on pin 23 GPIO.output( 24 , 1 ) # turn on pin 24 GPIO.output( 25 , 1 ) # turn on pin 25 myfunc1.sensortest( "P1" , "C4:7C:8D:64:43:6F" , 17 ) myfunc1.sensortest( "P2" , "C4:7C:8D:64:43:C8" , 27 ) myfunc1.sensortest( "P3" , "C4:7C:8D:64:43:7F" , 22 ) myfunc1.sensortest( "P4" , "C4:7C:8D:64:43:6c" , 23 ) myfunc1.sensortest( "P5" , "C4:7C:8D:64:43:5b" , 24 ) myfunc1.sensortest( "P6" , "C4:7C:8D:64:43:3f" , 25 ) |
any pointers provided regarding the best way to log data, and or retain some persistent data between runs will be greatly appreciated.
if im not using a python vocabulary yet, be patient ;)