meta data for this page
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
ixc2025:lappeenranta:team_2:start [2025/05/23 21:05] – [9. Final Code] salim | ixc2025: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 | + | 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 | ||
=== 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' | ||
+ | 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 | |
- | 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), | + | |
- | lcd = I2cLcd(i2c, DEFAULT_I2C_ADDR, | + | |
- | + | ||
- | # Fan motor setup (no button control) | + | |
- | INA = PWM(Pin(19, Pin.OUT), freq=10000) | + | |
- | INB = PWM(Pin(18, Pin.OUT), freq=10000) | + | |
- | + | ||
- | # NeoPixel LED setup | + | |
- | np_pin = Pin(26, Pin.OUT) | + | |
- | np = neopixel.NeoPixel(np_pin, | + | |
- | brightness = 100 | + | |
- | RED = [brightness, | + | |
- | 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// | + | |
- | voltage = adcVal / 4095.0 * 3.3 | + | |
- | print(" | + | |
- | + | ||
- | + | ||
- | if voltage > 0.6: | + | |
- | if WINDOW_OPEN == False: | + | |
- | await LCDDisplay(" | + | |
- | await asyncio.sleep(3) | + | |
- | 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), | + | |
- | lcd = I2cLcd(i2c, DEFAULT_I2C_ADDR, | + | |
- | DHT.measure() | + | |
- | + | ||
- | print(' | + | |
- | if DHT.temperature() > 23: | + | |
- | await asyncio.gather( | + | |
- | LCDDisplay(" | + | |
- | blink_color(RED, | + | |
- | Danger_Ringtone(), | + | |
- | fan_on() | + | |
- | ) | + | |
- | + | ||
- | + | ||
- | async def fan_on(): | + | |
- | INA.duty(0) | + | |
- | INB.duty(700) | + | |
- | + | ||
- | 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, | + | |
- | blink_count = int(duration / (2 * interval)) | + | |
- | 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, | + | |
- | 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(" | + | |
- | lcd.move_to(1, | + | |
- | lcd.putstr(' | + | |
- | await temp_on() | + | |
- | await steam_controller() | + | |
- | + | ||
- | if gasVal == 1: | + | |
- | await LCDDisplay(" | + | |
- | fan_off() | + | |
- | else: | + | |
- | lcd.move_to(1, | + | |
- | lcd.putstr(' | + | |
- | await asyncio.gather( | + | |
- | blink_color(RED, | + | |
- | Danger_Ringtone(), | + | |
- | fan_on() | + | |
- | ) | + | |
- | + | ||
- | await asyncio.sleep(1) | + | |
- | + | ||
- | + | ||
- | 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, | + | |
- | lcd.clear() | + | |
- | lcd.move_to(1, | + | |
- | lcd.putstr(line1) | + | |
- | lcd.move_to(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(" | + | |
- | for i in rc522.uid.uidByte[0: | + | |
- | data += i | + | |
- | print(" | + | |
- | if data == 695: | + | |
- | await asyncio.gather( | + | |
- | LCDDisplay(" | + | |
- | Door_Opening_Ringtone(), | + | |
- | servoMotor(state) | + | |
- | ) | + | |
- | + | ||
- | elif data == 816: | + | |
- | await asyncio.gather( | + | |
- | LCDDisplay(" | + | |
- | Door_Opening_Ringtone(), | + | |
- | servoMotor(state) | + | |
- | ) | + | |
- | else: | + | |
- | print(" | + | |
- | data = 0 | + | |
- | btnVal1 = button1.value() | + | |
- | if btnVal1 == 0: | + | |
- | pwm.duty(angle_0) | + | |
- | print(" | + | |
- | await asyncio.sleep(1) | + | |
- | + | ||
- | + | ||
- | async def main(): | + | |
- | + | ||
- | await asyncio.gather( | + | |
- | GasSensor(), | + | |
- | RFID_Loop() | + | |
- | ) | + | |
- | + | ||
- | asyncio.run(main()) | + | |
- | + |