Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
first steps with python3
#1
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??  

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)))
called from
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)
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 ;)
Reply


Messages In This Thread
first steps with python3 - by hunnimonstr - Jul-03-2017, 11:27 AM
RE: first steps with python3 - by Larz60+ - Jul-03-2017, 12:19 PM
RE: first steps with python3 - by hunnimonstr - Jul-03-2017, 02:24 PM
RE: first steps with python3 - by hunnimonstr - Jul-03-2017, 01:08 PM
RE: first steps with python3 - by nilamo - Jul-03-2017, 03:05 PM
RE: first steps with python3 - by hunnimonstr - Jul-03-2017, 08:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Run this once instead of a loop, do I need the 'calibration' steps? duckredbeard 2 718 Jan-28-2025, 04:55 PM
Last Post: duckredbeard
Thumbs Up Sorting Steps MoreMoney 19 4,813 Mar-31-2024, 10:59 AM
Last Post: Pedroski55
  Next steps for using API data Rebster 6 3,655 Oct-10-2020, 05:35 PM
Last Post: perfringo
  Keep Toggle View through Slider Steps yourboyjoe 1 2,132 Aug-10-2020, 07:32 PM
Last Post: Yoriz
  Files to store configuration and steps for a industrial process control application Danieru 1 2,384 Aug-03-2020, 05:43 PM
Last Post: buran
  Gnuradio python3 is not compatible python3 xmlrpc library How Can I Fix İt ? muratoznnnn 3 6,062 Nov-07-2019, 05:47 PM
Last Post: DeaD_EyE
  Pexpect baby steps slouw 9 10,292 May-23-2019, 10:21 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020