Jan Ibrahim
Published © MIT

Dental laboratory gesture control device

A gesture control device that turns on and off lighting, exhaust, and active carbon ventilation system in case of other harmful fumes.

IntermediateFull instructions provided5 hours274
Dental laboratory gesture control device

Things used in this project

Hardware components

PM 2.5 SENSOR USB POWER/SHT20 (PMSA003)
M5Stack PM 2.5 SENSOR USB POWER/SHT20 (PMSA003)
×1
I2C Hub 1 to 6 Expansion TCA9548A Module
M5Stack I2C Hub 1 to 6 Expansion TCA9548A Module
×1
Dlight Unit - Ambient Light Sensor (BH1750FVI-TR)
M5Stack Dlight Unit - Ambient Light Sensor (BH1750FVI-TR)
×1
ENV II Unit with Temperature Humidity Pressure Sensor(SHT30+BMP280)
M5Stack ENV II Unit with Temperature Humidity Pressure Sensor(SHT30+BMP280)
×1
M5Stack I/O Hub 1 to 6 Expansion
×1
LEGO Technic 39369 6252630
×2
LEGO Technic 64179 6300331
×2
LEGO Technic 2780 4121715
×24
LEGO TECHNIC 15M BEAM
×1
PSG-JWS-65
×1
1700-0132
×1
ELECTROLUX Silence PD82-ALRG
×1
RND 560-00156
×1
M5Stack 4-Relay Unit
×1
Adafruit LED Ring Light - 76mm Diameter
×1
M5Stack Unit - Gesture recognition sensor (PAJ7620U2)
×1
PSU-9V1A-MP
×1

Software apps and online services

M5STACK M5FLOW
M5Stack M5Burner

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Schematics

Video 3

Video 2

Video 4

Workspace

Active carbon exhaust

Light ring

Video 1

Code

M5Stack Gesture control

MicroPython
The code is written in micropython but the original code is written in MFlow ( M5Stack ).
from m5stack import *
from m5ui import *
from uiflow import *
import machine
import module

import time
import unit


setScreenColor(0x000000)
gesture_0 = unit.get(unit.GESTURE, unit.PAHUB0)
pahub_0 = unit.get(unit.PAHUB, unit.PORTA)
tvoc_0 = unit.get(unit.TVOC, unit.PAHUB1)
env2_0 = unit.get(unit.ENV2, unit.PAHUB2)
relay4_0 = unit.get(unit.RELAY4, unit.PAHUB3)
dlight_1 = unit.get(unit.DLIGHT, unit.PAHUB4)


get_sensor = None
i = None

pm0 = module.get(module.PM25)

label0 = M5TextBox(0, 0, "T", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label1 = M5TextBox(77, 0, "TEMP", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label2 = M5TextBox(0, 43, "H", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label6 = M5TextBox(0, 131, "LUX", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label3 = M5TextBox(78, 43, "HUMI", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label7 = M5TextBox(77, 131, "LUX", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label8 = M5TextBox(0, 173, "PM2,5", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label4 = M5TextBox(0, 87, "VOC", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label9 = M5TextBox(92, 173, "PM", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label5 = M5TextBox(75, 87, "TVOC", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label10 = M5TextBox(0, 214, "CO2", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label11 = M5TextBox(94, 214, "CO2", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
circle1 = M5Circle(240, 133, 15, 0xff0000, 0x010000)



def buttonC_wasPressed():
  global get_sensor, i
  machine.reset()
  pass
btnC.wasPressed(buttonC_wasPressed)


pahub_0.select_only_on(4)
pahub_0.select_only_on(3)
pahub_0.select_only_on(0)
pahub_0.select_only_on(1)
pahub_0.select_only_on(2)
gesture_0.begin()
gesture_0.set_gesture_highrate(True)
get_sensor = 0
relay4_0.set_mode(1)
relay4_0.set_relay_status(1, 0)
relay4_0.set_relay_status(2, 0)
relay4_0.set_relay_status(3, 0)
relay4_0.set_relay_status(4, 0)
while True:
  label9.setText(str(pm0.get_pm2_5_factory()))
  label7.setText(str(dlight_1.get_lux()))
  label1.setText(str(env2_0.temperature))
  label3.setText(str(env2_0.humidity))
  label5.setText(str(tvoc_0.TVOC))
  label11.setText(str(tvoc_0.eCO2))
  get_sensor = gesture_0.get_gesture()
  if get_sensor==gesture_0.GestureRight:
    circle1.setSize(15)
    for i in range(240, 179, -10):
      circle1.setPosition(i, 133)
      wait_ms(50)
    circle1.setPosition(240, 133)
    circle1.setBgColor(0x33ff33)
    relay4_0.set_relay_status(1, 1)
  elif get_sensor==gesture_0.GestureLeft:
    circle1.setSize(15)
    for i in range(240, 291, 10):
      circle1.setPosition(i, 133)
      relay4_0.set_relay_status(2, 1)
    wait_ms(50)
    circle1.setPosition(240, 133)
    circle1.setBgColor(0x33ff33)
  elif get_sensor==gesture_0.GestureUp:
    circle1.setSize(15)
    for i in range(133, 181, 10):
      circle1.setPosition(240, i)
    wait_ms(50)
    circle1.setPosition(240, 133)
    circle1.setBgColor(0x33ff33)
  elif get_sensor==gesture_0.GestureDown:
    circle1.setSize(15)
    for i in range(133, 79, -10):
      circle1.setPosition(240, i)
      relay4_0.set_relay_status(2, 0)
      wait_ms(50)
    circle1.setPosition(240, 133)
    circle1.setBgColor(0x33ff33)
  elif get_sensor==gesture_0.GestureForward:
    for i in range(15, 66, 5):
      circle1.setSize(i)
      relay4_0.set_relay_status(3, 1)
  elif get_sensor==gesture_0.GestureBackward:
    for i in range(65, 14, -5):
      circle1.setSize(i)
      relay4_0.set_relay_status(3, 0)
  elif get_sensor==gesture_0.GestureWave:
    for i in range(65, 14, -5):
      circle1.setBgColor(0xffff00)
    relay4_0.set_relay_status(2, 1)
    relay4_0.set_relay_status(1, 1)
  else:
    if btnA.isPressed():
      while not (btnB.wasPressed()):
        relay4_0.set_relay_status(3, 0)
        relay4_0.set_relay_status(4, 0)
    else:
      if (tvoc_0.TVOC) > 700:
        circle1.setBgColor(0xcc0000)
        label4.setColor(0xff0000)
        speaker.setVolume(1)
        speaker.tone(4800, 200)
      else:
        circle1.setBgColor(0x33ff33)
        label4.setColor(0x33ff33)
      if (tvoc_0.eCO2) > 700:
        circle1.setBgColor(0xcc0000)
        label10.setColor(0xff0000)
        speaker.setVolume(1)
        speaker.tone(500, 200)
      else:
        circle1.setBgColor(0x33ff33)
        label10.setColor(0x33ff33)
      if (pm0.get_pm2_5_factory()) > 120:
        circle1.setBgColor(0xcc0000)
        label8.setColor(0xff0000)
        speaker.setVolume(1)
        speaker.tone(2000, 200)
      else:
        circle1.setBgColor(0x33ff33)
        label8.setColor(0x33ff33)
        wait_ms(50)
        relay4_0.set_relay_status(1, 0)
      if (tvoc_0.TVOC) > 700 or (tvoc_0.eCO2) > 700 or (pm0.get_pm2_5_factory()) > 120:
        relay4_0.set_relay_status(3, 1)
      else:
        relay4_0.set_relay_status(3, 0)
  if (dlight_1.get_lux()) <= 500:
    circle1.setBgColor(0xcc0000)
    label6.setColor(0xff0000)
    wait_ms(50)
  else:
    circle1.setBgColor(0x33ff33)
    label6.setColor(0x33ff33)
  if (env2_0.temperature) >= 28:
    circle1.setBgColor(0xcc0000)
    label0.setColor(0xff0000)
    relay4_0.set_relay_status(4, 1)
  else:
    circle1.setBgColor(0x33ff33)
    label0.setColor(0x33ff33)
    relay4_0.set_relay_status(4, 0)
  if (env2_0.humidity) >= 70:
    circle1.setBgColor(0xcc0000)
    label2.setColor(0xff0000)
    wait_ms(50)
  else:
    circle1.setBgColor(0x33ff33)
    label2.setColor(0x33ff33)
  wait_ms(2)

Credits

Jan Ibrahim

Jan Ibrahim

4 projects • 20 followers

Comments