Qi Yun
Published © Apache-2.0

Plant watering system (for urban farming)

Our project seeks to address this challenge by developing a comprehensive system that monitors the vital parameters of plants.

IntermediateFull instructions providedOver 1 day250
Plant watering system (for urban farming)

Things used in this project

Story

Read more

Schematics

implementation

we use a transmitter(to process input) and receiver(to process output)

servo motor

when the soil moisture level is low the servo motor will spin

RGB activitation

when soil moisture if within ideal moist level it will show green

Code

Python code(transmitter)

Python
from m5stack import * from
m5ui
import *
from uiflow import * import espnow import wificfg import unit
ESPNOW Transmit
Show Ul
20
setScreenColor (0x222222)
env2_1 = unit.get(unit. ENV2, unit. PORTA)
end
Data_send = None
wificfg wlan_ap.active(True)
wificfg-wlan_
_sta. active(True)
espnow. init()
labelo = M5TextBox11, 138, "Text", lcd. FONT_DejaVu18, OxFFFFFF, rotate=o)
label1 = M5TextBox(11,
"Text", lcd. FONT_DejaVu18, OxFFFFFF, rotate 0)
DataTransmit = MSTitle(title="DataTransmit", x=6, fgcolor=0XFFFFFF, bgcolor=0x0000FF)
label2 = M5TextBox(11, 28, "Sending data:", lcd. FONT.
label3
_DejaVu18, 0xFFFFFF, rotate=0)
= M5TextBox(11, 109, "Data
Sent:"
, lcd. FONT_DejaVu18, 0xFFFFFF, rotate=0)
label4 = M5TextBox(91, 200,
"Text", lcd. FONT_Default, OXFFFFFF, rotate=0)
def
send
_cb(flag) :
global Data_send
Data_send = flag
label1. setText( 'Yes')
pass
espnow. send_cb(send_cb)
 def buttonA _wasPressed():
global Data_send
Data_send =
'Turn on Sprinkler'
label0. setText(str(Data_send))
espnow. send (id=1, data=str( 'Turn on Sprinkler'))
pass
btnA. wasPressed (buttonA_wasPressed)
def button_wasPressed() :
global Data_send
Data_send =
'Stop Sprinkler'
label. setText(str(Data_send))|
espnow. send (id=1, data str('Stop Sprinkler'))
pass
btnc.wasPressed (button_wasPressed)
v. add
_peer (' f0:08: d1: C7:38:19', id=1)
 setText (str (Data_send))
espnow. send (id=1, data=str('Red RGB'))
else:
Data send = 'Blue RGB'
labelo.setText(strData
send))
spnow. send (id=1, data=str( 'Blue RGB' ))
Show Ul
07/
-_ms (2)

Python code(receiver)

Python
we use another laptop to connect another m5stack and it acts as an receiver
from
m5stack import *
from
mui import *
from
uiflow import *
import espnow import wificfg import
time
import unit
setScreenColor (0x222222)
servoo = unit.get(unit.SERVO, unit.PORTB)
rgb_0 = unit. get(unit.RGB, unit. PORTA)
mac = None
Data_send = None
wificfg.wlan_ap.active(True)
wificfg-wlan_sta.active (True)
espnow.init()
labelo label1
titlee
label2
label3
= M5TextBox(155, 49, "Text", lcd. FONT_Default, OxFFFFFF, rotate=0)
M5 TextBox (170,
125, "Text", lcd.FONT_DejaVu18, OxFFFFFF, rotate=0)
M5Title(title="DataReceive", x=3, fgcolor=0xFFFFFF, bgcolor=0xff0047)
M5TextBox (5, 49,
"Mac Address:", lcd. FONT_Default, OxFFFFFF, rotate=0)
M5TextBox5, 125, "Data
Received:", lcd. FONT
Majalalo , 0xFFFFFF, rotated=0
def recv cb(_): 
global mac, Data_send
mac,
- Data_send
= espnow. recv_data(encoder='str')
label1. setText(str(Data_send))
if Data_send
'Turn on Sprinkler':
while True:|
servo0 write_
angle(0)
servo0.write_angle(180)
wait_ms (2)
elif Data
send
'Stop
Sprinkler':
servol. write_angle(0)
wait (1)
pass
espnow. recv_cb(recv_cb)- defrecv
cb():
global mac, Data send 50
mac,
_send = espnow. recv_data(encoder='str')
Tabe 11.setText(str (Data
_send))
if Data_send == 'Red RGB' :
rgb- _0. setColorAll(0xff0000)54
wait (1)

alif Data_send
== 'Blue RGB':
Show Ul
gb_0.setColorAll(0x33ccff)

wait (1)

Credits

Qi Yun

Qi Yun

0 projects • 0 followers

Comments