MarcusPek
Published

EEP Project

Eep proj

BeginnerProtip45
EEP Project

Things used in this project

Hardware components

M5Stack FIRE V2.7
M5Stack FIRE V2.7
×3
M5Stack RGB Unit with NeoPixel RGB LED (SK6812)
M5Stack RGB Unit with NeoPixel RGB LED (SK6812)
×3
I2C Hub 1 to 6 Expansion TCA9548A Module
M5Stack I2C Hub 1 to 6 Expansion TCA9548A Module
×1
M5stack ENV III
×3
SERVO
×1
PIR Sensor Human Body Infrared PIR Motion Sensor (AS312)
M5Stack PIR Sensor Human Body Infrared PIR Motion Sensor (AS312)
×2

Software apps and online services

UiFLOW

Hand tools and fabrication machines

penknife
Box, General Purpose
Box, General Purpose
Tape, Clear
Tape, Clear

Story

Read more

Schematics

Block Diagram

Code

Main Room

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

setScreenColor(0x000000)
pahub_1 = unit.get(unit.PAHUB, unit.PORTA)
env3_3 = unit.get(unit.ENV3, unit.PAHUB0)
env3_5 = unit.get(unit.ENV3, unit.PAHUB2)
rgb_3 = unit.get(unit.RGB, unit.PORTB)


view = None
pointer = None
lightbar = None
rainrandom = None
i = None



MainLabel1 = M5Title(title="Mainlabel", x=10, fgcolor=0x0d0505, bgcolor=0xbc80f2)
Menu1op1 = M5TextBox(20, 35, "Light", lcd.FONT_Default, 0xFFFFFF, rotate=0)
rectangle0 = M5Rect(95, 160, 28, 2, 0xe80000, 0xff0505)
pointer1 = M5Circle(10, 41, 5, 0x56ff6a, 0x000000)
On = M5TextBox(95, 140, "On ", lcd.FONT_Ubuntu, 0xFFFFFF, rotate=0)
Dim = M5TextBox(145, 140, "Dim", lcd.FONT_Ubuntu, 0xFFFFFF, rotate=0)
Off = M5TextBox(195, 140, "Off", lcd.FONT_Ubuntu, 0xFFFFFF, rotate=0)
Outside = M5TextBox(55, 47, "Outside", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
Inside = M5TextBox(170, 47, "Inside", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
outsidetemp = M5TextBox(70, 75, "Text", lcd.FONT_Ubuntu, 0xFFFFFF, rotate=0)
insidetemp = M5TextBox(180, 75, "Text", lcd.FONT_Ubuntu, 0xFFFFFF, rotate=0)
textforlights = M5TextBox(110, 173, "Double Tap B", lcd.FONT_Ubuntu, 0xFFFFFF, rotate=0)
menu = M5TextBox(45, 107, "Press A To Go Menu", lcd.FONT_Comic, 0xFFFFFF, rotate=0)
outsidehumid = M5TextBox(70, 100, "Text", lcd.FONT_Ubuntu, 0xFFFFFF, rotate=0)
c1 = M5TextBox(113, 75, "C", lcd.FONT_DefaultSmall, 0xFFFFFF, rotate=0)
insidehumid = M5TextBox(180, 100, "Text", lcd.FONT_Ubuntu, 0xFFFFFF, rotate=0)
dot1 = M5Circle(108, 77, 2, 0xFFFFFF, 0xFFFFFF)
c = M5TextBox(224, 75, "C", lcd.FONT_DefaultSmall, 0xFFFFFF, rotate=0)
dot = M5Circle(218, 77, 2, 0xFFFFFF, 0xFFFFFF)
p = M5TextBox(107, 105, "%", lcd.FONT_Default, 0xFFFFFF, rotate=0)
firstpageA = M5TextBox(55, 220, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
p1 = M5TextBox(217, 100, "%", lcd.FONT_Default, 0xFFFFFF, rotate=0)
firstpageB = M5TextBox(145, 220, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
firstpageC = M5TextBox(235, 220, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
Menu1op2 = M5TextBox(20, 60, "Temperature", lcd.FONT_Default, 0xFFFFFF, rotate=0)
sun = M5Circle(30, 147, 15, 0xffb829, 0xffb809)
cloud2 = M5Circle(48, 180, 12, 0x807b7b, 0x807b7b)
cloud1 = M5Circle(62, 176, 17, 0x807b7b, 0x807b7b)
cloud4 = M5Circle(93, 180, 12, 0x807b7b, 0x807b7b)
rain = M5Rect(53, 183, 1, 1, 0x97b6f3, 0x97b6f3)
circle0 = M5Circle(79, 176, 17, 0x807b7b, 0x807b7b)
rectangle1 = M5Rect(78, 183, 1, 1, 0x97b6f3, 0x97b6f3)
rectangle2 = M5Rect(90, 192, 1, 1, 0x97b6f3, 0x97b6f3)
rectangle3 = M5Rect(65, 192, 1, 1, 0x97b6f3, 0x97b6f3)
rectangle4 = M5Rect(104, 183, 1, 1, 0x97b6f3, 0x97b6f3)
rectangle5 = M5Rect(41, 190, 1, 1, 0x97b6f3, 0x97b6f3)

from numbers import Number
import random


# Describe this function...
def swap_page():
  global view, pointer, lightbar, rainrandom, i
  while True:
    if view == 'Menu':
      if pointer == 1 and (btnB.isPressed()):
        view = 'Light Menu'
        SetView()
      else:
        if pointer == 2 and (btnB.isPressed()):
          view = 'Temperature Menu'
          SetView()
        else:
          if pointer == 3 and (btnB.isPressed()):
            view = 'Toilet'
            SetView()
          else:
            pass
    else:
      if view == 'Light Menu':
        if lightbar == 1 and (btnB.wasDoublePress()):
          rgb_3.setBrightness(100)
          rgb_3.setColor(1, 0xffcc33)
        else:
          if lightbar == 2 and (btnB.wasDoublePress()):
            rgb_3.setBrightness(20)
            rgb_3.setColor(1, 0xffcc33)
          else:
            if lightbar == 3 and (btnB.wasDoublePress()):
              rgb_3.setColor(1, 0x000000)
            else:
              pass
      else:
        if view == 'Temperature Menu':
          pahub_1.select_only_on(0)
          pahub_1.select_only_on(2)
          insidetemp.setText(str(int((env3_3.temperature))))
          insidehumid.setText(str(int((env3_3.humidity))))
          outsidetemp.setText(str(int((env3_5.temperature))))
          outsidehumid.setText(str(int((env3_5.humidity))))
          outside()
        else:
          rgb.setColorAll(0x000000)
    wait_ms(2)

# Describe this function...
def outside():
  global view, pointer, lightbar, rainrandom, i
  if view == 'Temperature Menu':
    if (env3_5.humidity) <= 50:
      sun.hide()
      rgb.setColorAll(0x3366ff)
      rain.setBgColor(0x3366ff)
      rectangle1.setBgColor(0x3366ff)
      rectangle2.setBgColor(0x3366ff)
      rectangle3.setBgColor(0x3366ff)
      rectangle4.setBgColor(0x3366ff)
      rectangle5.setBgColor(0x3366ff)
      rainrandom = random.randint(2, 30)
      rain.setSize(height=rainrandom)
      rainrandom = random.randint(2, 30)
      rectangle1.setSize(height=rainrandom)
      rainrandom = random.randint(2, 30)
      rectangle2.setSize(height=rainrandom)
      rainrandom = random.randint(2, 30)
      rectangle3.setSize(height=rainrandom)
      rainrandom = random.randint(2, 30)
      rectangle4.setSize(height=rainrandom)
      rainrandom = random.randint(2, 30)
      rectangle5.setSize(height=rainrandom)
    else:
      rgb.setColorAll(0xffff00)
      rain.hide()
      rectangle1.show()
      rectangle2.show()
      rectangle3.show()
      rectangle4.show()
      rectangle5.show()
      sun.setBgColor(0xffff00)
      cloud2.setBgColor(0xffffff)
      cloud1.setBgColor(0xffffff)
      cloud4.setBgColor(0xffffff)
      circle0.setBgColor(0xffffff)
      cloud2.setBorderColor(0xffffff)
      cloud1.setBorderColor(0xffffff)
      cloud4.setBorderColor(0xffffff)
      circle0.setBorderColor(0xffffff)
      for i in range(15, 26):
        lcd.circle(30, 147, i, color=0xffcc33)
        lcd.circle(30, 147, (i - 1), color=0x000000)
        wait(0.05)
      lcd.circle(30, 147, 25, color=0x000000)
  else:
    rgb.setColorAll(0x000000)

# Describe this function...
def SetView():
  global view, pointer, lightbar, rainrandom, i
  MainLabel1.setTitle(str(view))
  if view == 'Start':
    menu.show()
    Menu1op1.hide()
    Menu1op2.hide()
    On.hide()
    Dim.hide()
    Off.hide()
    Outside.hide()
    outsidetemp.hide()
    outsidehumid.hide()
    insidehumid.hide()
    insidetemp.hide()
    Inside.hide()
    firstpageA.show()
    firstpageB.show()
    firstpageC.show()
    textforlights.hide()
    c1.hide()
    c.hide()
    p.hide()
    p1.hide()
    sun.hide()
    cloud2.hide()
    cloud1.hide()
    cloud4.hide()
    circle0.hide()
    rain.hide()
    rectangle1.hide()
    rectangle2.hide()
    rectangle3.hide()
    rectangle4.hide()
    rectangle5.hide()
    dot1.hide()
    dot.hide()
    pointer1.hide()
    rectangle0.hide()
  else:
    if view == 'Menu':
      menu.hide()
      Menu1op1.show()
      Menu1op2.show()
      On.hide()
      Dim.hide()
      Off.hide()
      Outside.hide()
      Inside.hide()
      outsidetemp.hide()
      insidetemp.hide()
      outsidehumid.hide()
      insidehumid.hide()
      textforlights.hide()
      c1.hide()
      c.hide()
      p.hide()
      p1.hide()
      sun.hide()
      cloud2.hide()
      cloud1.hide()
      cloud4.hide()
      circle0.hide()
      rain.hide()
      rectangle1.hide()
      rectangle2.hide()
      rectangle3.hide()
      rectangle4.hide()
      rectangle5.hide()
      dot1.hide()
      dot.hide()
      rectangle0.hide()
      pointer1.show()
    else:
      if view == 'Light Menu':
        menu.hide()
        Menu1op1.hide()
        Menu1op2.hide()
        On.show()
        Dim.show()
        Off.show()
        Outside.hide()
        Inside.hide()
        outsidetemp.hide()
        insidetemp.hide()
        outsidehumid.hide()
        insidehumid.hide()
        textforlights.show()
        c1.hide()
        c.hide()
        p1.hide()
        sun.hide()
        cloud2.hide()
        cloud1.hide()
        cloud4.hide()
        circle0.hide()
        rain.hide()
        rectangle1.hide()
        rectangle2.hide()
        rectangle3.hide()
        rectangle4.hide()
        rectangle5.hide()
        dot1.hide()
        p.hide()
        dot.hide()
        pointer1.hide()
        rectangle0.show()
      else:
        if view == 'Temperature Menu':
          menu.hide()
          Menu1op1.hide()
          Menu1op2.hide()
          On.hide()
          Dim.hide()
          Off.hide()
          Outside.show()
          Inside.show()
          outsidetemp.show()
          insidetemp.show()
          outsidehumid.show()
          insidehumid.show()
          c1.show()
          sun.show()
          cloud2.show()
          cloud1.show()
          cloud1.show()
          cloud4.show()
          circle0.show()
          rain.show()
          rectangle1.show()
          rectangle2.show()
          rectangle3.show()
          rectangle4.show()
          rectangle5.show()
          dot1.show()
          c.show()
          p.show()
          p1.show()
          dot.show()
          textforlights.hide()
          pointer1.hide()
          rectangle0.hide()
        else:
          pass


def buttonA_wasPressed():
  global view, pointer, lightbar, rainrandom, i
  if view == 'Start':
    view = 'Menu'
    SetView()
  else:
    if view == 'Menu':
      view = 'Start'
      SetView()
    else:
      if view == 'Light Menu':
        view = 'Menu'
        SetView()
      else:
        if view == 'Temperature Menu':
          view = 'Menu'
          SetView()
        else:
          pass
  pass
btnA.wasPressed(buttonA_wasPressed)

def buttonC_wasPressed():
  global view, pointer, lightbar, rainrandom, i
  if view == 'Menu':
    if pointer < 2:
      pointer = (pointer if isinstance(pointer, Number) else 0) + 1
    else:
      pointer = 1
    pointer1.setPosition(10, (16 + 25 * pointer))
  else:
    if view == 'Light Menu':
      if lightbar < 3:
        lightbar = (lightbar if isinstance(lightbar, Number) else 0) + 1
      else:
        lightbar = 1
      rectangle0.setPosition((45 + 50 * lightbar), 160)
      SetView()
    else:
      pass
  pass
btnC.wasPressed(buttonC_wasPressed)


view = 'Start'
pointer = 1
lightbar = 1
firstpageA.setText('A')
firstpageB.setText('B')
firstpageC.setText('C')
SetView()
swap_page()

toilet lights

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

setScreenColor(0x222222)
pir_0 = unit.get(unit.PIR, unit.PORTB)
rgb_1 = unit.get(unit.RGB, unit.PORTA)






PIR = M5TextBox(103, 92, "Text", lcd.FONT_DejaVu56, 0xFFFFFF, rotate=0)


while True:
  if (btnA.isPressed()) and (pir_0.state) == 1:
    PIR.setText('On')
    rgb_1.setBrightness(100)
    rgb_1.setColor(3, 0xffff00)
  else:
    if (pir_0.state) == 0:
      PIR.setText('Off')
      rgb_1.setColor(3, 0x000000)
  wait_ms(2)

Toilet door

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

setScreenColor(0x222222)
env3_4 = unit.get(unit.ENV3, unit.PORTA)
servo_1 = unit.get(unit.SERVO, unit.PORTB)






label0 = M5TextBox(146, 112, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label1 = M5TextBox(172, 112, "%", lcd.FONT_Default, 0xFFFFFF, rotate=0)


while True:
  label0.setText(str(int((env3_4.humidity))))
  label1.setText('%')
  if (env3_4.humidity) > 50:
    servo_1.write_angle(90)
  else:
    servo_1.write_angle(0)
  wait_ms(2)

Credits

MarcusPek
1 project • 0 followers

Comments