Help I got 400 Bad Request Error with my BMP180 and InfluxDB Cloud

Hi everyone, im currently working sending some data to a cloud, and i have 2 circuits:

  • One ESP32 with a DHT22 sending Data to InfluxDB
  • Another ESP32 with a BMP180 sending Data to InfluxDB

The first circuit works wonderful, the problem comes when i try to do the same with the BMP180 sensor.

I have tried everything that i though of the source of the problem, the bucket, type of data, accent mark characters, etc.

My code is the following:

#include <Wire.h>
#include <Adafruit_BMP085.h>
#include <Adafruit_Sensor.h>
#include <InfluxDbClient.h>
#include <InfluxDbCloud.h>
#include <WiFi.h>

#define INFLUXDB_URL "XXXXXX"
#define INFLUXDB_TOKEN "XXXXXX"
#define INFLUXDB_ORG "XXXXXX"
#define INFLUXDB_BUCKET "XXXXXX" 

const char* ssid = "XXXXXXX";
const char* password = "XXXXXXX";
unsigned long previousMillis = 0;   
unsigned long interval = 30000;     
WiFiClient espClient;

Adafruit_BMP085 bmp;

InfluxDBClient client(INFLUXDB_URL, INFLUXDB_ORG, INFLUXDB_BUCKET, INFLUXDB_TOKEN, InfluxDbCloud2CACert);

Point sensorReadings("BMP180");

void setup() {
  Serial.begin(115200);
  bmp.begin();
  if (!bmp.begin()) {
	Serial.println("No se pudo encontrar un sensor BMP180 válido, revisar cableado");
	while (1) {}
  }
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.print("Conectando a red WiFi ..");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print('.');
    delay(1000);
  }
  Serial.println(WiFi.localIP());
  Serial.println(ssid);
  if (client.validateConnection()) {
  Serial.print("Conectado a InfluxDB: ");
  Serial.println(client.getServerUrl());
  } else {
  Serial.print("Conexión FALLIDA a InfluxDB: ");
  Serial.println(client.getLastErrorMessage());
  }
}
  
void loop() {
  
  delay(1000);
  float t = bmp.readTemperature();
  float p = bmp.readPressure();
  float a = bmp.readAltitude();
  sensorReadings.addField("Temperatura", t);
  sensorReadings.addField("Presión", p);
  sensorReadings.addField("Altitud", a);

  Serial.print("Escribiendo: ");
  Serial.println(client.pointToLineProtocol(sensorReadings));

  unsigned long currentMillis = millis();
  if ((WiFi.status() != WL_CONNECTED) && (currentMillis - previousMillis >=interval)) {
    Serial.print(millis());
    Serial.println("Reconnecting to WiFi...");
    WiFi.disconnect();
    WiFi.reconnect();
    previousMillis = currentMillis;
  }

  client.writePoint(sensorReadings);
  if(!client.writePoint(sensorReadings));
  {
    Serial.print("Falló la escritura en InfluxDB: ");
    Serial.println(client.getLastErrorMessage());
  }
  sensorReadings.clearFields();
 
  Serial.print("Temperatura = ");
  Serial.print(bmp.readTemperature());
  Serial.println(" °C");
  
  Serial.print("Presion = ");
  Serial.print(bmp.readPressure());
  Serial.println(" Pa");

  Serial.print("Altitud = ");
  Serial.print(bmp.readAltitude());
  Serial.println(" metros");

  Serial.print("Presión al nivel del mar = ");
  Serial.print(bmp.readSealevelPressure());
  Serial.println(" Pa");

  Serial.print("Altitud Real = ");
  Serial.print(bmp.readAltitude(102000));
  Serial.println(" metros");
    
  Serial.println();
  delay(10000);
}

I hope that someone here can help me, regards!

Write the values in pure ASCII (p.e. English). I guess the accent in "presión" isn't correctly encoded and that's why the server doesn't accept the request. Don't expect Arduino libraries to handle encoding automatically!

Thanks for your response.
That's something that i already tried, im currently reading the libraries but nothing seems bad writed in my code.

Even so, you were right.
My bucket had accent and that was the problem,
Rare that only in Influx definitions that is a big thing, but in tag, point and field definitions there is no problem with accents.
I repeat, thank you for your response (:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.