Cannot send real values to the cloud (Asksensors)


I am struggling with getting real values instead of random values, when I try to send values to a cloud-base called Asksensors. Those real values would be measured by my ESP32-attached BMP280 sensor. So I am using ESP32 (wroom-32D), BMP280 for temperature and pressure measurement, and Arduino IDE.

For experiment, I am trying to send only pressure values from the BMP280. I have already tested that the pressure sending to a local website works. But now, when I try to send the BMP280 pressure values to the cloud instead of the local website, I get confused on how to edit a provided source code template (available at 3- Connect ESP32 over HTTPS | AskSensors Documentation ).

Firstly, I downloaded an identical code http_get.ino from a Github repository as instructed in I managed to upload the code and to get it to update random values (between 10 and 100) to the Asksensors website.

Now while I try to edit the source code above, I end up with the Serial monitor going bizarre. But all I actually did was that I edited url += random(10, 100); to be url += pressure; so that I declared earlier the BMP280 pressure to be pressure = bmp.readPressure();

Here is my edition of the source code template. I have bolded my amendments to the source code.

  Connect ESP32 to AskSensors
 * Description:  This sketch connects to a website ( using an ESP32 Wifi module.
 *  Author:, 2018
 *  github:
#include <WiFi.h>
#include <WiFiMulti.h>
#include <Wire.h>
**#include <Adafruit_BMP280.h>**
#include <HTTPClient.h>

**Adafruit_BMP280 bmp; // I2C

float pressure = bmp.readPressure(); **

WiFiMulti WiFiMulti;
HTTPClient ask;
// TODO: user config
const char* ssid     = "mokkula_351164"; //Wifi SSID
const char* password = "XXXXXXXXXXX"; //Wifi Password
const char* apiKeyIn = "9DhBkKau7Mdx1P6JizFtyvFvGzxcP8le";      // API KEY IN
const unsigned int writeInterval = 25000;   // write interval (in ms)

// ASKSENSORS API host config
const char* host = "";  // API host name
const int httpPort = 80;      // port
void setup(){ 
  // open serial
  Serial.println("********** Program Start : Connect ESP32 to AskSensors.");
  Serial.println("Wait for WiFi... ");

  // connecting to the WiFi network
  WiFiMulti.addAP(ssid, password);
  while ( != WL_CONNECTED) {
  // connected
  Serial.println("WiFi connected");
  Serial.println("IP address: ");

void loop(){  

  // Use WiFiClient class to create TCP connections
  WiFiClient client;

  if (!client.connect(host, httpPort)) {
    Serial.println("connection failed");
  }else {
// Create a URL for updating module 1 and module2 request 
String url = ""; 
url += apiKeyIn;
url += "?module1=";
url += **pressure; **
**//**url += "&module2=";   
**//**url += random(10, 100);
Serial.print("********** requesting URL: ");

ask.begin(url); //Specify the URL
//Check for the returning code
int httpCode = ask.GET();
if (httpCode > 0) {
String payload = ask.getString();
} else {
Serial.println("Error on HTTP request");
ask.end(); //End
Serial.println("********** End ");
client.stop(); // stop client
delay(writeInterval); // delay

What is more, that code gives me a serial monitor screen that flickers with the following message every half seconds:

Thanks for any advice! :face_with_raised_eyebrow:

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