Tested with Wemos D1 R2 and Arduino IDE.
You should change ssid, password to your wifi.
Also InfluxDB database name and data you are using.
.....................................................................................................
```c #include <Arduino.h> #include <ESP8266WiFi.h> #include <ESP8266WiFiMulti.h> #include <ESP8266HTTPClient.h> #define USE_SERIAL // Comment this line for no serial const char* ssid = "Your_SSID"; const char* password = "Your_Pass"; ESP8266WiFiMulti WiFiMulti; void setup() { #ifdef USE_SERIAL Serial.begin( 115200 ); #endif WiFi.mode( WIFI_STA ); WiFiMulti.addAP( ssid, password ); } void loop() { if( WiFiMulti.run() == WL_CONNECTED ) // wait for WiFi connection { int sensorValue = analogRead( A0 ); // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 3.2V): float voltage = sensorValue * (3.2/1023.0); #ifdef USE_SERIAL Serial.println( voltage ); #endif HTTPClient http; #ifdef USE_SERIAL Serial.print( "[HTTP] begin...\n" ); #endif // Start writting to influxbd database: mydb // Set database, IP and Port you are using http.begin( "http://192.168.1.33:8086/write?db=mydb" ); // Send data to influxbd // Set data you are using int httpCode = http.POST( "Volts,Bat=Lead-Acid,Ser=pruebas value="+String(voltage) ); #ifdef USE_SERIAL if(httpCode == 204) // Data Succesfully Written { Serial.printf( "Data Succesfully Written... code: %d\n", httpCode ); } else // Data Failed { Serial.printf( "Data Failed... code: %d\n", httpCode ); Serial.printf( "Error: %s\n", http.errorToString(httpCode).c_str() ); } #endif http.end(); } delay( 10000 ); // Wait for 10 seconds } ```
.....................................................................................................