Hello, I have 2 boards.
1: ESP32 on wifi with this code:
#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "Orange-db8b7";
const char* password = "steva123";
String serverName = "http://micro-power.be/vemat/get_status_bouton.php?opslaan=1";
unsigned long lastTime = 0;
unsigned long timerDelay = 5000;
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.println("Connecting");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to WiFi network with IP Address: ");
Serial.println(WiFi.localIP());
}
void loop() {
if ((millis() - lastTime) > timerDelay) {
if (WiFi.status() == WL_CONNECTED) {
Serial.println("ok");
HTTPClient http;
String serverPath = serverName;
http.begin(serverPath.c_str());
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("Disconnected");
}
lastTime = millis();
}
}
2: ESP32 + enc28j60 (ethernetshield) with this code:
#include <SPI.h>
#include <UIPEthernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char server[] = "micro-power.be";
EthernetClient client;
#include <HTTPClient.h>
String serverName = "http://micro-power.be/vemat/get_status_bouton.php?opslaan=1";
unsigned long lastTime = 0;
unsigned long timerDelay = 5000;
void setup() {
Serial.begin(115200);
if (Ethernet.begin(mac) == 0) {
Ethernet.begin(mac);
}
Serial.println("Connecting.....");
delay(1000);
Serial.println(Ethernet.localIP());
}
void loop() {
if ((millis() - lastTime) > timerDelay) {
if (client.connect(server, 80)) {
Serial.println("ok");
HTTPClient http;
String serverPath = serverName;
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("Disconnected");
}
lastTime = millis();
}
}
The 1 give me an answer '10' and it's just.
the 2 give me the just ip (I have ethernet connection) but I don't receive the '10'.
Where is the problem?
Thx