TPYBOARDV102 automatic watering system of Micropython example

Source: Internet
Author: User

1. System functions

Monitoring of soil moisture, ambient temperature, light intensity
Automatic watering according to current environment, cold weather automatically heats soil

2. Required Components

Tpyboard Board 1 pieces
Photosensitive Module 1 Blocks
DS18B20 Module 1 Block
Soil Moisture Detection Module 1 block
DuPont Line several
Relays 2 X

3. Wiring method


After the wiring is complete, main.py, boot.py, ds18x20.py, onewire.py are imported into the 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 ')) #300亮-1700 Dark SD = ADC (PIN (' Y11 ')) #1800干-800 Wet WD = ds18x20 (Pin (' Y10 ')) KS = Pin (' Y9 ', pin.out_pp) JR = Pin (' Y8 ', PIN.OUT_PP) while true:print (' \ t light intensity: ', gl.read (), ' \ t soil humidity: ', sd.read (), ' \ t current temperature: ', wd.read_temp ()) Pyb.delay (200              ) if Gl.read () <=250: #阳光充足 if Sd.read () >800: #多浇水 ks.value (1)  Else:ks.value (0) elif Gl.read () >=1300: #阳光不足 if Sd.read () >1200:                                  #少浇水 ks.value (1) else:ks.value (0) Else:                     #阳光一般 if Sd.read () >1000: #正常浇水 ks.value (1) Else: Ks.value (0) if Wd.read_temp () <18: #温度过低 jr.value (1) else:jr.value (0) 
   

  

TPYBOARDV102 automatic watering system of Micropython example

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.