Pushing data from remote ESP8266 to local InfluxDB database

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 :slight_smile:

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);

}

If you would like to connect to the Influx server over the open Internet rather than your local wifi network, then you need to make sure that your Influx server has a public IP address and is accessible publicly. Depending on your setup, you may be able to do this using port forwarding on your router (google that for more info).

Thank you very much svet, I will try it immediately!

Can you share your Arduino coding?..i want to do the same but with the same network…I’m kinda new in database so I have a hard time to sent DHT sensor data using esp8266 to my influxdb that I install in my windows…so I hope you can help me on this