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


Serial.println("Connection successful");


void loop() {

HTTPClient http;    //Declare object of class HTTPClient


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


http.end();  //Close connection




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!