diff --git a/include/FOLYWLIJEOILQ5U.webp b/include/FOLYWLIJEOILQ5U.webp new file mode 100644 index 0000000..e24a96a Binary files /dev/null and b/include/FOLYWLIJEOILQ5U.webp differ diff --git a/include/Screenshot 2024-12-06 at 12-09-41 ESP32 mit Arduino Code programmieren • Wolles Elektronikkiste.png b/include/Screenshot 2024-12-06 at 12-09-41 ESP32 mit Arduino Code programmieren • Wolles Elektronikkiste.png new file mode 100644 index 0000000..2a6c82c Binary files /dev/null and b/include/Screenshot 2024-12-06 at 12-09-41 ESP32 mit Arduino Code programmieren • Wolles Elektronikkiste.png differ diff --git a/platformio.ini b/platformio.ini index a90310c..a9ec7ab 100644 --- a/platformio.ini +++ b/platformio.ini @@ -13,8 +13,8 @@ platform = espressif32 board = lolin32 framework = arduino monitor_speed=115200 -;monitor_filters=time +monitor_filters=time lib_deps = # The exact version adafruit/Adafruit MAX31865 library @ 1.6.2 - adafruit/Adafruit SSD1306 @ 2.5.13 \ No newline at end of file + adafruit/Adafruit SSD1306 @ 2.5.13 diff --git a/src/main.cpp b/src/main.cpp index fb56757..6dc7bd0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -42,11 +42,14 @@ Adafruit_MAX31865 thermo = Adafruit_MAX31865(5, 23, 19, 18); int LED_Blue = 2; + #include #include #include #include #include +#include + #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels @@ -57,6 +60,15 @@ Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); #define NUMFLAKES 10 // Number of snowflakes in the animation example +#define chipSelect 4 + +#define SD_SCK 14 +#define SD_MISO 12 +#define SD_MOSI 13 +#define SD_CS 27 + + + const char* ssid = "MagentaWLAN-RGDO"; const char* password = "93329248424922704583"; const char* NTP_SERVER = "de.pool.ntp.org"; @@ -67,6 +79,8 @@ time_t now; long unsigned lastNTPtime; unsigned long lastEntryTime; +File myFile; + char szZeit[20]; bool getNTPtime(int sec) { @@ -122,6 +136,16 @@ void blink(){ digitalWrite (LED_Blue, HIGH); delay(100); digitalWrite (LED_Blue, !HIGH); +} + +void blinkError(){ + digitalWrite (LED_Blue, HIGH); + delay(50); + digitalWrite (LED_Blue, !HIGH); + delay(50); + digitalWrite (LED_Blue, HIGH); + delay(50); + digitalWrite (LED_Blue, !HIGH); } void drawIST(float wert){ @@ -155,7 +179,16 @@ void drawIST(float wert){ void setup() { Serial.begin(115200); + //pinMode (chipSelect, OUTPUT); + pinMode (LED_Blue, OUTPUT); + /* while (!Serial) { + + ; // wait for serial port to connect. Needed for native USB port only + + + } + */ // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1306 allocation failed")); @@ -165,7 +198,18 @@ void setup() { display.ssd1306_command(SSD1306_SETCONTRAST); display.ssd1306_command(8); - delay(1000); + delay(50); + display.clearDisplay(); + display.setTextSize(2); // Normal 1:1 pixel scale + display.setTextColor(WHITE); // Draw white text + display.setCursor(0,0); // Start at top-left corner + + Serial.println("Wait to Wlan."); + display.println("Start."); + display.setTextSize(2); + display.println("Wait to Wlan."); + display.display(); + WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); @@ -173,18 +217,28 @@ void setup() { } Serial.printf("\nConnecting to %s\n", ssid); + + + if(!SD.begin(SD_CS)){ + Serial.println("SD-Card not connected!"); + while(1){ + blinkError(); + }; + } + else{ + Serial.println("SD-Card initialized"); + } + // Clear the buffer display.clearDisplay(); display.setTextSize(2); // Normal 1:1 pixel scale display.setTextColor(WHITE); // Draw white text - display.setCursor(0,0); // Start at top-left corner + display.setCursor(0,0); display.println("--PT1000--"); //display.display(); - - pinMode (LED_Blue, OUTPUT); - digitalWrite (LED_Blue, HIGH); + //digitalWrite (LED_Blue, HIGH); Serial.println("Adafruit MAX31865 PT100 Sensor Test!"); thermo.begin(MAX31865_2WIRE); // set to 2WIRE or 4WIRE as necessary