Smart Industrial Guidance Machine AutoSafety (SIGMA)

We'll be developing a prototype for optimizing safety of workers and equipment in a smart factory.

BeginnerProtip185
Smart Industrial Guidance Machine AutoSafety (SIGMA)

Things used in this project

Story

Read more

Schematics

Block Diagram for SI (Safety Inspector)

Circuit Diagram for SI (Safety Inspector)

Flow chart for SI (Safety Inspector)

Block Diagram for GA (Gateway Admission)

Circuit Diagram for GA (Gateway Admission)

Flow Chart for GA (Gateway Admission)

Block Diagram for MA (Monitoring Ambience)

Circuit Diagram for MA (Monitoring Ambience)

Flow Chart for MA (Machine Ambience)

Code

Python code for SI (Safety Inspector)

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

setScreenColor(0x222222)
env2_0 = unit.get(unit.ENV2, unit.PAHUB0)
tof_0 = unit.get(unit.TOF, unit.PAHUB5)
pahub_0 = unit.get(unit.PAHUB, unit.PORTA)
rgb_0 = unit.get(unit.RGB, unit.PORTB)






title0 = M5Title(title="Environment", x=3, fgcolor=0xFFFFFF, bgcolor=0x0000FF)
label0 = M5TextBox(99, 25, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label2 = M5TextBox(0, 25, "Temperature: ", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label4 = M5TextBox(250, 25, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label5 = M5TextBox(180, 25, "Distance:", lcd.FONT_Default, 0xFFFFFF, rotate=0)
image2 = M5Img(210, 129, "res/default.jpg", True)
label6 = M5TextBox(285, 25, "cm", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label1 = M5TextBox(27, 60, "2", lcd.FONT_Default, 0xfa0303, rotate=0)
label7 = M5TextBox(145, 25, "C", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label3 = M5TextBox(70, 85, "Text", lcd.FONT_Default, 0xff0202, rotate=0)
circle0 = M5Circle(142, 26, 2, 0x000000, 0xFFFFFF)
image3 = M5Img(10, 129, "res/default.jpg", True)
image0 = M5Img(10, 129, "res/default.jpg", True)
image1 = M5Img(110, 129, "res/default.jpg", True)


while True:
  label0.setText(str(env2_0.temperature))
  label4.setText(str(tof_0.distance))
  if (env2_0.temperature) > 29 and (tof_0.distance) < 100:
    rgb.setColorAll(0xff0000)
    label1.hide()
    label3.setText('Danger  Danger Danger')
    speaker.sing(448, 1)
    speaker.setVolume(1)
    image0.changeImg("res/Rad.png")
    image0.show()
    rgb_0.setColor(2, 0xff0000)
    rgb_0.setColor(3, 0xff0000)
    rgb_0.setColor(1, 0xff0000)
    rgb_0.setBrightness(20)
    image1.changeImg("res/Rad.png")
    image1.show()
    image2.changeImg("res/Rad.png")
    image2.show()
    image3.hide()
  else:
    if (env2_0.temperature) > 29:
      image0.hide()
      image1.hide()
      image2.hide()
      speaker.sing(220, 1)
      speaker.setVolume(1)
      label1.setText('!!Critical Temperature Reached!!')
      label3.setText('!!Please Stop The Operation!!')
      label3.setColor(0xff0000)
      rgb_0.setColor(2, 0xff0000)
      rgb_0.setBrightness(20)
      rgb_0.setColor(1, 0xff0000)
      rgb_0.setColor(3, 0xff0000)
      rgb.setColorAll(0x009900)
      image3.changeImg("res/Hightemp.png")
      image3.show()
      wait_ms(100)
      image3.hide()
    else:
      if (tof_0.distance) < 100:
        image0.hide()
        image1.hide()
        image2.hide()
        speaker.sing(220, 1)
        speaker.setVolume(1)
        label1.setText('!!You are too CLOSED to the machine!!')
        label3.setText('!!Please Step Back!!')
        label3.setColor(0xff0000)
        rgb_0.setColor(1, 0x009900)
        rgb_0.setColor(2, 0x009900)
        rgb_0.setColor(3, 0x009900)
        rgb.setColorAll(0xff0000)
        image3.changeImg("res/Warning.png")
        image3.show()
        wait_ms(100)
        image3.hide()
      else:
        image3.hide()
        label3.setText('Everythig is runing smoothly')
        label3.setColor(0x009900)
        label1.hide()
        rgb_0.setColor(1, 0x009900)
        rgb_0.setColor(2, 0x009900)
        rgb_0.setColor(3, 0x009900)
        rgb.setColorAll(0x33cc00)
        image1.changeImg("res/S.png")
        image0.changeImg("res/S.png")
        image2.changeImg("res/S.png")
  wait_ms(2)

Python code for GA (Gateway Admission)

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

setScreenColor(0x222222)
servo_0 = unit.get(unit.SERVO, unit.PORTB)
rfid_1 = unit.get(unit.RFID, unit.PORTA)


a = None



label0 = M5TextBox(118, 91, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label1 = M5TextBox(118, 91, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
image0 = M5Img(91, 140, "res/default.jpg", True)
label2 = M5TextBox(118, 91, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)




servo_0.write_angle(0)
image0.changeImg("res/green_tick.png")
while True:
  label0.setText('Access granted')
  label1.setText('Access denied')
  label2.setText('Please scan your card ')
  a = rfid_1.readUid()
  if a == '2036e911':
    speaker.sing(220, 1)
    speaker.setVolume(1)
    label1.hide()
    label2.hide()
    label0.show()
    image0.show()
    rgb.setColorAll(0x33cc00)
    servo_0.write_angle(90)
    wait(5)
    rgb.setColorAll(0xffff00)
    wait(0.5)
    rgb.setColorAll(0x000000)
    wait(0.5)
    rgb.setColorAll(0xffff00)
    wait(0.5)
    rgb.setColorAll(0x000000)
    wait(0.5)
    rgb.setColorAll(0xff0000)
    wait(0.5)
    rgb.setColorAll(0x000000)
    wait(0.5)
    rgb.setColorAll(0xff0000)
    wait(0.5)
    rgb.setColorAll(0x000000)
    servo_0.write_angle(0)
  elif (rfid_1.isCardOn()) and a != '2036e911':
    speaker.sing(247, 1)
    speaker.setVolume(1)
    label0.hide()
    label2.hide()
    label1.show()
    rgb.setColorAll(0xff0000)
  else:
    rgb.setColorAll(0x000000)
    image0.hide()
    label0.hide()
    label1.hide()
    label2.show()
  wait_ms(2)

Python code for MA (Monitoring Ambience)

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

setScreenColor(0x222222)
env2_0 = unit.get(unit.ENV2, unit.PORTA)
earth_0 = unit.get(unit.EARTH, unit.PORTB)






label0 = M5TextBox(170, 29, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label1 = M5TextBox(170, 82, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label2 = M5TextBox(170, 133, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label3 = M5TextBox(170, 184, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label4 = M5TextBox(57, 29, "Pressure:", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label5 = M5TextBox(32, 82, "Temperature:", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label6 = M5TextBox(57, 133, "Humidity:", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label7 = M5TextBox(54, 184, "Moisture:", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label8 = M5TextBox(58, 210, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label9 = M5TextBox(230, 29, "atm", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label10 = M5TextBox(228, 82, "C", lcd.FONT_Default, 0xFFFFFF, rotate=0)
circle0 = M5Circle(225, 80, 2, 0x222222, 0xFFFFFF)
label11 = M5TextBox(225, 133, "%", lcd.FONT_Default, 0xFFFFFF, rotate=0)


while True:
  label0.setText(str(env2_0.pressure))
  label1.setText(str(env2_0.temperature))
  label2.setText(str(env2_0.humidity))
  label3.setText(str(earth_0.analogValue))
  label8.setText('The moisture level is too high!!!')
  if (earth_0.analogValue) > 50:
    speaker.sing(220, 1)
    speaker.setVolume(1)
    label8.show()
    rgb.setColorAll(0x3333ff)
  else:
    label8.hide()
    rgb.setColorAll(0x000000)
  wait_ms(2)

Credits

Arkar Kyaw

Arkar Kyaw

1 project • 0 followers
Jonathan lim

Jonathan lim

0 projects • 0 followers
Kuan Jonas

Kuan Jonas

0 projects • 0 followers
Jayden Sim Zhong Yi

Jayden Sim Zhong Yi

0 projects • 0 followers

Comments