plant watering

Showroom for MicroPython related hardware projects.
Target audience: Users wanting to show off their project!
johnv
Posts: 25
Joined: Sun Nov 10, 2019 6:01 pm

Re: plant watering

Post by johnv » Sun Dec 15, 2019 6:01 pm

so its working!

didnt need the relay after all, the 2n7000 did the trick!

btw cant upload the mp4 video :(
Attachments
WhatsApp Image 2019-12-15 at 6.41.43 PM.jpeg
WhatsApp Image 2019-12-15 at 6.41.43 PM.jpeg (219.49 KiB) Viewed 332 times

johnv
Posts: 25
Joined: Sun Nov 10, 2019 6:01 pm

Re: plant watering

Post by johnv » Fri Dec 27, 2019 1:59 pm

hi, for reading the values and future stuff and controlling, maybe using an app, what is the better way to do it,

learn about mqtt, or a websocket or try building a server???

i'm kinda lost on this subject,

i think there is to much info on this subject,

i end up installing node red on the raspberry, but i would like to learn micropython, so block coding is cool to see things work but not the way i want to go,

also home assistant is a bit overkill, using yaml and implimantations of all kinds,

i like to keep it to python, so i can learn more,

so i would be gratefull, to any help offcourse ;)

i really like to know where to start with this,

kind regards, john!

safetyfactorman
Posts: 28
Joined: Sat Jan 24, 2015 10:34 pm
Location: vancouver/kelowna/lethbridge

Re: plant watering

Post by safetyfactorman » Tue Jan 07, 2020 9:23 pm

I'm not sure what your requirements are, but you may find the opensprinkler project of interest.

https://opensprinkler.com/product/opensprinkler-pi/

The software has a c/c++ verson and a python version. I am trying to learn the python version, so I can hack it.

https://rayshobby.net/mediawiki/index.p ... Background

The developers sell a card that plugs into the gpio bus on the raspberry pi. It is also possible to have remote stations. The software could be expanded to become a kinda garden scada, using remote embedded micropython devices.

johnv
Posts: 25
Joined: Sun Nov 10, 2019 6:01 pm

Re: plant watering

Post by johnv » Thu Feb 13, 2020 7:22 pm

Code: Select all

import machine
from machine import Pin
from machine import ADC
import time
from time import sleep

moisture = ADC(0)        #declare soil sensor
pump = Pin(4, Pin.OUT)    #declare pin 4 as output, naming it pump
dry_value = 600                #declare dry_value as 600

while True:                                       #create infinit loop till somthing breaks the true statement
    moisture_value = moisture.read()    #when there are readings from the soil sensor put them in 'moisture_value'
    print(moisture_value)                      #show readings from soil sensor
    sleep(3)                                          #wait for ... seconds
    
    if (moisture_value < dry_value):      #when readings from soil sensor is smaller than 600 then ...
        pump.on()                                  #pin 4 high
        print(pump.value())                      #shows pin state 1 (high)
        sleep(10)                                      #wait ... seconds
        pump.off()                                     #pin 4 (0)low
        sleep(10)                                        #wait 10 seconds
    

hi i'm still struggeling, to grasp how i'm supposed to put the data in to mqtt

do i use the " print(moisture_value)" into the publish topic?

User avatar
pythoncoder
Posts: 3915
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: plant watering

Post by pythoncoder » Fri Feb 14, 2020 5:48 pm

See the official examples such as this one. You will need to convert moisture_value to a bytes instance to publish it, so after connecting to your broker your publication code will look something like

Code: Select all

c.publish(b'moisture', str(moisture).encode())
Peter Hinch

johnv
Posts: 25
Joined: Sun Nov 10, 2019 6:01 pm

Re: plant watering

Post by johnv » Sat Feb 15, 2020 6:44 pm

i apreciate your help, sir! have a great weekend!

Post Reply