Makerfactory
Published

Smart Plant with M5Stack

Make your plants smart and monitor water, temperature and humidity!

BeginnerFull instructions provided1 hour5,459
Smart Plant with M5Stack

Things used in this project

Story

Read more

Schematics

Smart Plant Schematics

Enviroment sensor: Port A
Earth sensor: Pin 35
Photo resistor: Pin 36

Code

Smart Plant

MicroPython
from m5stack import *
from m5ui import *
from uiflow import *
from easyIO import *
import unit

setScreenColor(0xffffff)
env1 = unit.get(unit.ENV, unit.PORTA)




t = M5TextBox(90, 212, "temp", lcd.FONT_Default,0x000000, rotate=0)
l = M5TextBox(181, 212, "l", lcd.FONT_Default,0x000000, rotate=0)
lf = M5TextBox(245, 212, "lf", lcd.FONT_Default,0x000000, rotate=0)
suntoomuch = M5Img(177, 69, "res/1.JPG", True)
lb = M5TextBox(8, 212, "boden", lcd.FONT_Default,0x000000, rotate=0)
dryair = M5Img(177, 69, "res/2.JPG", True)
wetair = M5Img(176, 63, "res/3.JPG", True)
unhappy = M5Img(12, 69, "res/5.JPG", True)
happymax = M5Img(12, 69, "res/7.JPG", True)
wetground = M5Img(14, 69, "res/12.JPG", True)
dark = M5Img(176, 61, "res/8.JPG", True)
L = M5TextBox(85, 17, "Smart Plant", lcd.FONT_Comic,0x000000, rotate=0)
happy = M5Img(12, 69, "res/10.JPG", True)
sunok = M5Img(176, 65, "res/11.JPG", True)
hot = M5Img(14, 70, "res/9.JPG", True)
cold = M5Img(14, 72, "res/6.JPG", True)

import math

humid_min = None
humid_max = None
temp_min = None
temp_max = None
light_min = None
light_max = None
lfeucht_min = None
lfeucht_max = None
humidity = None
brightness = None
airhumidity = None
temperature = None



suntoomuch.hide()
dryair.hide()
wetair.hide()
unhappy.hide()
happymax.hide()
dark.hide()
happy.hide()
sunok.hide()
hot.hide()
cold.hide()
wetground.hide()
humid_min = 65
humid_max = 90
temp_min = 15
temp_max = 25
light_min = 10
light_max = 90
lfeucht_min = 30
lfeucht_max = 60
while True:
  humidity = round(map_value((analogRead(35)), 0, 970, 0, 100))
  brightness = round(map_value((analogRead(36)), 0, 970, 0, 100))
  airhumidity = env1.humidity
  temperature = env1.temperature
  t.setText(str(('T:' + ((str(temperatur) + 'C')))))
  lf.setText(str(('LF:' + ((str(airhumidity) + '\%')))))
  l.setText(str(('L:' + str(brightness))))
  lb.setText(str(('BF:' + str(humidity))))
  if humidity > humid_max:
    unhappy.show()
    happymax.hide()
    wetground.hide()
    hot.hide()
    cold.hide()
  elif humidity < humid_min:
    wetground.show()
    happymax.hide()
    hot.hide()
    cold.hide()
    unhappy.hide()
  elif temperatur > temp_max:
    hot.show()
    cold.hide()
    happymax.hide()
    unhappy.hide()
    wetground.hide()
  elif temperature < temp_min:
    cold.show()
    hot.hide()
    unhappy.hide()
    happymax.hide()
    wetground.hide()
  else:
    happymax.show()
    hot.hide()
    cold.hide()
    unhappy.hide()
    wetground.hide()
  if brightness > light_max:
    dark.show()
    suntoomuch.hide()
    dryair.hide()
    wetair.hide()
    sunok.hide()
  elif brightness < light_min:
    suntoomuch.show()
    dark.hide()
    dryair.hide()
    wetair.hide()
    sunok.hide()
  elif airhumidity > lfeucht_max:
    wetair.show()
    suntoomuch.hide()
    dark.hide()
    dryair.hide()
    sunok.hide()
  elif airhumidity < lfeucht_min:
    dryair.show()
    suntoomuch.hide()
    dark.hide()
    wetair.hide()
    sunok.hide()
  else:
    sunok.show()
    dryair.hide()
    wetair.hide()
    suntoomuch.hide()
    dark.hide()
  wait(2)
  wait_ms(2)

Credits

Makerfactory

Makerfactory

6 projects • 8 followers
Practice makes perfect.We are designing the future together with our customers.

Comments