shernysekaviyaLindy KohWU YIYANChongJiaYi
Published

Smart Greenhouse for Crop Production

We aim to make a product which detects the values of temperature, humidity and light.

BeginnerFull instructions provided2 hours349
Smart Greenhouse for Crop Production

Things used in this project

Story

Read more

Schematics

Flowchart Diagram

Block Diagram

Rooftop & Fan System

Light System

Code

Light system

Python
{"components":[{"id":"____screen","createTime":1675307106228,"name":"screen","x":0,"y":0,"width":320,"height":240,"backgroundColor":"#222222","backgroundImage":"","type":"screen"},{"id":"____buttonA","createTime":1675307106228,"name":"ButtonA","buttonIndex":0,"x":35,"y":216,"width":64,"height":24,"text":"ButtonA","visibility":false,"type":"button"},{"id":"____buttonB","createTime":1675307106228,"name":"ButtonB","buttonIndex":1,"x":125,"y":216,"width":64,"height":24,"text":"ButtonB","visibility":false,"type":"button"},{"id":"____buttonC","createTime":1675307106228,"name":"ButtonC","buttonIndex":2,"x":215,"y":216,"width":64,"height":24,"text":"ButtonC","visibility":false,"type":"button"},{"id":"75sEn#1yvwhK^^bX","createTime":1675312165435,"isCoreTwo":false,"isPaper":false,"name":"light","x":155,"y":199,"color":"#FFFFFF","text":"Detected Light Value","font":"lcd.FONT_Default","rotation":0,"type":"label","layer":6},{"id":"f&kgHx`xgc^jbQr0","createTime":1675917459408,"isCoreTwo":false,"isPaper":false,"name":"label0","x":49,"y":199,"color":"#FFFFFF","text":"Light","font":"lcd.FONT_Default","rotation":0,"type":"label","layer":5},{"id":"@6hX9s!mu$7K=h9y","createTime":1675917752760,"isCoreTwo":false,"isCoreInk":false,"isPaper":false,"name":"image1","x":91,"y":18,"imagePath":"dim.png","visibility":true,"imageInvert":false,"imageThreshold":128,"type":"image","layer":8}],"type":"core","versions":"Beta","units":[{"id":"tzFZ!_q$afh8Svj4","createTime":1675956862878,"stickType":"stick","type":"light","name":"light_1","port":"B","default":["A","B","C","D","Custom"],"user_port":["21","22"],"icon":"light.png"}],"hats":[],"blockly":"<block type=\"basic_on_setup\" id=\"setup_block\" deletable=\"false\" x=\"210\" y=\"70\"><next><block type=\"basic_on_loop\" id=\"Bo__/#wV.[bY6.F`bX%9\"><statement name=\"LOOP\"><block type=\"label_set_text\" id=\"6aL.yS2/v,Li-Ro/@eM;\"><field name=\"COMPONENT\">light</field><value name=\"TEXT\"><shadow type=\"text\" id=\"AcsBd3:[3Y087^+CAMbf\"><field name=\"TEXT\">Hello M5</field></shadow><block type=\"light_a_read\" id=\"L3?/80E..|6ZKz+0$Bv3\"><field name=\"VARNAME\">light_1</field></block></value><next><block type=\"controls_ifelse\" id=\"4mL%S|_X5)D3+3.cTcIJ\"><value name=\"IF0\"><block type=\"logic_compare\" id=\"y$vY,3a}!j[?Ih7H^=Ec\"><field name=\"OP\">LT</field><value name=\"A\"><block type=\"light_a_read\" id=\"qRyEu*Te+^64uxAkK#js\"><field name=\"VARNAME\">light_1</field></block></value><value name=\"B\"><block type=\"math_number\" id=\"=V+*,~L|k:?w[gMFkFK=\"><field name=\"NUM\">300</field></block></value></block></value><statement name=\"DO0\"><block type=\"rgb_set_all\" id=\"h`ru!-DU0Fh*v),U16IL\"><field name=\"COLOR\">#6666cc</field><next><block type=\"rgb_set_brightness\" id=\"L-/tHFZF@;E9-ccuWmZq\"><value name=\"BRIGHTNESS\"><shadow type=\"math_slider\" id=\"AYiwiU)o`vF8G?mZegwZ\"><field name=\"NUM\" max=\"100\" step=\"1\">20</field></shadow></value><next><block type=\"image_set_image\" id=\"n3%,R~Gw@N=eqStVLQ+L\"><field name=\"COMPONENT\">image1</field><field name=\"IMAGE\">default.jpg</field><next><block type=\"timer_delay\" id=\"}O?U!R,E]wNd1(d1t(I]\"><value name=\"DELAY\"><shadow type=\"math_number\" id=\"GqD}m%[dxNVmxP9b=Dr3\"><field name=\"NUM\">1</field></shadow></value></block></next></block></next></block></next></block></statement><statement name=\"ELSE\"><block type=\"rgb_set_brightness\" id=\"h#Y6omtI_Y1@A2`V[jdx\"><value name=\"BRIGHTNESS\"><shadow type=\"math_slider\" id=\"zEsXw[1jucKqlmzX1:b6\"><field name=\"NUM\" max=\"100\" step=\"1\">0</field></shadow></value><next><block type=\"image_set_image\" id=\"uae/aSf8_g-_(+oG65@R\"><field name=\"COMPONENT\">image1</field><field name=\"IMAGE\">default.jpg</field><next><block type=\"timer_delay\" id=\"%,n[G);~gy;sb6)uf.mG\"><value name=\"DELAY\"><shadow type=\"math_number\" id=\"i9asw}Qb?xv$i[!)L~zR\"><field name=\"NUM\">1</field></shadow></value></block></next></block></next></block></statement></block></next></block></statement></block></next></block>","Blockly.Remotes":[],"Blockly.RemotePlus":[{"id":"__title","blockId":"","createTime":1675956862878,"name":"M5RemoteTitle","dragAndDrop":false,"resizable":false,"options":{"minWidth":1,"minHeight":1,"maxWidth":6,"maxHeight":10,"defaultWidth":2,"defaultHeight":1},"w":2,"h":1,"bgColor":"#0080FF","color":"#fff","fontsize":"M","label":"M5Remote","interval":3000,"code":"","event":"","dataSource":"none","ezdataToken":"","topic":"","needShadow":false,"type":"title","x":0,"y":0}],"modules":["rgb"],"cbIdList_":[],"eventCBIdList_":[]}

Automatic rooftop and fans control system

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

setScreenColor(0x222222)
env2_1 = unit.get(unit.ENV2, unit.PORTA)
servo_1 = unit.get(unit.SERVO, unit.PORTB)






Humidity = M5TextBox(196, 45, "Text", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
HUM = M5TextBox(34, 46, "Humidity:", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
TEMP = M5TextBox(34, 109, "Temperature:", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
temperature = M5TextBox(219, 109, "Text", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
Closing = M5TextBox(47, 173, "Rooftop Closing", lcd.FONT_DejaVu24, 0x28ff00, rotate=0)
Opening = M5TextBox(47, 173, "Rooftop Opening", lcd.FONT_DejaVu24, 0xff0000, rotate=0)
humiditystatus = M5TextBox(138, 69, "Humidity Status", lcd.FONT_Default, 0xFFFFFF, rotate=0)
tempstatus = M5TextBox(146, 137, "Temperature Status", lcd.FONT_Default, 0xFFFFFF, rotate=0)
Fanstatus = M5TextBox(118, 214, "Fan On", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)

def buttonA_wasPressed():
  # global params
  rgb.setColorAll(0xcc66cc)
  rgb.setBrightness(10)
  wait(3)
  pass
btnA.wasPressed(buttonA_wasPressed)

def buttonB_wasPressed():
  # global params
  rgb.setColorAll(0xffff00)
  rgb.setBrightness(10)
  wait(3)
  pass
btnB.wasPressed(buttonB_wasPressed)


while True:
  Humidity.setText(str(env2_1.humidity))
  temperature.setText(str(env2_1.temperature))
  Closing.hide()
  Opening.hide()
  Fanstatus.hide()
  rgb.setBrightness(0)
  if (env2_1.temperature) > 24:
    tempstatus.setText('Temperature too high!')
    if (env2_1.humidity) > 80:
      humiditystatus.setText('Humidity too high!')
      servo_1.write_angle(0)
      Closing.show()
      wait(1)
      Fanstatus.show()
      servo_1.write_angle(90)
      wait(1)
      servo_1.write_angle(0)
      wait(1)
    elif (env2_1.humidity) < 60:
      humiditystatus.setText('Humidity too low!')
      servo_1.write_angle(0)
      Closing.show()
      wait(2)
    else:
      humiditystatus.setText('Humidity normal')
      servo_1.write_angle(0)
      Closing.show()
      wait(2)
  elif (env2_1.temperature) < 18:
    tempstatus.setText('Temperature too low!')
    if (env2_1.humidity) > 80:
      humiditystatus.setText('Humidity too high!')
      servo_1.write_angle(90)
      Opening.show()
      wait(2)
      Fanstatus.show()
      servo_1.write_angle(0)
      wait(2)
      servo_1.write_angle(90)
      wait(2)
      servo_1.write_angle(0)
      wait(2)
    elif (env2_1.humidity) < 60:
      humiditystatus.setText('Humidity too low!')
      servo_1.write_angle(90)
      Closing.show()
      wait(2)
    else:
      humiditystatus.setText('Humidity normal!')
      servo_1.write_angle(0)
      Closing.show()
      wait(2)
  else:
    temperature.setText('Temperature normal!')
    if (env2_1.humidity) > 80:
      humiditystatus.setText('Humidity too high!')
      servo_1.write_angle(0)
      Closing.show()
      wait(2)
    elif (env2_1.humidity) < 60:
      humiditystatus.setText('Humidity too low!')
      servo_1.write_angle(0)
      Closing.show()
      wait(2)
    else:
      humiditystatus.setText('Humidity normal!')
      servo_1.write_angle(90)
      Opening.show()
      wait(2)
  wait_ms(2)

Credits

shernyse

shernyse

1 project • 3 followers
kaviya

kaviya

1 project • 2 followers
Lindy Koh

Lindy Koh

0 projects • 1 follower
WU YIYAN

WU YIYAN

0 projects • 1 follower
ChongJiaYi

ChongJiaYi

0 projects • 2 followers
Thanks to Jia Yi, Yi Yan, Lindy, Kaviya, and Shernyse.

Comments