AsyrafHazrieq FirdausAriq Rayyan
Published

SimplyPlant - Data reader for urban farming

Our mission is to develop a cutting-edge solution for urban farming that supports farmers in keeping their plants healthy with timely alerts

IntermediateFull instructions provided180
SimplyPlant - Data reader for urban farming

Things used in this project

Story

Read more

Schematics

Main Circuit

Blocky Code

Blocky Code

Blocky Code

Flowchart

Code

Main M5Stack Code

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

setScreenColor(0x222222)
env2_0 = unit.get(unit.ENV2, unit.PAHUB0)
rgb_0 = unit.get(unit.RGB, unit.PORTC)
earth_0 = unit.get(unit.EARTH, unit.PORTB)
tof_0 = unit.get(unit.TOF, unit.PAHUB1)
pahub_1 = unit.get(unit.PAHUB, unit.PORTA)


temperature = None
humidity = None
moisture = None



label_temp = M5TextBox(40, 20, "Temperature", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
label_humid = M5TextBox(40, 60, "Humidity", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
temp = M5TextBox(230, 20, "C", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
humid = M5TextBox(230, 60, "%", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
label_earth = M5TextBox(40, 100, "Moisture", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
earth = M5TextBox(230, 100, "%", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
distance_label = M5TextBox(40, 140, "Water Level", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
distance = M5TextBox(230, 140, "%", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)

import math




temperature = 24
humidity = 80
moisture = 30.5
while True:
  temp.setText(str((str(("%.2f"%((env2_0.temperature)))) + str('C'))))
  humid.setText(str((str(("%.0f"%((env2_0.humidity)))) + str('%'))))
  earth.setText(str((str(("%.0f"%((((earth_0.analogValue) / 1024) * 100)))) + str('%'))))
  distance.setText(str((str(("%.0f"%((150 - ((tof_0.distance) * 100) / 200)))) + str('%'))))
  if int(round(env2_0.temperature)) > temperature + 3:
    rgb_0.setColor(1, 0xff0000)
  else:
    rgb_0.setColor(1, 0x33ff33)
  if int(round(env2_0.temperature)) < temperature - 3:
    rgb_0.setColor(1, 0x3333ff)
  if int((env2_0.humidity)) > humidity + 10:
    rgb_0.setColor(2, 0xff0000)
  else:
    rgb_0.setColor(2, 0x33ff33)
  if int((env2_0.humidity)) < humidity - 10:
    rgb_0.setColor(2, 0x3333ff)
  if ((earth_0.analogValue) / 1024) * 100 > moisture + 29.5:
    rgb_0.setColor(3, 0xff0000)
  else:
    rgb_0.setColor(3, 0x33ff33)
  if ((earth_0.analogValue) / 1024) * 100 < moisture - 29.5:
    rgb_0.setColor(3, 0x3333ff)
  if 150 - ((tof_0.distance) * 100) / 200 < 40:
    rgb.setColorAll(0xff0000)
  else:
    rgb.setColorAll(0x33ff33)
  wait_ms(2)

Credits

Asyraf
1 project • 2 followers
Contact
Hazrieq Firdaus
1 project • 2 followers
Contact
Ariq Rayyan
1 project • 2 followers
Contact

Comments

Please log in or sign up to comment.