Danke für deine Rückmeldung.
Alles klar, die GPIO kann ich jetzt auch nur aus dem Web entnehmen. Es ist eine NodeMcu von Makershop.
Das die Pins nicht für alles geeignet sind, habe ich festgestellt, bis ich das ePaper Display endlich ans laufen hatte. Und dann erneut, weil ich kein SoftwareSerial hinbekommen habe. Und Natürlich mehrmals die Problematik, dass das Board an manchen Pins nicht bootet wenn was eingesteckt ist.
Die Sketch ist ziemlich wild, da ich ständig was anderes probiert habe und dann wieder was zurückgebaut habe. Aber bitte, Sketch anbei. Allerdings einiges verfremdet.
#include <ESP8266WiFi.h> // WiFi
#include <ESP8266HTTPClient.h> // WiFi
extern "C" {
#include "user_interface.h"
#include "wpa2_enterprise.h"
#include "c_types.h"
}
#include <GxEPD2_3C.h> // - ePaper
#include <Fonts/FreeMonoBold9pt7b.h> // - ePaper
#define EPD_SS 15 // Chip Select (CS) - ePaper
#define EPD_DC 4 // Data/Command (DC) - ePaper
#define EPD_RST 5 // Reset (RES) - ePaper
#define EPD_BUSY 16 // - ePaper
#define MAX_DISPLAY_BUFFER_SIZE 800 // - ePaper
#define MAX_HEIGHT(EPD) (EPD::HEIGHT <= (MAX_DISPLAY_BUFFER_SIZE / 2) / (EPD::WIDTH / 8) ? EPD::HEIGHT : (MAX_DISPLAY_BUFFER_SIZE / 2) / (EPD::WIDTH / 8)) // - ePaper
GxEPD2_3C<GxEPD2_290c, GxEPD2_290c::HEIGHT> display(GxEPD2_290c( 2, 4, 5, 0));
// ######## Variablen
const int ain=A0; // Capacitive Touch Pin
int inputVal=0; // Touch
int iTouchMenu=0; // Touch Menue Seite
bool toggleZustand = false; // Welcher Zustand gerade aktiv ist
String RfidEmpfangeneDaten;
char c;
char ssid[] = "WLAN";
char username[] = "SmartCoffee@firma.de";
char identity[] = "SmartCoffee@firma.de";
char password[] = "pass";
const char* terminalLocation = "1OG";
String apiKeyValue = "key";
const char* urlGetUsername = "http://IP.../coffee/testrfidpost.php";
uint8_t target_esp_mac[6] = { 0x24, 0x0a, 0xc4, 0x9a, 0x58, 0x28 };
HTTPClient http;
WiFiClient* client;
int httpResponseCode;
String httpRequestData = "";
String getResult = "";
// ######## Variablen
// ############ BILDER ###################
static const unsigned char PROGMEM image_data_cb[] = {
};
static const unsigned char PROGMEM image_data_coffeecup[] = {
};
static const unsigned char PROGMEM image_data_coffeecupred[] = {
};
static const unsigned char PROGMEM image_data_lovecoffeesw[] = {
};
static const unsigned char PROGMEM image_data_lovecoffeered[] = {
};
// ############ BILDER ###################
void setup(){
//Serial.begin(115200); //Start der Debug Konsole
//Serial.println("Starte ePaper Display...");
Serial.begin(9600);
//Serial.begin(9600); // Debugging über USB
// Setting ESP into STATION mode only (no AP mode or dual mode)
wifi_set_opmode(STATION_MODE);
struct station_config wifi_config;
memset(&wifi_config, 0, sizeof(wifi_config));
strcpy((char*)wifi_config.ssid, ssid);
strcpy((char*)wifi_config.password, password);
wifi_station_set_config(&wifi_config);
wifi_set_macaddr(STATION_IF, target_esp_mac);
wifi_station_set_wpa2_enterprise_auth(1);
// Clean up to be sure no old data is still inside
wifi_station_clear_cert_key();
wifi_station_clear_enterprise_ca_cert();
wifi_station_clear_enterprise_identity();
wifi_station_clear_enterprise_username();
wifi_station_clear_enterprise_password();
wifi_station_clear_enterprise_new_password();
wifi_station_set_enterprise_identity((uint8*)identity, strlen(identity));
wifi_station_set_enterprise_username((uint8*)username, strlen(username));
wifi_station_set_enterprise_password((uint8*)password, strlen((char*)password));
wifi_station_connect();
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
//Serial.print(".");
}
display.init(115200);
//showLoveCoffeeScreen();
display.hibernate();
}
void showLoveCoffeeScreen() {
display.setRotation(1);
display.setFullWindow();
display.firstPage();
do {
display.fillScreen(GxEPD_WHITE);
display.setFont(&FreeMonoBold9pt7b);
display.drawBitmap(0, 0, image_data_lovecoffeesw, 280, 107, GxEPD_BLACK);
display.drawBitmap(60, 22, image_data_lovecoffeered, 86, 72, GxEPD_RED);
} while (display.nextPage());
}
void showStartScreen() {
display.setRotation(1);
display.setFullWindow();
display.firstPage();
do {
display.fillScreen(GxEPD_WHITE);
display.setFont(&FreeMonoBold9pt7b);
int16_t x1, y1;
uint16_t w, h;
// Text "Text" in Schwarz
//display.setTextColor(GxEPD_BLACK);
//display.getTextBounds("TEXT", 0, 0, &x1, &y1, &w, &h);
//display.setCursor((display.width() - w) / 2, 30);
//display.setCursor(140, 30);
//display.print("TEXT");
// Text "Smart-Coffee" in Rot
display.setTextColor(GxEPD_RED);
display.getTextBounds("Smart-Coffee", 0, 0, &x1, &y1, &w, &h);
display.setCursor(140, 100);
display.print("Smart-Coffee");
// Text "20ct/Tasse" in Schwarz
display.setTextColor(GxEPD_BLACK);
display.getTextBounds("20ct/Tasse", 0, 0, &x1, &y1, &w, &h);
//display.setCursor((display.width() - w) / 2, 30);
display.setCursor(140, 120);
display.print("20ct/Tasse");
// Kaffee-Logo in Schwarz und rot
display.drawBitmap(110, 0, image_data_..., 200, 82, GxEPD_BLACK);
display.drawBitmap(0, 38, image_data_coffeecup, 120, 104, GxEPD_BLACK);
display.drawBitmap(0, 0, image_data_coffeecupred, 120, 38, GxEPD_RED);
//display.drawBitmap((display.width() - coffee_logo_width) / 2, 100, coffeelogobw, coffee_logo_width, coffee_logo_height, GxEPD_BLACK);
} while (display.nextPage());
}
void loop() {
inputVal=analogRead(ain); // Touch Sensor erfassen
//Serial.print("Analog value: ");
//Serial.println(inputVal);
if(inputVal > 200){
iTouchMenu++;
if(iTouchMenu==1){
setEPaperTextFull("Mein Menue 1");
}
else if(iTouchMenu==2){
setEPaperTextFull("Mein Menue 2");
}
display.hibernate();
}
while (Serial.available() > 0) { //Wenn RFID Daten vorhanden sind
delay(11);
//delay(10); // Kleine Verzögerung zwischen den Zeichen. Wenn Verzögerung zu gering und Karte nicht schnell genug weg genommen wird, wird das TAG 2x gelesen.
c = Serial.read(); // Zeichen einlesen und in Variable speichern
RfidEmpfangeneDaten += c; // Zeichen zu einem String zusammenfassen
setEPaperTextFull(RfidEmpfangeneDaten.c_str());
}
if (RfidEmpfangeneDaten.length() > 20){ // Hier ren, wenn RIF daten empfangen wurden.
//Serial.println(RfidEmpfangeneDaten);
//setEPaperTextFull(RfidEmpfangeneDaten.c_str());
//CardCheck();
showStartScreen();
iTouchMenu=0;
display.hibernate();
}
RfidEmpfangeneDaten = "";
httpResponseCode = 0;
httpRequestData = "";
getResult = "";
};
void CardCheck() // Funktion um die RFID Karte zu pürfen.
{
RfidEmpfangeneDaten = RfidEmpfangeneDaten.substring(1, 13);
//Serial.println("Card ID : " + RfidEmpfangeneDaten);
//Serial.println(WiFi.localIP());
if (WiFi.status() == WL_CONNECTED) {
client = new WiFiClient; //WiFiClientSecure; für HTTPS
//client->setInsecure(); //don't use SSL certificate // Wird nur per HTTPS benötigt
http.begin(*client, urlGetUsername);
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
httpRequestData = "api_key=" + apiKeyValue + "&cardid=" + RfidEmpfangeneDaten + "&location=" + terminalLocation;
//Serial.print("httpRequestData: ");
//Serial.println(httpRequestData);
// Send HTTP POST request
httpResponseCode = http.POST(httpRequestData);
if (httpResponseCode == 200) {
getResult = http.getString();
//Serial.println(getResult + "\n");
//oledSchreiben(getResult);
//display.drawBitmap(0, 0, image_data_coffeecup, 128, 64, 1);
//display.display();
//delay(5000);
//display.clearDisplay();
//display.display();
httpRequestData = "api_key=" + apiKeyValue + "&kuerzel=" + RfidEmpfangeneDaten; // Daten die an die PHP Seite geschickt werden
} else if (httpResponseCode > 0) {
//Serial.print("HTTP Response code: ");
//Serial.println(httpResponseCode);
getResult = http.getString(); // Ausgabe der PHP Seite entgegen nehmen
//Serial.println(getResult + "\n");
} else {
//oledSchreiben("ERROR:" + httpResponseCode);
//Serial.print("Error code: ");
//Serial.println(httpResponseCode);
}
http.end(); // Free resources
} else {
//Serial.println("WiFi Disconnected");
}
RfidEmpfangeneDaten = "";
delay(1000);
Serial.println(" ");
Serial.println("Bring your RFID card closer …");
}
void setEPaperTextFull(const char* mein_text){
display.setRotation(1);
display.setFont(&FreeMonoBold9pt7b);
display.setTextColor(GxEPD_BLACK);
int16_t tbx, tby; uint16_t tbw, tbh;
display.getTextBounds(mein_text, 0, 0, &tbx, &tby, &tbw, &tbh);
// center the bounding box by transposition of the origin:
uint16_t x = ((display.width() - tbw) / 2) - tbx;
uint16_t y = ((display.height() - tbh) / 2) - tby;
display.setFullWindow();
display.firstPage();
do{
display.fillScreen(GxEPD_WHITE);
display.setCursor(x, y);
display.print(mein_text);
}while (display.nextPage());
}