Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize automatic Flower watering system with Python

Shulou Source: shulou.com Published: 2022-06-01 04:04:51 10月04日 Update

This article mainly explains "Python how to achieve automatic flower watering system", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "Python how to achieve automatic flower watering system" bar!

1. System function

Monitor soil moisture, ambient temperature and light intensity

Automatic watering according to the current environment, automatic heating of soil in cold weather

two。 Required components

1 TPYBoard board

Photosensitive module 1 block

DS18B20 module 1 block

Soil moisture detection module 1

Some DuPont lines

2 relays

3. Connection mode

After the wiring is finished, import main.py, boot.py, ds18x20.py and onewire.py into TPYBoard v102 drive letter to run. Automatic watering experiment code

5. source code

From pyb import Pin, ADCfrom ds18x20 import DS18X20 gl = ADC (Pin ('Y12')) # 300Light-1700 Dark sd = ADC (Pin (' Y11')) # 1800 dry-800Wet wd = DS18X20 (Pin ('Y10')) ks = Pin (' Y9rays, Pin.OUT_PP) jr = Pin ('Y8lighting, Pin.OUT_PP) while True: print ('\ t Light intensity:', gl.read (),'\ t soil moisture:' Sd.read (),'\ t current temperature:' Wd.read_temp () pyb.delay (200) if gl.read () 800: # multiple watering ks.value (1) else: ks.value (0) elif gl.read () > = 1300: # insufficient sunshine if sd.read () > 1200: # less watering Ks.value (1) else: ks.value (0) else: # Sunshine General if sd.read () > 1000: # normal watering ks.value (1) else: ks.value (0) if wd.read_temp ()

Tags: System soil module temperature humidity learning lighting content intensity environment sunlight wiring cold code components functions weather that is ideas situations Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Linux Huawei OPPO Reno MariaDB