Ng Jun MingJorven LiawnavajokPio Goh
Published

UtoFarm Hub: Efficient and Realiable Farming

Our goal is to enhance urban farming with sustainable tech, optimizing resources, reducing costs, and boosting productivity efficiently.

BeginnerFull instructions provided8 hours274
UtoFarm Hub: Efficient and Realiable Farming

Things used in this project

Hardware components

M5Stack FIRE IoT Development Kit (PSRAM 2.0)
M5Stack FIRE IoT Development Kit (PSRAM 2.0)
×2
Earth Module Grove Compatible Soil monitoring
M5Stack Earth Module Grove Compatible Soil monitoring
×1
ENV III Unit with Temperature Humidity Air Pressure Sensor (SHT30+QMP6988)
M5Stack ENV III Unit with Temperature Humidity Air Pressure Sensor (SHT30+QMP6988)
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×2
Dlight Unit - Ambient Light Sensor (BH1750FVI-TR)
M5Stack Dlight Unit - Ambient Light Sensor (BH1750FVI-TR)
×1
CardKB Mini Keyboard Unit MEGA328P GROVE Port
M5Stack CardKB Mini Keyboard Unit MEGA328P GROVE Port
×1

Software apps and online services

M5Stack Uiflow

Hand tools and fabrication machines

Scissor, Electrician
Scissor, Electrician
Hot glue gun (generic)
Hot glue gun (generic)
Tape, Scotch
Tape, Scotch

Story

Read more

Schematics

BlockyCodeMain

MainM5Blocky

BlockyCodeSecondary

SecondaryM5Blocky

Main FlowChart

Main M5 FlowChart

Secondary FlowChart

Secondary M5 FlowChart

Code

Project_Main_M5.py

Python
from m5stack import *
from m5ui import *
from uiflow import *
import unit

setScreenColor(0x222222)
servo_0 = unit.get(unit.SERVO, unit.PORTA)
earth_0 = unit.get(unit.EARTH, unit.PORTB)


Waterlevel = None
Moisture = None



label1 = M5TextBox(12, 18, "MOISTURE", lcd.FONT_Default, 0xFFFFFF, rotate=0)
image1 = M5Img(110, 100, "res/default.jpg", True)
moisturecondition = M5TextBox(146, 213, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label7 = M5TextBox(119, 82, "MOISTURE", lcd.FONT_Default, 0xFFFFFF, rotate=0)
moisture = M5TextBox(257, 17, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)




servo_0.write_angle(60)
while True:
  Moisture = int((earth_0.analogValue))
  moisture.setText(str(Moisture))
  if Moisture >= 50 and Moisture <= 800:
    servo_0.write_angle(60)
    moisturecondition.setText('Okay')
    image1.changeImg("res/Comfortable.png")
    rgb.setColorAll(0x33ff33)
  elif Moisture > 800:
    moisturecondition.setText('High')
    servo_0.write_angle(60)
    image1.changeImg("res/Comfortable.png")
    rgb.setColorAll(0x00cccc)
  elif Moisture < 50:
    moisturecondition.setText('Low')
    servo_0.write_angle(150)
    image1.changeImg("res/Comfortable.png")
    speaker.tone(1800, 100)
    rgb.setColorAll(0xff0000)
  wait_ms(2)

Project Secondary M5.py

Python
from m5stack import *
from m5ui import *
from uiflow import *
import time
import unit

setScreenColor(0x222222)
light_2 = unit.get(unit.LIGHT, unit.PORTB)
servo_1 = unit.get(unit.SERVO, unit.PORTA)
env2_0 = unit.get(unit.ENV2, unit.PORTA)


Angle = None



label0 = M5TextBox(21, 6, "Light Level:", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
image0 = M5Img(31, 88, "res/default.jpg", True)
label1 = M5TextBox(60, 53, "Text", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
label2 = M5TextBox(39, 207, "Text", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
label3 = M5TextBox(184, 6, "Temperature:", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
label4 = M5TextBox(230, 52, "Text", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
image1 = M5Img(205, 88, "res/default.jpg", True)
label5 = M5TextBox(229, 207, "Text", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)




while True:
  label1.setText(str(light_2.analogValue))
  label4.setText(str(env2_0.temperature))
  if (light_2.analogValue) >= 1000:
    label2.setText('Too bright!')
    image0.changeImg("res/default.jpg")
    servo_1.write_angle(90)
    speaker.tone(1800, 200)
    wait_ms(100)
  elif (light_2.analogValue) <= 250:
    label2.setText('Too dark!')
    image0.changeImg("res/default.jpg")
    rgb.setColorAll(0x330033)
    wait_ms(100)
    rgb.setColorAll(0x000099)
  else:
    label1.setText(str(light_2.analogValue))
    label2.setText('All good!')
    image0.changeImg("res/default.jpg")
    rgb.setColorAll(0x000000)
    servo_1.write_angle(0)
  if (env2_0.temperature) >= 21 and (env2_0.temperature) <= 32:
    label5.setText('All good!')
    image1.changeImg("res/default.jpg")
  elif (env2_0.temperature) < 21:
    label5.setText('too cold!')
    image1.changeImg("res/default.jpg")
  elif (env2_0.temperature) > 32:
    label5.setText('too hot!')
    image1.changeImg("res/default.jpg")
  wait_ms(2)

Credits

Ng Jun Ming
1 project • 1 follower
Jorven Liaw
1 project • 1 follower
navajok
1 project • 1 follower
Pio Goh
1 project • 1 follower

Comments