Habe alles entfernt was mir nicht wichtig ist. ( Anzeigen im Monitor ).
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <MFRC522.h>
#include <SPI.h>
#define SS_PIN D8
#define RST_PIN D2
MFRC522 mfrc522(SS_PIN, RST_PIN);
const char* ssid = "my_SSID";
const char* password = "my_PASSWORD";
const char* serverName = "http://192.168.1.254/tz.php";
String tempzeit = "abccba";
void setup() {
Serial.begin(115200);
SPI.begin();
mfrc522.PCD_Init();
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("Scan a RFID tag...");
}
void loop() {
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}
String rfid_uid = "";
for (byte i = 0; i < mfrc522.uid.size; i++) {
rfid_uid += String(mfrc522.uid.uidByte[i] < 0x10 ? "0" : "");
rfid_uid += String(mfrc522.uid.uidByte[i], DEC);
}
rfid_uid.toUpperCase();
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
String serverPath = String(serverName) + "?tempzeit=" + tempzeit;
Serial.println(serverPath);
http.begin(serverPath);
int httpResponseCode = http.GET();
if (httpResponseCode > 0) {
Serial.print("HTTP Response code: ");
Serial.println(httpResponseCode);
String payload = http.getString();
Serial.println(payload);
} else {
Serial.print("Error code: ");
Serial.println(httpResponseCode);
}
http.end();
} else {
Serial.println("WiFi Disconnected");
}
delay(3000);
}
Mein Ziel ist es Datum und Temparatur erst dann in Tabelle mit dazu gehörenden Chip zu speichern.
Aber erst mal soll mein Sketch nach lesen vom Chip eine verbindung aufbauen mit meinem Webserver worauf eine DB läuft.
C:\Users\ich\Desktop\nrd\nrd.ino: In function 'void loop()':
C:\Users\ich\Desktop\nrd\nrd.ino:41:15: error: call to 'HTTPClient::begin' declared with attribute error: obsolete API, use ::begin(WiFiClient, url)
41 | http.begin(serverPath);
| ~~~~~~~~~~^~~~~~~~~~~~
exit status 1
Compilation error: call to 'HTTPClient::begin' declared with attribute error: obsolete API, use ::begin(WiFiClient, url)
Der Fehler besteht weiter.