This shows you the differences between two versions of the page.
iothings:proiecte:2023sric:smartled [2024/05/30 01:14] dragos.petre [Software Architecture] |
iothings:proiecte:2023sric:smartled [2024/05/30 01:56] (current) dragos.petre [Software] |
||
---|---|---|---|
Line 3: | Line 3: | ||
* Email: <dragso.petre@stud.acs.pub.ro> | * Email: <dragso.petre@stud.acs.pub.ro> | ||
* Master: SCPD | * Master: SCPD | ||
+ | * Video link: [[https://youtu.be/PxzQ7asWBro]] | ||
+ | * Source Code: {{:iothings:proiecte:2023sric:petredragos_sourcecode.zip|}} | ||
===== Overview ===== | ===== Overview ===== | ||
Line 23: | Line 25: | ||
* **Arduino IDE** for code development and Serial Monitor | * **Arduino IDE** for code development and Serial Monitor | ||
* **BLE Scanner Android App** for connecting my phone to the ESP32 board via BLE | * **BLE Scanner Android App** for connecting my phone to the ESP32 board via BLE | ||
+ | |||
+ | === Libraries needed === | ||
+ | * Adafruit_BusIO | ||
+ | * Adafruit_GFX_Library | ||
+ | * Adafruit_NeoPixel | ||
+ | * Adafruit_SSD1306 | ||
+ | * ArduinoBLE | ||
===== Architecture ===== | ===== Architecture ===== | ||
Line 275: | Line 284: | ||
} | } | ||
strip.show(); | strip.show(); | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | === Display setup and printing === | ||
+ | <code cpp> | ||
+ | // OLED display settings | ||
+ | #define SCREEN_WIDTH 128 | ||
+ | #define SCREEN_HEIGHT 32 | ||
+ | #define OLED_RESET -1 | ||
+ | Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); | ||
+ | |||
+ | void setup() { | ||
+ | // Initialize the OLED display | ||
+ | // Address 0x3C for 128x32 OLED display | ||
+ | if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { | ||
+ | Serial.println(F("SSD1306 allocation failed")); | ||
+ | for(;;); | ||
+ | } | ||
+ | display.display(); | ||
+ | delay(2000); // Pause for 2 seconds | ||
+ | display.clearDisplay(); | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | // Update the display with the current status | ||
+ | updateDisplay(); | ||
+ | } | ||
+ | |||
+ | // Update the OLED display with the current status | ||
+ | void updateDisplay() { | ||
+ | display.clearDisplay(); | ||
+ | display.setTextSize(1); | ||
+ | display.setTextColor(SSD1306_WHITE); | ||
+ | |||
+ | // Show if any device is connected | ||
+ | display.setCursor(0, 0); | ||
+ | display.print("Device: "); | ||
+ | display.print(deviceConnected ? "Connected" : "Disconnected"); | ||
+ | |||
+ | // Show if the lights are on or off | ||
+ | display.setCursor(0, 10); | ||
+ | display.print("Lights: "); | ||
+ | display.print(lightsOn ? "On" : "Off"); | ||
+ | |||
+ | // Show the current lighting mode | ||
+ | display.setCursor(0, 20); | ||
+ | display.print("Mode: "); | ||
+ | display.print(mode.c_str()); | ||
+ | |||
+ | display.display(); | ||
} | } | ||
</code> | </code> | ||
Line 303: | Line 362: | ||
First of all, buy a better development board, one that has at leas a LTR308 module on it. | First of all, buy a better development board, one that has at leas a LTR308 module on it. | ||
After that, I will implement the automatic light detection function and have the lights start automatically when it becomes dark in the room. | After that, I will implement the automatic light detection function and have the lights start automatically when it becomes dark in the room. | ||
+ | I also have to actually fix the connection that I screwed up and had to glue together. | ||
+ | Lastly, I have to find a way to mount this thing. | ||
===== Resources ===== | ===== Resources ===== | ||
+ | * IoT Laboratories | ||
+ | * Lots of sites, especially StackOverflow (for debugging ;-)) |