/********* Board: DOIT ESP32 DEVKIT V1 / V4 Einstellungen: https://arduino.esp8266.com/stable/package_esp8266com_index.json https://dl.espressif.com/dl/package_esp32_index.json http://dan.drown.org/stm32duino/package_STM32duino_index.json https://dl.espressif.com/dl/package_esp32_index.json BME280 temperature, humidity and pressure sensor; LDR (light dependent resistor – luminosity sensor); 0.96 inch I2C OLED Display; Pushbutton; 12 WS2812B addressable RGB LEDs; Component ESP32 Pin Assignment BME280 GPIO 21 (SDA), GPIO 22 (SCL) OLED Display GPIO 21 (SDA), GPIO 22 (SCL) Light Dependent Resistor (LDR) GPIO 33 Pushbutton GPIO 18 Addressable RGB LEDs GPIO 27 */ #include #include #include #include #include #include #include #include #include // Insert your network credentials const char* ssid = "xxx"; const char* password = "xxx"; // NTP Server Details const char* ntpServer = "pool.ntp.org"; const long gmtOffset_sec = 0; const int daylightOffset_sec = 3600; // OLED Display #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels #define I2Cdisplay_SDA 21 #define I2Cdisplay_SCL 22 TwoWire I2Cdisplay = TwoWire(1); Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &I2Cdisplay, -1); // WS2812B Addressable RGB LEDs #define LED_PIN 27 // GPIO the LEDs are connected to #define LED_COUNT 12 // Number of LEDs Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); // BME280 #define I2C_SDA 21 #define I2C_SCL 22 TwoWire I2CBME = TwoWire(0); Adafruit_BME280 bme; // LDR (Light Dependent Resistor) #define ldr 33 // Pushbutton #define buttonPin 18 int buttonState; // current reading from the input pin int lastButtonState = LOW; // previous reading from the input pin unsigned long lastDebounceTime = 0; // the last time the output pin was toggled unsigned long debounceDelay = 50; // the debounce time; increase if the output flickers // Screens int displayScreenNum = 0; int displayScreenNumMax = 4; unsigned long lastTimer = 0; unsigned long timerDelay = 15000; unsigned char temperature_icon[] ={ 0b00000001, 0b11000000, // ### 0b00000011, 0b11100000, // ##### 0b00000111, 0b00100000, // ### # 0b00000111, 0b11100000, // ###### 0b00000111, 0b00100000, // ### # 0b00000111, 0b11100000, // ###### 0b00000111, 0b00100000, // ### # 0b00000111, 0b11100000, // ###### 0b00000111, 0b00100000, // ### # 0b00001111, 0b11110000, // ######## 0b00011111, 0b11111000, // ########## 0b00011111, 0b11111000, // ########## 0b00011111, 0b11111000, // ########## 0b00011111, 0b11111000, // ########## 0b00001111, 0b11110000, // ######## 0b00000111, 0b11100000, // ###### }; unsigned char humidity_icon[] ={ 0b00000000, 0b00000000, // 0b00000001, 0b10000000, // ## 0b00000011, 0b11000000, // #### 0b00000111, 0b11100000, // ###### 0b00001111, 0b11110000, // ######## 0b00001111, 0b11110000, // ######## 0b00011111, 0b11111000, // ########## 0b00011111, 0b11011000, // ####### ## 0b00111111, 0b10011100, // ####### ### 0b00111111, 0b10011100, // ####### ### 0b00111111, 0b00011100, // ###### ### 0b00011110, 0b00111000, // #### ### 0b00011111, 0b11111000, // ########## 0b00001111, 0b11110000, // ######## 0b00000011, 0b11000000, // #### 0b00000000, 0b00000000, // }; unsigned char arrow_down_icon[] ={ 0b00001111, 0b11110000, // ######## 0b00011111, 0b11111000, // ########## 0b00011111, 0b11111000, // ########## 0b00011100, 0b00111000, // ### ### 0b00011100, 0b00111000, // ### ### 0b00011100, 0b00111000, // ### ### 0b01111100, 0b00111110, // ##### ##### 0b11111100, 0b00111111, // ###### ###### 0b11111100, 0b00111111, // ###### ###### 0b01111000, 0b00011110, // #### #### 0b00111100, 0b00111100, // #### #### 0b00011110, 0b01111000, // #### #### 0b00001111, 0b11110000, // ######## 0b00000111, 0b11100000, // ###### 0b00000011, 0b11000000, // #### 0b00000001, 0b10000000, // ## }; unsigned char sun_icon[] ={ 0b00000000, 0b00000000, // 0b00100000, 0b10000010, // # # # 0b00010000, 0b10000100, // # # # 0b00001000, 0b00001000, // # # 0b00000001, 0b11000000, // ### 0b00000111, 0b11110000, // ####### 0b00000111, 0b11110000, // ####### 0b00001111, 0b11111000, // ######### 0b01101111, 0b11111011, // ## ######### ## 0b00001111, 0b11111000, // ######### 0b00000111, 0b11110000, // ####### 0b00000111, 0b11110000, // ####### 0b00010001, 0b11000100, // # ### # 0b00100000, 0b00000010, // # # 0b01000000, 0b10000001, // # # # 0b00000000, 0b10000000, // # }; // Clear the LEDs void colorWipe(uint32_t color, int wait, int numNeoPixels) { for(int i=0; i debounceDelay) { if (reading != buttonState) { buttonState = reading; if (buttonState == HIGH) { updateScreen(); Serial.println(displayScreenNum); if(displayScreenNum < displayScreenNumMax) { displayScreenNum++; } else { displayScreenNum = 0; } lastTimer = millis(); } } } lastButtonState = reading; // Change screen every 15 seconds (timerDelay variable) if ((millis() - lastTimer) > timerDelay) { updateScreen(); Serial.println(displayScreenNum); if(displayScreenNum < displayScreenNumMax) { displayScreenNum++; } else { displayScreenNum = 0; } lastTimer = millis(); } }