meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ixc2025:lappeenranta:team_2:start [2025/05/23 21:05] – [9. Final Code] salimixc2025:lappeenranta:team_2:start [2025/05/24 13:57] (current) – [5. Future Improvements] salim
Line 5: Line 5:
  
 ==== 1. Group Introduction ==== ==== 1. Group Introduction ====
-==== Smart Inclusive Party House ====+We are Master students of the Software Engineers 4 Green Deal program. 
 +  * (S) Salim - Nigeria 
 +  * (A) Angelina - Russia 
 +  * (T) Tasluf - Bangladesh 
 +  * (A) Ahsan-Ishan - Bangladesh 
 + 
 +We are Team **SATA** 
 +==== Smart Inclusive Social Space ====
  
 === Team Members === === Team Members ===
-=== Tasluf, Ishan, Salim, Angelina​ ===+Tasluf, Ishan, Salim, Angelina​
  
  
Line 108: Line 115:
 ==== 5. Future Improvements ==== ==== 5. Future Improvements ====
  
 +1. Personalized Profiles: To use RFID or user logins to load each individual's preferences (e.g., display language, audio volume, etc.) and adapt the environment accordingly. Also, in the case of smart offices, which allow personalized work environments (smart lighting, climate, adjustable desks), each user tailors their workspace for comfort and productivity.
  
 +2. Gamification & Sustainable Feedback: Integrate real-time environmental feedback and game-like incentives. Display metrics (energy use, air quality, waste) and award points or challenges for eco-friendly actions. Studies show that gamified energy feedback – giving points and friendly competition – significantly boosts motivation to conserve energy. This encourages behavioral change toward sustainability.
 ==== 6. SUSAF Analysis ==== ==== 6. SUSAF Analysis ====
  
Line 146: Line 155:
  
 ==== 9. Final Code ==== ==== 9. Final Code ====
- +Find Code attached in main.rar
-import uasyncio as asyncio +
-from machine import Pin, PWM, SoftI2C, ADC,DAC +
-from mfrc522_i2c import mfrc522 +
-from i2c_lcd import I2cLcd +
-import time +
-import neopixel +
-import machine +
-import dht +
-from time import sleep_ms, ticks_ms +
- +
-# LCD setup +
-DEFAULT_I2C_ADDR = 0x27 +
-i2c = SoftI2C(scl=Pin(22), sda=Pin(21), freq=100000) +
-lcd = I2cLcd(i2c, DEFAULT_I2C_ADDR, 2, 16) +
- +
-# Fan motor setup (no button control) +
-INA = PWM(Pin(19, Pin.OUT), freq=10000)  # IN+ +
-INB = PWM(Pin(18, Pin.OUT), freq=10000)  # IN- +
- +
-# NeoPixel LED setup +
-np_pin = Pin(26, Pin.OUT) +
-np = neopixel.NeoPixel(np_pin, 4) +
-brightness = 100 +
-RED = [brightness, 0, 0] +
-OFF = [0, 0, 0] +
- +
-WINDOW_OPEN = True +
- +
-async def window_open(): +
-    pwm = PWM(Pin(12))   +
-    pwm.freq(50) +
-    pwm.duty(90) +
-    asyncio.sleep(0.5)  +
-        +
-async def window_close(): +
-    pwm = PWM(Pin(12))   +
-    pwm.freq(50) +
-    pwm.duty(25) +
-    asyncio.sleep(0.5) +
-             +
-     +
-async def steam_controller(): +
-    global WINDOW_OPEN +
-    # Turn on and configure the ADC with the range of 0-3.3V  +
-    adc=ADC(Pin(34)) +
-    adc.atten(ADC.ATTN_11DB) +
-    adc.width(ADC.WIDTH_12BIT) +
-     +
-    adcVal=adc.read() +
-    dacVal=adcVal//16 +
-    voltage = adcVal / 4095.0 * 3.3 +
-    print("ADC Val:",adcVal,"DACVal:",dacVal,"Voltage:",voltage,"V", "Window", WINDOW_OPEN) +
-     +
-     +
-    if voltage > 0.6: +
-        if WINDOW_OPEN == False: +
-            await LCDDisplay("Temparature Up", "Dangerous"+
-            await asyncio.sleep(3)  # Delay to let the message show +
-            await window_open() +
-            WINDOW_OPEN = True +
-     +
-    else: +
-        if WINDOW_OPEN == True: +
-            await window_close() +
-            WINDOW_OPEN = False +
-     +
- +
-async def temp_on(): +
-    global WINDOW_OPEN +
-    #Associate DHT11 with Pin(17). +
-    DHT = dht.DHT11(machine.Pin(17)) +
- +
-    #This is the temperature module variable +
-    DEFAULT_I2C_ADDR = 0x27 +
- +
-    i2c = SoftI2C(scl=Pin(22), sda=Pin(21), freq=100000)  +
-    lcd = I2cLcd(i2c, DEFAULT_I2C_ADDR, 2, 16) +
-    DHT.measure() +
-     +
-    print('temperature:',DHT.temperature(),'℃','humidity:',DHT.humidity(),'%', 'Window', WINDOW_OPEN) +
-    if DHT.temperature() > 23: +
-        await asyncio.gather( +
-                LCDDisplay("Temparature Up", "Dangerous"), +
-                blink_color(RED, duration=3, interval=0.3), +
-                Danger_Ringtone(), +
-                fan_on() +
-                ) +
-     +
-         +
-async def fan_on(): +
-    INA.duty(0) +
-    INB.duty(700)  # Speed of fan (0–1023) +
- +
-def fan_off(): +
-    INA.duty(0) +
-    INB.duty(0) +
- +
- +
-def set_color(color): +
-    for i in range(4): +
-        np[i] = color +
-    np.write() +
- +
-async def blink_color(color, duration=3, interval=0.5): +
-    blink_count = int(duration / (2 * interval))  # ON and OFF cycles +
-    for _ in range(blink_count): +
-        set_color(color) +
-        await asyncio.sleep(interval) +
-        set_color(OFF) +
-        await asyncio.sleep(interval) +
- +
- +
- +
-# Servo setup +
- +
-angle_0 = 25 +
-angle_90 = 77 +
-angle_180 = 128 +
- +
-# RFID setup +
-button1 = Pin(16, Pin.IN, Pin.PULL_UP) +
-addr = 0x28 +
-scl = 22 +
-sda = 21 +
-rc522 = mfrc522(scl, sda, addr) +
-rc522.PCD_Init() +
-rc522.ShowReaderDetails() +
- +
-data = 0 +
- +
-# Buzzer setup +
-buzzer_pin = PWM(Pin(32)) +
-buzzer_pin.duty(0) +
- +
-# Gas sensor +
-gas = Pin(23, Pin.IN, Pin.PULL_UP) +
- +
- +
-async def GasSensor(): +
-    while True: +
-        gasVal = gas.value() +
-        print("gas =", gasVal) +
-        lcd.move_to(1, 1) +
-        lcd.putstr('val: {}'.format(gasVal)) +
-        await temp_on() +
-        await steam_controller() +
-         +
-        if gasVal == 1: +
-            await LCDDisplay("Welcome to", "the Party"+
-            fan_off() +
-        else: +
-            lcd.move_to(1, 0) +
-            lcd.putstr('Dangerous    ') +
-            await asyncio.gather( +
-                blink_color(RED, duration=3, interval=0.3), +
-                Danger_Ringtone(), +
-                fan_on() +
-                ) +
-             +
-        await asyncio.sleep(1)  # Let other tasks run +
- +
- +
-async def Door_Opening_Ringtone(): +
-    buzzer_pin.duty(1000) +
-    buzzer_pin.freq(294) +
-    time.sleep(0.25) +
-    buzzer_pin.freq(440) +
-    time.sleep(0.25) +
-    buzzer_pin.freq(392) +
-    time.sleep(0.25) +
-    buzzer_pin.freq(532) +
-    time.sleep(0.25) +
-    buzzer_pin.duty(0) +
-     +
-async def Happy_Birthday_Ringtone(): +
-    buzzer.duty(1000)  +
- +
-    # Happy birthday +
-    buzzer.freq(294) +
-    sleep(0.25) +
-    buzzer.freq(440) +
-    sleep(0.25) +
-    buzzer.freq(392) +
-    sleep(0.25) +
-    buzzer.freq(532) +
-    sleep(0.25) +
-    buzzer.freq(494) +
-    sleep(0.25) +
-    buzzer.freq(392) +
-    sleep(0.25) +
-    buzzer.freq(440) +
-    sleep(0.25) +
-    buzzer.freq(392) +
-    sleep(0.25) +
-    buzzer.freq(587) +
-    sleep(0.25) +
-    buzzer.freq(532) +
-    sleep(0.25) +
-    buzzer.freq(392) +
-    sleep(0.25) +
-    buzzer.freq(784) +
-    sleep(0.25) +
-    buzzer.freq(659) +
-    sleep(0.25) +
-    buzzer.freq(532) +
-    sleep(0.25) +
-    buzzer.freq(494) +
-    sleep(0.25) +
-    buzzer.freq(440) +
-    sleep(0.25) +
-    buzzer.freq(698) +
-    sleep(0.25) +
-    buzzer.freq(659) +
-    sleep(0.25) +
-    buzzer.freq(532) +
-    sleep(0.25) +
-    buzzer.freq(587) +
-    sleep(0.25) +
-    buzzer.freq(532) +
-    sleep(0.5) +
-    buzzer.duty(0) +
-     +
-async def Danger_Ringtone(): +
-    buzzer_pin.duty(1000) +
-    for i in range(1, 10): +
-        buzzer_pin.freq(294) +
-        time.sleep(0.25) +
-    buzzer_pin.duty(0) +
-     +
- +
-async def LCDDisplay(line1, line2): +
-    lcd.clear() +
-    lcd.move_to(1, 0) +
-    lcd.putstr(line1) +
-    lcd.move_to(1, 1) +
-    lcd.putstr(line2) +
- +
- +
-async def servoMotor(state): +
-    pwm = PWM(Pin(5)) +
-    pwm.freq(50) +
-    pwm.duty(angle_0) +
-    time.sleep(3) +
-    pwm.duty(angle_90) +
-    state = 1 +
- +
- +
-async def RFID_Loop(): +
-    global data +
-    global state +
-    state = 0 +
-    while True: +
-        if rc522.PICC_IsNewCardPresent(): +
-            if rc522.PICC_ReadCardSerial(): +
-                print("Card UID:"+
-                for i in rc522.uid.uidByte[0:rc522.uid.size]: +
-                    data += i +
-            print("RFID data:", data) +
-            if data == 695:                 +
-                await asyncio.gather( +
-                    LCDDisplay("Welcome", "Salim"), +
-                    Door_Opening_Ringtone(), +
-                    servoMotor(state) +
-                    ) +
-                 +
-            elif data == 816: +
-                await asyncio.gather( +
-                    LCDDisplay("Welcome", "Angelina"), +
-                    Door_Opening_Ringtone(), +
-                    servoMotor(state) +
-                    ) +
-            else: +
-                print("Unknown card"+
-            data = 0 +
-        btnVal1 = button1.value() +
-        if btnVal1 == 0: +
-            pwm.duty(angle_0) +
-            print("Close"+
-        await asyncio.sleep(1) +
- +
- +
-async def main(): +
-     +
-    await asyncio.gather( +
-        GasSensor(), +
-        RFID_Loop() +
-    ) +
- +
-asyncio.run(main()) +
- +