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
photosensitive module |
Tpyboard v102 |
VCC |
3.3v |
gnd |
< Span class= "Nodeal" >gnd |
a0 |
y12 |
soil Soil Moisture Detection Module |
tpyboard v102 |
VCC |
3.3v |
gnd |
gnd |
a0 |
y11 |
separate two pins are connected to the probe board |
&NBSP; |
Ds18b20 |
Tpyboard v102 |
Vcc |
3.3V |
GND |
GND |
Do |
Y10 |
Relay Module 1 (Control water valve humidification) |
Tpyboard v102 |
Vcc |
Vin |
GND |
GND |
Inch |
Y9 |
Com |
Vin |
NO connection to the electric water valve |
|
Relay Module 2 (Control electric hot Line heating) |
Tpyboard v102 |
Vcc |
Vin |
GND |
GND |
Inch |
Y8 |
COM connected to 220V home powered FireWire |
|
NO connection to the plus line one end |
|
Plus the other end connected to the home power 0-wire |
|
|
|
After the wiring is complete, main.py, boot.py, ds18x20.py, onewire.py are imported into the Tpyboard v102 drive letter to run. Source code
5. Source Code
From Pyb import Pin, ADC
From 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)
Experiment on automatic watering of Micropython Tpyboard v102