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:team_1:start [2025/05/15 13:26] – ilmari | ixc2025:team_1:start [2025/05/15 16:29] (current) – karppi | ||
|---|---|---|---|
| Line 4: | Line 4: | ||
| === 1. Group Introduction === | === 1. Group Introduction === | ||
| - | |||
| - | === 2. Initial brainstorming ideas/ | ||
| - | |||
| - | |||
| - | === 3. Day 2 Presentation slides === | ||
| - | |||
| - | |||
| - | === 3. Finalised Idea, description & Functions === | ||
| - | |||
| - | |||
| - | === 4. SUSAF Analysis === | ||
| - | |||
| - | |||
| - | === 5. Power meter measurements === | ||
| - | |||
| - | === 6. Future Improvements === | ||
| - | |||
| - | === 7. Final Day Presentation Slides === | ||
| - | |||
| - | === 8. Final Code === | ||
| - | |||
| - | |||
| So, we called our home " | So, we called our home " | ||
| + | === 2. Initial brainstorming ideas/ | ||
| 🌡️ Smart Climate Control: | 🌡️ Smart Climate Control: | ||
| Line 54: | Line 33: | ||
| Real-time temperature, | Real-time temperature, | ||
| + | |||
| + | === 3. Day 2 Presentation slides === | ||
| + | {{ : | ||
| + | |||
| + | |||
| + | === 3. Finalised Idea, description & Functions === | ||
| + | Home that tracks electricity prices and adapts to it | ||
| + | |||
| + | |||
| + | |||
| + | === 6. Future Improvements === | ||
| + | |||
| + | |||
| + | Ad-Hoc Sensor Networks for Neighborhood Safety: | ||
| + | Emergency Alerts: Nearby homes can communicate to share data about fire, smoke, gas leaks, or intrusions. | ||
| + | Collective Security: Use mesh networks to create a neighborhood-wide alarm system for better safety. | ||
| + | Predictive Maintenance and Analytics: | ||
| + | AI-Based Predictions: | ||
| + | Usage Analytics: Provide insights on energy usage to promote more sustainable habits. | ||
| + | | ||
| + | | ||
| + | Renewable Energy Integration: | ||
| + | Solar and Battery Integration: | ||
| + | Electric Vehicle (EV) Charging Management: Coordinate EV charging when electricity is cheapest. | ||
| + | Waste and Water Management: | ||
| + | Smart Water Meters: Detect leaks and optimize water usage. | ||
| + | Compost and Recycling Guidance: Use sensors to assist in proper waste segregation. | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ===notes=== | ||
| Day 1: We gathered our team members according to our interests and built our smart home. Then we tested a few existing codes. | Day 1: We gathered our team members according to our interests and built our smart home. Then we tested a few existing codes. | ||
| We brainstormed with each other and finally agreed about the main points that we are all going to build for our sustainable home. | We brainstormed with each other and finally agreed about the main points that we are all going to build for our sustainable home. | ||
| Line 85: | Line 99: | ||
| {{: | {{: | ||
| + | === 4. SUSAF Analysis === | ||
| {{: | {{: | ||
| + | === 5. Power meter measurements === | ||
| + | |||
| + | {{: | ||
| + | {{: | ||
| + | |||
| + | |||
| + | === 7. Final Day Presentation Slides === | ||
| + | |||
| + | final ppt | ||
| + | {{ : | ||
| + | |||
| + | |||
| + | === 8. Final Code === | ||
| + | |||
| + | |||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | |||
| + | // WiFi | ||
| + | const char* ssid = " | ||
| + | const char* password = " | ||
| + | |||
| + | |||
| + | // Tilamuuttujat | ||
| + | int screenstate = 0; | ||
| + | float price = 0; | ||
| + | float temperature; | ||
| + | float last_temperature; | ||
| + | float humidity; | ||
| + | float last_humidity; | ||
| + | bool alertcheck = true; | ||
| + | |||
| + | |||
| + | // Rajat | ||
| + | #define PRICE_ALERT_THRESHOLD 20.0 // c/kWh | ||
| + | |||
| + | |||
| + | // Pinimääritykset | ||
| + | #define LED_PIN 26 | ||
| + | #define BUTTON_LEFT_PIN 16 | ||
| + | #define BUTTON_RIGHT_PIN 27 | ||
| + | #define BUZZER_PIN 25 | ||
| + | #define NUM_LEDS 4 | ||
| + | #define DHT_PIN 17 | ||
| + | #define DHT_TYPE DHT11 | ||
| + | |||
| + | |||
| + | // Näyttötilat | ||
| + | #define price_display 0 | ||
| + | #define temperature_display 1 | ||
| + | |||
| + | |||
| + | // Muut globaalit | ||
| + | CRGB leds[NUM_LEDS]; | ||
| + | boolean alertStatus = false; | ||
| + | int display_state = 0; | ||
| + | LiquidCrystal_I2C lcd(0x27, 16, 2); | ||
| + | DHT dht(DHT_PIN, | ||
| + | |||
| + | |||
| + | // Ajastin hintapäivitykselle | ||
| + | unsigned long lastPriceUpdate = 0; | ||
| + | const unsigned long priceInterval = 0.5 * 60 * 1000; // 30 sec | ||
| + | |||
| + | |||
| + | // WiFi-yhteys | ||
| + | void connectwifi() { | ||
| + | WiFi.begin(ssid, | ||
| + | Serial.println(" | ||
| + | |||
| + | |||
| + | while (WiFi.status() != WL_CONNECTED) { | ||
| + | delay(500); | ||
| + | Serial.print(" | ||
| + | } | ||
| + | |||
| + | |||
| + | Serial.println(" | ||
| + | } | ||
| + | |||
| + | |||
| + | // Piippaus | ||
| + | void beepBuzzer() { | ||
| + | tone(BUZZER_PIN, | ||
| + | noTone(BUZZER_PIN); | ||
| + | } | ||
| + | |||
| + | |||
| + | // Hälytys | ||
| + | void alert(String warningMessage, | ||
| + | lcd.clear(); | ||
| + | lcd.setCursor(0, | ||
| + | lcd.print(warningMessage); | ||
| + | |||
| + | |||
| + | while (alertStatus) { | ||
| + | beepBuzzer(); | ||
| + | for (int i = 0; i < NUM_LEDS; i++) { | ||
| + | leds[i] = CRGB:: | ||
| + | } | ||
| + | FastLED.show(); | ||
| + | delay(1000 / freq); | ||
| + | |||
| + | |||
| + | if (digitalRead(BUTTON_LEFT_PIN) == LOW) { | ||
| + | delay(50); // debounce | ||
| + | alertStatus = false; | ||
| + | clearAlert(); | ||
| + | } | ||
| + | |||
| + | |||
| + | for (int i = 0; i < NUM_LEDS; i++) { | ||
| + | leds[i] = CRGB:: | ||
| + | } | ||
| + | FastLED.show(); | ||
| + | delay(1000 / freq); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | |||
| + | // Hälytyksen poisto | ||
| + | void clearAlert() { | ||
| + | alertStatus = false; | ||
| + | lcd.clear(); | ||
| + | for (int i = 0; i < NUM_LEDS; i++) { | ||
| + | leds[i] = CRGB:: | ||
| + | } | ||
| + | FastLED.show(); | ||
| + | alertcheck = false; | ||
| + | } | ||
| + | |||
| + | |||
| + | // Oikean napin painallus | ||
| + | int r_buttonPress() { | ||
| + | if (digitalRead(BUTTON_RIGHT_PIN) == LOW) { | ||
| + | delay(100); // debounce | ||
| + | return 1; | ||
| + | } | ||
| + | return 0; | ||
| + | } | ||
| + | |||
| + | |||
| + | // Näytön päivitys | ||
| + | void screen(int state) { | ||
| + | lcd.clear(); | ||
| + | if (state == temperature_display) { | ||
| + | lcd.setCursor(0, | ||
| + | lcd.print(" | ||
| + | lcd.print(temperature); | ||
| + | lcd.print(" | ||
| + | lcd.setCursor(0, | ||
| + | lcd.print(" | ||
| + | lcd.print(humidity); | ||
| + | lcd.print(" | ||
| + | } else if (state == price_display) { | ||
| + | lcd.setCursor(0, | ||
| + | lcd.print(" | ||
| + | lcd.print(price); | ||
| + | lcd.print(" | ||
| + | } | ||
| + | } | ||
| + | // | ||
| + | float changePrice() { | ||
| + | |||
| + | |||
| + | float newPrice = random(18, 30); // Generoi uusi hinta | ||
| + | |||
| + | |||
| + | if (newPrice > 0.5 || newPrice < -0.05) { | ||
| + | |||
| + | |||
| + | //newPrice = 0.05; // Palauta hinta, jos se karkaa käsistä | ||
| + | |||
| + | |||
| + | } | ||
| + | |||
| + | |||
| + | return newPrice; // Palauta uusi hinta | ||
| + | |||
| + | |||
| + | } | ||
| + | // Hintahaku | ||
| + | float curPrice() { | ||
| + | String priceStr = " | ||
| + | if (WiFi.status() == WL_CONNECTED) { | ||
| + | HTTPClient http; | ||
| + | |||
| + | |||
| + | String date = " | ||
| + | int hour = 14; | ||
| + | |||
| + | |||
| + | String url = " | ||
| + | http.begin(url); | ||
| + | int httpResponseCode = http.GET(); | ||
| + | |||
| + | |||
| + | if (httpResponseCode > 0) { | ||
| + | String payload = http.getString(); | ||
| + | int priceIndex = payload.indexOf(" | ||
| + | if (priceIndex != -1) { | ||
| + | int start = payload.indexOf(":", | ||
| + | int end = payload.indexOf(" | ||
| + | priceStr = payload.substring(start, | ||
| + | priceStr.trim(); | ||
| + | } | ||
| + | } else { | ||
| + | Serial.print(" | ||
| + | Serial.println(httpResponseCode); | ||
| + | } | ||
| + | |||
| + | |||
| + | http.end(); | ||
| + | } | ||
| + | return priceStr.toFloat(); | ||
| + | } | ||
| + | |||
| + | |||
| + | // Alustus | ||
| + | void setup() { | ||
| + | randomSeed(71137); | ||
| + | Serial.begin(115200); | ||
| + | // | ||
| + | |||
| + | |||
| + | lcd.init(); | ||
| + | lcd.backlight(); | ||
| + | dht.begin(); | ||
| + | |||
| + | |||
| + | pinMode(BUZZER_PIN, | ||
| + | digitalWrite(BUZZER_PIN, | ||
| + | |||
| + | |||
| + | FastLED.addLeds< | ||
| + | FastLED.setBrightness(50); | ||
| + | |||
| + | |||
| + | pinMode(BUTTON_LEFT_PIN, | ||
| + | pinMode(BUTTON_RIGHT_PIN, | ||
| + | |||
| + | |||
| + | screen(display_state); | ||
| + | } | ||
| + | |||
| + | |||
| + | // Pääsilmukka | ||
| + | void loop() { | ||
| + | if (millis() - lastPriceUpdate > priceInterval || price == 0) { | ||
| + | price = changePrice(); | ||
| + | lastPriceUpdate = millis(); | ||
| + | alertcheck = true; | ||
| + | } | ||
| + | |||
| + | |||
| + | temperature = dht.readTemperature(); | ||
| + | humidity = dht.readHumidity(); | ||
| + | |||
| + | |||
| + | if (r_buttonPress() == 1) { | ||
| + | delay(50); | ||
| + | display_state = !display_state; | ||
| + | screen(display_state); | ||
| + | } | ||
| + | |||
| + | |||
| + | if (alertcheck && price > PRICE_ALERT_THRESHOLD) { | ||
| + | alertStatus = true; | ||
| + | alert(" | ||
| + | |||
| + | |||
| + | screen(display_state); | ||
| + | } | ||
| + | |||
| + | |||
| + | if ((last_humidity != humidity || last_temperature != temperature)/ | ||
| + | if (humidity <= 100) { | ||
| + | screen(display_state); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | |||
| + | last_temperature = temperature; | ||
| + | last_humidity = humidity; | ||
| + | } | ||
| + | |||