IvanChen Yinmax
Published

Urban Farming EEP

This project aims to improve the issue of manpower shortages in the urban farming industry by developing an automated harvesting system.

BeginnerWork in progress125
Urban Farming EEP

Things used in this project

Hardware components

M5Stack FIRE IoT Development Kit (PSRAM 2.0)
M5Stack FIRE IoT Development Kit (PSRAM 2.0)
×1
Light Unit with Photo-resistance
M5Stack Light Unit with Photo-resistance
×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
×1
Earth Module Grove Compatible Soil monitoring
M5Stack Earth Module Grove Compatible Soil monitoring
×1
Time-of-Flight (ToF) VL53L0X Laser Ranging Unit (MCP4725/)
M5Stack Time-of-Flight (ToF) VL53L0X Laser Ranging Unit (MCP4725/)
×1

Software apps and online services

Uiflow desktop IDE and Web IDE
Qubitro
Qubitro

Hand tools and fabrication machines

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

Story

Read more

Schematics

Protoype

Code

Code

Python
from m5stack import *
from m5ui import *
from uiflow import *
import wifiCfg
from m5mqtt import M5mqtt
import json

import time
import unit

setScreenColor(0x000000)
earth_4 = unit.get(unit.EARTH, unit.PORTB)
env3_3 = unit.get(unit.ENV3, unit.PAHUB1)
pbhub_2 = unit.get(unit.PBHUB, unit.PAHUB0)




wifiCfg.doConnect('Ok noted with thanks', 'password124')

Light = M5TextBox(163, 27, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
Humidity = M5TextBox(163, 128, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
Moisture = M5TextBox(163, 76, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label3 = M5TextBox(17, 28, "Light", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label4 = M5TextBox(17, 76, "Moisture", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label5 = M5TextBox(15, 128, "Humidity", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label6 = M5TextBox(15, 177, "Temperature", lcd.FONT_Default, 0xFFFFFF, rotate=0)
Temp = M5TextBox(155, 177, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label8 = M5TextBox(49, 218, "STOP", lcd.FONT_Default, 0xFFFFFF, rotate=0)


if wifiCfg.wlan_sta.isconnected():
  m5mqtt = M5mqtt('f55f2957-ce72-4a2a-b9e4-00bc501a2f4e', 'broker.qubitro.com', 1883, 'f55f2957-ce72-4a2a-b9e4-00bc501a2f4e', '173943995150490178251d255b10320f0511a9dc23200534e765f3276794bcc682371cefb18ff4675205b0915ad9a2e76a3', 300)
  m5mqtt.start()
  while True:
    if (env3_3.temperature) > 25 and (env3_3.humidity) < 80 and (earth_4.analogValue) < 50 and (pbhub_2.analogRead(0)) > 600:
      Moisture.setText('Water the plant')
      Light.setText('Light has issue')
      Humidity.setText('On Humidifier')
      Temp.setText('On Aircon')
      rgb.setColorAll(0xff0000)
      speaker.tone(1800, 200)
      wait_ms(200)
    elif (env3_3.temperature) > 25 and (env3_3.humidity) < 80 and (earth_4.analogValue) < 50 and (pbhub_2.analogRead(0)) < 600:
      Moisture.setText('Water the plant')
      Light.setText('Light is stable')
      Humidity.setText('On Humidifier')
      Temp.setText('On Aircon')
      rgb.setColorAll(0xff0000)
      speaker.tone(1800, 200)
      wait_ms(200)
    elif (env3_3.temperature) > 25 and (env3_3.humidity) < 80 and (earth_4.analogValue) > 50 and (pbhub_2.analogRead(0)) > 600:
      Moisture.setText('Water level stable')
      Light.setText('Light has issue')
      Humidity.setText('On Humidifier')
      Temp.setText('On Aircon')
      rgb.setColorAll(0xff0000)
      speaker.tone(1800, 200)
      wait_ms(200)
    elif (env3_3.temperature) > 25 and (env3_3.humidity) < 80 and (earth_4.analogValue) > 50 and (pbhub_2.analogRead(0)) < 600:
      Moisture.setText('Water level stable')
      Light.setText('Light is stable')
      Humidity.setText('On Humidifier')
      Temp.setText('On Aircon')
      rgb.setColorAll(0xff0000)
      speaker.tone(1800, 200)
      wait_ms(200)
    elif (env3_3.temperature) > 25 and (env3_3.humidity) > 80 and (earth_4.analogValue) < 50 and (pbhub_2.analogRead(0)) > 600:
      Moisture.setText('Water the plant')
      Light.setText('Light has issue')
      Humidity.setText('Humidity level stable')
      Temp.setText('On Aircon')
      rgb.setColorAll(0xff0000)
      speaker.tone(1800, 200)
      wait_ms(200)
    elif (env3_3.temperature) > 25 and (env3_3.humidity) > 80 and (earth_4.analogValue) < 50 and (pbhub_2.analogRead(0)) < 600:
      Moisture.setText('Water the plant')
      Light.setText('Light is stable')
      Humidity.setText('Humidity level stable')
      Temp.setText('On Aircon')
      rgb.setColorAll(0xff0000)
      speaker.tone(1800, 200)
      wait_ms(200)
    elif (env3_3.temperature) > 25 and (env3_3.humidity) > 80 and (earth_4.analogValue) > 50 and (pbhub_2.analogRead(0)) > 600:
      Moisture.setText('Water level stable')
      Light.setText('Light has issue')
      Humidity.setText('Humidity level stable')
      Temp.setText('On Aircon')
      rgb.setColorAll(0xff0000)
      speaker.tone(1800, 200)
      wait_ms(200)
    elif (env3_3.temperature) > 25 and (env3_3.humidity) > 80 and (earth_4.analogValue) > 50 and (pbhub_2.analogRead(0)) < 600:
      Moisture.setText('Water level stable')
      Light.setText('Light is stable')
      Humidity.setText('Humidity level stable')
      Temp.setText('On Aircon')
      rgb.setColorAll(0xff0000)
      speaker.tone(1800, 200)
      wait_ms(200)
    elif (env3_3.temperature) < 25 and (env3_3.humidity) < 80 and (earth_4.analogValue) < 50 and (pbhub_2.analogRead(0)) > 600:
      Moisture.setText('Water the plant')
      Light.setText('Light has issue')
      Humidity.setText('On Humidifier')
      Temp.setText('Temperature is stable')
      rgb.setColorAll(0xff0000)
      speaker.tone(1800, 200)
      wait_ms(200)
    elif (env3_3.temperature) < 25 and (env3_3.humidity) < 80 and (earth_4.analogValue) < 50 and (pbhub_2.analogRead(0)) < 600:
      Moisture.setText('Water the plant')
      Light.setText('Light is stable')
      Humidity.setText('On Humidifier')
      Temp.setText('Temperature is stable')
      rgb.setColorAll(0xff0000)
      speaker.tone(1800, 200)
      wait_ms(200)
    elif (env3_3.temperature) < 25 and (env3_3.humidity) < 80 and (earth_4.analogValue) > 50 and (pbhub_2.analogRead(0)) > 600:
      Moisture.setText('Water level stable')
      Light.setText('Light has issue')
      Humidity.setText('On Humidifier')
      Temp.setText('Temperature is stable')
      rgb.setColorAll(0xff0000)
      speaker.tone(1800, 200)
      wait_ms(200)
    elif (env3_3.temperature) < 25 and (env3_3.humidity) < 80 and (earth_4.analogValue) > 50 and (pbhub_2.analogRead(0)) < 600:
      Moisture.setText('Water level stable')
      Light.setText('Light is stable')
      Humidity.setText('On Humidifier')
      Temp.setText('Temperature is stable')
      rgb.setColorAll(0xff0000)
      speaker.tone(1800, 200)
      wait_ms(200)
    elif (env3_3.temperature) < 25 and (env3_3.humidity) > 80 and (earth_4.analogValue) < 50 and (pbhub_2.analogRead(0)) > 600:
      Moisture.setText('Water the plant')
      Light.setText('Light has issue')
      Humidity.setText('Humidity level stable')
      Temp.setText('Temperature is stable')
      rgb.setColorAll(0xff0000)
      speaker.tone(1800, 200)
      wait_ms(200)
    elif (env3_3.temperature) < 25 and (env3_3.humidity) > 80 and (earth_4.analogValue) < 50 and (pbhub_2.analogRead(0)) < 600:
      Moisture.setText('Water the plant')
      Light.setText('Light is stable')
      Humidity.setText('Humidity level stable')
      Temp.setText('Temperature is stable')
      rgb.setColorAll(0xff0000)
      speaker.tone(1800, 200)
      wait_ms(200)
    elif (env3_3.temperature) < 25 and (env3_3.humidity) > 80 and (earth_4.analogValue) > 50 and (pbhub_2.analogRead(0)) > 600:
      Moisture.setText('Water level stable')
      Light.setText('Light has issue')
      Humidity.setText('Humidity level stable')
      Temp.setText('Temperature is stable')
      rgb.setColorAll(0xff0000)
      speaker.tone(1800, 200)
      wait_ms(200)
    else:
      Moisture.setText('Water level stable')
      Light.setText('Light is stable')
      Humidity.setText('Humidity level stable')
      Temp.setText('Temperature is stable')
      rgb.setColorAll(0x33ff33)
    m5mqtt.publish(str('f55f2957-ce72-4a2a-b9e4-00bc501a2f4e'), str((json.dumps(({'Light':(pbhub_2.analogRead(0)),'Moisture':(earth_4.analogValue),'Humidity':(env3_3.humidity),'Temp.':(env3_3.temperature)})))), 0)
    wait_ms(2)

Credits

Ivan
1 project • 0 followers
Chen Yin
1 project • 1 follower
max
1 project • 0 followers

Comments