Hi to all friends... i have one problem and cant figure out what is wrong.
I have one server that i can send and store data to a MySQL Data base
i can send data with an arduino and a Sim800L device through GPRS in my domain ip (working fine)
also i can send and store data to my database with my web Browser if i post this address :
http://192.168.1.110:8000/testing01.php?airtemp=31&airhum=12&battery=1.05
where : 192.168.1.110 is my local ip where my server - data base is connected
: 8000 is the port for the Apache server
: testing01.php is the php file that collects and store the incoming data to the DataBase
I wanted to use a esp32 module that will be connected to the same wifi (local network) and reading some sensors and pass the data to the DataBase
i am using the code below :
#include <WiFi.h>
#include <HTTPClient.h>
// Replace with your network credentials
const char* ssid = "NameOfMyWifi";
const char* password = "MyPassword";
//Your Domain name with URL path or IP address with path
const char* serverName = "http://192.168.1.110:8000/testing01.php?";
// the following variables are unsigned longs because the time, measured in
// milliseconds, will quickly become a bigger number than can be stored in an int.
unsigned long lastTime = 0;
// Set timer to 10 seconds (5000)
unsigned long timerDelay = 10000;
// Variables to send in my Database
int AirTempData = 90;
int AirHumData = 1;
float Battery_Value_voltage = 3.10;
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());
Serial.println("Timer set to 10 secondss (timerDelay variable), it will take 10 seconds before publishing the first reading.");
}
void loop() {
//Send an HTTP POST request every seconds / minutes
if ((millis() - lastTime) > timerDelay) {
//Check WiFi connection status
if (WiFi.status() == WL_CONNECTED) {
WiFiClient client;
HTTPClient http;
// Your Domain name with URL path or IP address with path
http.begin(client, serverName);
// Data to send with HTTP POST
String httpRequestData = "airtemp=" + String(AirTempData) + "&airhum=" + String(AirHumData) + "&battery=" + String(Battery_Value_voltage);
// Send HTTP POST request
int httpResponseCode = http.POST(httpRequestData);
Serial.println(httpResponseCode);
// Free resources
http.end();
}
else {
Serial.println("WiFi Disconnected");
}
lastTime = millis();
}
}
(i used just some variables and not actual data from sensors to make it simple at first)
So with this code i can connect my Esp32 to the wifi network and i am getting also a http Response : 200 (that is good as i know from my Sim800L adventure)
but when i open the data base nothing had stored
what may be wrong ?
Thanks in advance