Yong Li YanJoy -Shiva Dharaniashley chan
Published

Warehouse monitoring system

Inefficient monitoring of temperature and humidity along with pest monitoring system which results in warehouse items spoiling.

BeginnerFull instructions provided206
Warehouse monitoring system

Things used in this project

Story

Read more

Schematics

Overview Block Diagram

Flowchart 1

Flowchart for 1st M5stack that measures temperature, humidity and light levels

Flowchart 2

Flowchart for M5Stack that measures presence of pests

Prototype

Code

M5Stack Python Code

Python
This is the code for the 1st M5Stack that monitors light, humidity and temperature
from m5stack import *
from m5ui import *
from uiflow import *
import unit

setScreenColor(0x222222)
env3_0 = unit.get(unit.ENV3, unit.PAHUB4)
rfid_0 = unit.get(unit.RFID, unit.PAHUB1)
light_0 = unit.get(unit.LIGHT, unit.PORTB)


T_Value = None
H_Value = None
M_temp = None
M_Light = None
M_Humidity = None
card = None



label0 = M5TextBox(7, 0, "Temp (Celsius)  :", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label1 = M5TextBox(180, 0, "Humidity (%):", lcd.FONT_Default, 0xFFFFFF, rotate=0)
T = M5TextBox(7, 18, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
H = M5TextBox(180, 19, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
rfid = M5TextBox(30, 74, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label2 = M5TextBox(97, 48, "Light:", lcd.FONT_Default, 0xFFFFFF, rotate=0)
img_T = M5Img(22, 100, "res/coolTemp.png", True)
L = M5TextBox(154, 48, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
img_H = M5Img(192, 100, "res/L_HMD.png", True)


# Describe this function...
def dosomething():
  global T_Value, H_Value, M_temp, M_Light, M_Humidity, card
  T.setText(str(M_temp))
  T.show()
  H.setText(str(M_Humidity))
  H.show()
  L.setText(str(M_Light))
  L.show()
  label2.show()
  label1.show()
  label0.show()
  img_T.changeImg("res/coolTemp.png")
  img_H.changeImg("res/L_HMD.png")



T_Value = 23
H_Value = 45
while True:
  M_Light = int((light_0.analogValue))
  M_Humidity = int((env3_0.humidity))
  M_temp = int((env3_0.temperature))
  card = str('e23c7312bf')
  rgb.setColorFrom(6 , 10 ,0x33ff33)
  if M_temp >= T_Value or M_Humidity >= H_Value:
    if M_temp >= T_Value:
      while M_temp >= T_Value:
        T.setText('Abnormal Temperature')
        rgb.setColorFrom(6 , 10 ,0xff0000)
        H.hide()
        L.hide()
        label2.hide()
        label1.hide()
        img_T.changeImg("res/Hightemp.png")
        speaker.tone(1800, 200)
        speaker.setVolume(1)
        rfid.setText('Scan card to disable alarm system!')
        if (rfid_0.readUid()) == card:
          rgb.setColorFrom(6 , 10 ,0x3366ff)
          rfid.setText('Access Granted')
          T_Value = 10000
          dosomething()
    if M_Humidity >= H_Value:
      while M_Humidity >= H_Value:
        H.setText('Abnormal Humidity')
        rgb.setColorFrom(6 , 10 ,0xff0000)
        T.hide()
        L.hide()
        label0.hide()
        label2.hide()
        img_H.changeImg("res/H_HMD.png")
        speaker.tone(1800, 200)
        speaker.setVolume(1)
        rfid.setText('Scan card to disable alarm system!')
        if (rfid_0.readUid()) == card:
          rgb.setColorFrom(6 , 10 ,0x3366ff)
          rfid.setText('Access Granted')
          H_Value = 10000
          dosomething()
  else:
    dosomething()
  if btnA.isPressed():
    T_Value = 23
    H_Value = 45
  wait_ms(2)

M5Stack Python Code 2

Python
2nd M5Stack Pest detection system
from m5stack import *
from m5ui import *
from uiflow import *
import unit

setScreenColor(0x222222)
pir_3 = unit.get(unit.PIR, unit.PORTB)
rgb_3 = unit.get(unit.RGB, unit.PORTB)






label0 = M5TextBox(240, 11, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label2 = M5TextBox(22, 7, "Pest status:", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
label3 = M5TextBox(175, 12, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
image1 = M5Img(58, 50, "res/pest2.png", True)


image1.changeImg("res/pest2.png")
while True:
  label3.setText(str(pir_3.state))
  if (pir_3.state) >= 1:
    rgb_3.setColorFrom(1, 3, 0xff0000)
    label0.setText('Pest Detected!')
    image1.show()
  else:
    rgb_3.setColorFrom(1, 3, 0x33ff33)
    label0.setText('Normal')
    image1.hide()
  wait_ms(2)

Credits

Yong Li Yan

Yong Li Yan

1 project • 0 followers
Joy -

Joy -

0 projects • 0 followers
Shiva Dharani

Shiva Dharani

0 projects • 0 followers
ashley chan

ashley chan

0 projects • 0 followers

Comments