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
4. Source Code
fromPybImportPin, ADC fromds18x20Importds18x20 GL= ADC (Pin ('Y12'))#300 bright-1700 darkSD = ADC (Pin ('Y11'))#1800 Dry-800 wetWD = ds18x20 (Pin ('Y10')) KS= Pin ('Y9', PIN.OUT_PP) JR= Pin ('Y8', PIN.OUT_PP) whileTrue:Print('\ t light intensity:', Gl.read (),'\ t Soil moisture:', Sd.read (),'\ t Current temperature:', Wd.read_temp ()) Pyb.delay (200) ifGl.read () <=250:#Plenty of sunshine ifSd.read () >800:#More WateringKs.value (1) Else: Ks.value (0)elifGl.read () >=1300:#Insufficient Sunlight ifSd.read () >1200:#Less wateringKs.value (1) Else: Ks.value (0)Else:#Sunshine General ifSd.read () >1000:#Normal WateringKs.value (1) Else: Ks.value (0)ifWd.read_temp () <18:#temperature is too lowJr.value (1) Else: Jr.value (0)
TPYBOARDV102 automatic watering system of Micropython example