Hallo,
bei dem folgenden Sketch:
#include <LedControl.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <ESP8266WiFi.h>
// ESP8266 Anschluss
#define DIN_ESP D7 // GPIO13
#define CS_ESP D4 // GPIO02
#define CLK_ESP D5 // GPIO14
LedControl lc=LedControl(DIN_ESP,CLK_ESP,CS_ESP,1);
/* we always wait a bit between updates of the display */
unsigned long delaytime=500;
int addr0 = 0; // Adresse 1.Modul
// Replace with your network credentials
const char* ssid = "jbaben";
const char* password = "jbaben1955";
const int analogInPin = A0;
int sensorValue = 0;
int outputValue = 0;
const int UMSCHALT_T = D2;
const int UMSCHALT_D = 9;
// Define NTP Client to get time
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP);
// Variables to save date and time
String formattedDate;
String dayStamp;
String timeStamp;
int date_digit0;
int date_digit1;
int date_digit2;
int date_digit3;
int date_digit4;
int time_digit0;
int time_digit1;
int time_digit2;
int time_digit3;
int time_digit4;
int time_digit5;
int time_digit6;
int time_digit7;
int temp_digit7;
int temp_digit6;
void setup() {
// Initialize Serial Monitor
Serial.begin(115200);
delay(500);
pinMode(UMSCHALT_T, INPUT);
pinMode(UMSCHALT_D, INPUT);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA); //Stationst-Modus --> Esp8266 im Heimnetzwerk einloggen
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
// Print local IP address and start web server
Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
// Initialize a NTPClient to get time
timeClient.begin();
// Set offset time in seconds to adjust for your timezone, for example:
// GMT +1 = 3600
// GMT +2 = 7200 Nelspruit/Sued Afrika
// GMT +8 = 28800
// GMT -1 = -3600
// GMT 0 = 0
timeClient.setTimeOffset(7200);
/*
The MAX72XX is in power-saving mode on startup,
we have to do a wakeup call
*/
// Digit 0
lc.shutdown(0,false);
/* Set the brightness to a medium values */
lc.setIntensity(0,8);
/* and clear the display */
lc.clearDisplay(0);
delay(delaytime);
// Ausgabe Funktion und Version
lc.setChar(addr0, 7,'d', false);
lc.setChar(addr0, 6,'a', false);
lc.setChar(addr0, 5,'t', false);
lc.setChar(addr0, 4,'e', false);
lc.setChar(addr0, 3,'t', false);
lc.setChar(addr0, 2,'i', false);
lc.setChar(addr0, 1,'m', false);
lc.setChar(addr0, 0,'e', false);
delay(2000);
lc.setChar(addr0, 7,'v', false);
lc.setChar(addr0, 6,'e', false);
lc.setChar(addr0, 5,'r', false);
lc.setChar(addr0, 4,'s', false);
lc.setChar(addr0, 3,'i', false);
lc.setChar(addr0, 2,'o', false);
lc.setChar(addr0, 1,'n', false);
lc.setChar(addr0, 0,'1', false);
delay(2000);
lc.clearDisplay(0);
}
void loop() {
while(!timeClient.update()) {
timeClient.forceUpdate();
}
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
int t = outputValue/3 -20;
// Anzeige Temperatur zusammen fuegen t + °C
String zahl;
zahl = t;
String temperatur = zahl + " Grad C";
temp_digit7 = zahl[0] - 48;
temp_digit6 = zahl[1] - 48;
// The formattedDate comes with the following format:
// 2018-05-28T16:00:13Z
// We need to extract date and time
formattedDate = timeClient.getFormattedDate();
//Serial.println(formattedDate);
// Extract date
int splitT = formattedDate.indexOf("T");
dayStamp = formattedDate.substring(0, splitT);
Serial.print("DATE: ");
Serial.println(dayStamp);
// Extract time
timeStamp = formattedDate.substring(splitT+1, formattedDate.length()-1);
Serial.print("HOUR: ");
Serial.println(timeStamp);
date_digit0 = dayStamp[6] - 48;
date_digit1 = dayStamp[5] - 48;
date_digit2 = dayStamp[7];
date_digit3 = dayStamp[9] - 48;
date_digit4 = dayStamp[9] - 48;
Serial.print("date_digit0: ");
Serial.println(date_digit0);
time_digit0 = timeStamp[7] - 48;
time_digit1 = timeStamp[6] - 48;
time_digit2 = timeStamp[5];
time_digit3 = timeStamp[4] - 48;
time_digit4 = timeStamp[3] - 48;
time_digit5 = timeStamp[2];
time_digit6 = timeStamp[1] - 48;
time_digit7 = timeStamp[0] - 48;
lc.clearDisplay(addr0);
if (digitalRead(UMSCHALT_T) == HIGH) {
// Print Temperatur
lc.setDigit(addr0,7,temp_digit7, false);
lc.setDigit(addr0,6,temp_digit6, false);
lc.setChar(addr0,5,' ',false);
lc.setRow(addr0,4,99); // °
lc.setRow(addr0,3,78); // C
delay(2000);
}else {
// Print Time
lc.setDigit(addr0,7,time_digit7, false);
lc.setDigit(addr0,6,time_digit6, false);
lc.setChar(addr0,5,'-', false);
lc.setDigit(addr0,4,time_digit4, false);
lc.setDigit(addr0,3,time_digit3, false);
lc.setChar(addr0,2,'-', false);
lc.setDigit(addr0,1,time_digit1, false);
lc.setDigit(addr0,0,time_digit0, false);
delay(1000);
}
// Print Date
if (digitalRead(UMSCHALT_D) == HIGH) {
lc.clearDisplay(addr0);
lc.setDigit(addr0,7,date_digit4, false);
lc.setDigit(addr0,6,date_digit3, false);
lc.setChar(addr0,5,date_digit2, false);
lc.setDigit(addr0,4,date_digit1, false);
lc.setDigit(addr0,3,date_digit0, false);
delay(2000);
}
}
erhalte ich folgende Meldungen: --> siehe nächsten Beitreag
Ich habe leider dazu keine Lösung gefunden.
Probiert habe ich:
Firewall off
Antivir off
Verzeichnis: C:\arduino-1.8.9 und c:\arduino\arduino-1.8.9
Einen Sketch nur mit der Lib "ledcontrol.h" konnte ich kompilieren
MfG
Juergen B.