

If you need an HTTP request with a content type: application/json, use the following: int httpResponseCode = http.POST("Hello, World!") http.addHeader("Content-Type", "text/plain") If you need an HTTP request with a content type: text/plain Int httpResponseCode = http.POST(httpRequestData) then, use the httpRequestData variable below (for testing purposes without the BME280 sensor) You can comment the httpRequestData variable above + "&location=" + sensorLocation + "&value1=" + String(bme.readTemperature())

String httpRequestData = "api_key=" + apiKeyValue + "&sensor=" + sensorName Http.addHeader("Content-Type", "application/x-www-form-urlencoded") Your Domain name with URL path or IP address with path Serial.println("Could not find a valid BME280 sensor, check wiring or change I2C address!") (you can also pass in a Wire library object like &Wire2) Serial.print("Connected to WiFi network with IP Address: ") If you change the apiKeyValue value, the PHP file /post-esp-data.php also needs to have the same key REPLACE with your Domain name and URL path or IP address with pathĬonst char* serverName = " // Keep this API Key value to be compatible with the PHP code provided in the project page. #ifdef ESP32Ĭonst char* ssid = "replace with your WiFi ssid" Ĭonst char* password = "replace with your WiFi password" Code for ESP8266 Nodemcu with BME 280 sensor.
