Dear Influx community,
I am currently trying to push data from a remote ESP8266 microcontroller to my InfluxDB database which is located on my computer and hosted locally. I managed to send the data from the ESP to the database, but only if these two are connected to the same WiFi network. I have tried to send the data, but now with the ESP connected to the WiFi-hotspot of my smartphone. Unfortunately, this does not work an I keep receiving the http-error “-1”. I would be very happy, if anyone could help me with this problem
The code I upload to my ESP8266 via the Arduino IDE is the following:
#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>
void setup() {
Serial.begin(115200); //Serial connection
WiFi.begin("iPhone", "xxxxx"); //WiFi connection
while (WiFi.status() != WL_CONNECTED) { //Wait for the WiFI connection completion
delay(700);
Serial.print(".");
}
Serial.println("Connection successful");
}
void loop() {
HTTPClient http; //Declare object of class HTTPClient
http.begin("http://192.xxx.xxx.xxx:8086/write?db=HTTP&precision=s");
http.addHeader("Content-Type", "--data-binary"); //Specify content-type header, I have figured out that it can be left out
String postData = "remote,sensor=SDS011,temp=dht22 valuePM25=14.2";
int httpCode = http.POST(postData);
Serial.println(httpCode);
http.end(); //Close connection
delay(6000);
}