zoukankan      html  css  js  c++  java
  • [MicroPython]TPYBoardv102自动浇花系统

    1.系统功能

    监测土壤湿度、环境温度、光照强度
    根据当前环境自动浇水,寒冷天气自动加热土壤

    2.所需元器件

    TPYBoard板子1块
    光敏模块1块
    DS18B20模块1块
    土壤湿度检测模块1块
    杜邦线若干
    继电器2个

    3. 接线方式


    4.源代码

    from pyb import Pin, ADC
    from ds18x20 import DS18X20
      
    gl = ADC(Pin('Y12'))             #300亮-1700暗
    sd = ADC(Pin('Y11'))            #1800干-800湿
    wd = DS18X20(Pin('Y10'))
    ks = Pin('Y9', Pin.OUT_PP)
    jr = Pin('Y8', Pin.OUT_PP)
      
    while True:
           print('	光照强度:',gl.read(),'	土壤湿度:',sd.read(),'	当前温度:',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)
  • 相关阅读:
    02.替换空格 (Java)
    01.二维数组中的查找 (Java)
    css
    CSS Selectors
    Golang Singleton
    TL;DR
    go get
    golang string、int、int64 float 互相转换
    Thrift支持的基本数据类型
    双亲委派模型
  • 原文地址:https://www.cnblogs.com/xiaowuyi/p/9158647.html
Copyright © 2011-2022 走看看