JaydenYik kiat TengVicknaeiish
Published

Engineering Exploration Project

Smart-Sleep Assistant created using m5 stack

BeginnerFull instructions provided70
Engineering Exploration Project

Things used in this project

Hardware components

M5Stack FIRE IoT Development Kit (PSRAM 2.0)
M5Stack FIRE IoT Development Kit (PSRAM 2.0)
×2
Light Unit with Photo-resistance
M5Stack Light Unit with Photo-resistance
×1
ENV III Unit with Temperature Humidity Air Pressure Sensor (SHT30+QMP6988)
M5Stack ENV III Unit with Temperature Humidity Air Pressure Sensor (SHT30+QMP6988)
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×2

Hand tools and fabrication machines

Scissor, Electrician
Scissor, Electrician
Tape, Foam
Tape, Foam

Story

Read more

Code

Light sensor code

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

setScreenColor(0x222222)
light_0 = unit.get(unit.LIGHT, unit.PORTB)
servo_0 = unit.get(unit.SERVO, unit.PORTA)


LightLevel = None



label0 = M5TextBox(22, 45, "Too bright", lcd.FONT_DejaVu24, 0xf01f1f, rotate=0)
label1 = M5TextBox(194, 51, "Brightness", lcd.FONT_DejaVu18, 0xe21a1a, rotate=0)
label2 = M5TextBox(22, 129, "Normal", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label3 = M5TextBox(194, 135, "Brightness", lcd.FONT_DejaVu18, 0xffffff, rotate=0)




while True:
  LightLevel = int(((light_0.digitalValue) + 0))
  label2.setText(str(light_0.analogValue))
  if (light_0.analogValue) > 100:
    label0.show()
    label1.hide()
    label2.show()
    label3.hide()
    for count in range(10):
      servo_0.write_angle(90)
  elif (light_0.analogValue) < 100:
    label3.setText(str(light_0.analogValue))
    label0.hide()
    label1.show()
    label2.hide()
    label3.show()
    servo_0.write_angle(0)
  wait_ms(2)

Temperature Sensor code

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

setScreenColor(0x222222)
env2_1 = unit.get(unit.ENV2, unit.PORTA)
servo_1 = unit.get(unit.SERVO, unit.PORTB)


TEMPERATURE = None



label0 = M5TextBox(54, 43, "Too Hot", lcd.FONT_DejaVu18, 0xf30808, rotate=0)
label1 = M5TextBox(57, 107, "Normal", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
label2 = M5TextBox(58, 172, "Too Cold", lcd.FONT_DejaVu18, 0x075ff6, rotate=0)




while True:
  TEMPERATURE = int(((env2_1.temperature) + 0))
  label0.setText(str(env2_1.temperature))
  if (env2_1.temperature) > 27:
    label0.show()
    label1.hide()
    label2.hide()
    servo_1.write_angle(90)
  elif (env2_1.temperature) == 20:
    label0.hide()
    label1.show()
    label2.hide()
  elif (env2_1.temperature) < 15:
    label0.hide()
    label1.hide()
    label2.show()
    servo_1.write_angle(90)
  wait_ms(2)
This the temp

Credits

Jayden
1 project • 0 followers
Yik kiat Teng
1 project • 0 followers
Vicknaeiish
2 projects • 0 followers

Comments