2024-12-0700

Ich gebe es auf mit der SD Karte ................
This commit is contained in:
hans-jurgen 2024-12-07 02:16:49 +01:00
parent 628173b129
commit c359d3a099
2 changed files with 14 additions and 24 deletions

View File

@ -48,7 +48,8 @@ int LED_Blue = 2;
#include <Adafruit_GFX.h> #include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h> #include <Adafruit_SSD1306.h>
#include <WiFi.h> #include <WiFi.h>
#include <SD.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_WIDTH 128 // OLED display width, in pixels
@ -60,12 +61,12 @@ Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#define NUMFLAKES 10 // Number of snowflakes in the animation example #define NUMFLAKES 10 // Number of snowflakes in the animation example
#define chipSelect 4 #define SD_CS_PIN 15 // or 5
#define SD_SCK 14 // These pins will be use for SPI2
#define SD_MISO 12 #define SD_CLK_PIN 14
#define SD_MOSI 13 #define SD_MOSI_PIN 13
#define SD_CS 27 #define SD_MISO_PIN 12
@ -79,8 +80,6 @@ time_t now;
long unsigned lastNTPtime; long unsigned lastNTPtime;
unsigned long lastEntryTime; unsigned long lastEntryTime;
File myFile;
char szZeit[20]; char szZeit[20];
bool getNTPtime(int sec) { bool getNTPtime(int sec) {
@ -148,6 +147,7 @@ void blinkError(){
digitalWrite (LED_Blue, !HIGH); digitalWrite (LED_Blue, !HIGH);
} }
void drawIST(float wert){ void drawIST(float wert){
char msgt[20]; char msgt[20];
dtostrf(wert, 6, 2, msgt); dtostrf(wert, 6, 2, msgt);
@ -179,7 +179,7 @@ void drawIST(float wert){
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
//pinMode (chipSelect, OUTPUT); //PinMode (chipSelect, OUTPUT);
pinMode (LED_Blue, OUTPUT); pinMode (LED_Blue, OUTPUT);
/* while (!Serial) { /* while (!Serial) {
@ -210,6 +210,9 @@ void setup() {
display.println("Wait to Wlan."); display.println("Wait to Wlan.");
display.display(); display.display();
WiFi.disconnect();
delay(100);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password); WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) { while (WiFi.status() != WL_CONNECTED) {
delay(500); delay(500);
@ -218,19 +221,6 @@ void setup() {
Serial.printf("\nConnecting to %s\n", ssid); 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 // Clear the buffer
display.clearDisplay(); display.clearDisplay();
display.setTextSize(2); // Normal 1:1 pixel scale display.setTextSize(2); // Normal 1:1 pixel scale
@ -282,7 +272,7 @@ void loop() {
Serial.print("Ratio = "); Serial.println(ratio,8); Serial.print("Ratio = "); Serial.println(ratio,8);
Serial.print("Resistance = "); Serial.println(RREF*ratio,8); Serial.print("Resistance = "); Serial.println(RREF*ratio,8);
messung = thermo.temperature(RNOMINAL, RREF); messung = thermo.temperature(RNOMINAL, RREF);
Serial.printf("Temperature: %3.1f °C\n", messung); Serial.printf("Temperature: %3.3f °C\n", messung);
drawIST(messung); drawIST(messung);
// Check and print any faults // Check and print any faults
uint8_t fault = thermo.readFault(); uint8_t fault = thermo.readFault();