Help getting one gauges to display data

I have three gauges, two work and one (pressure) does not

void loop() {

  Blynk.run();

  Serial.println("");

  temperature = bme.readTemperature();
  Blynk.virtualWrite(1, temperature);

  Serial.print("Temperature: "); Serial.println(temperature); // virtual pin 1

  humidity = bme.readHumidity();
  Blynk.virtualWrite(2, humidity); // virtual pin 2
  Serial.print("Humidity: "); Serial.println(humidity);

  pressure = bme.readPressure(); // pressure in Pa
  pressure = bme.seaLevelForAltitude(ALTITUDE, pressure);
  pressure = pressure / 100.0F; // pressure in hPa

  Blynk.virtualWrite(3, pressure); // virtual pin 3

  Blynk.virtualWrite(0, pressure); // virtual pin 0

  Serial.print("Pressure: "); Serial.println(pressure);

  ESP.deepSleep(5 * 60 * 1000000); // // deepSleep time is defined in microseconds. Multiply seconds by 1e6
}

Serial.print displays a pressure value between 0 and 1500.

From the screen shot https://prnt.sc/nf81d7 you can see that the virtual pin is indeed 3 but yet nothing it being displayed in it.

All variables are type float

float temperature;
float humidity;
float pressure;

I’ve corrected the formatting g of your code.
You need to use triple backticks, not a quotation mark. Like this:
```

I suspect that your board is going to sleep before the pressure value has been uploaded to Blynk.
I’d add a Blynk.run(); and probably a delay(100); just before your deepsleep command.

It’s also good practice to add a short delay after the deepsleep command to ensure that the void loop doesn’t continue to execute before deepsleep kicks-in.

Pete.

Thanks for that… The sleep appears to have been the issue. I removed the line and it worked. So now to work out the appropriate delay length.


  Blynk.run();

  Serial.println("");

  temperature = bme.readTemperature();
  Blynk.virtualWrite(1, temperature);// virtual pin 1

  Serial.print("Temperature: "); Serial.println(temperature); 

  humidity = bme.readHumidity();
  Blynk.virtualWrite(2, humidity); // virtual pin 2
  Serial.print("Humidity: "); Serial.println(humidity);

  pressure = bme.readPressure(); // pressure in Pa
  pressure = bme.seaLevelForAltitude(ALTITUDE, pressure);
  pressure = pressure / 100.0F; // pressure in hPa
  
  Blynk.run();
  Blynk.virtualWrite(3, pressure); // virtual pin 3
  Blynk.virtualWrite(0, pressure); // virtual pin 0

  Serial.print("Pressure: "); Serial.println(pressure);
  
  delay(1000);
  ESP.deepSleep(5 * 60 * 1000000); // // deepSleep time is defined in microseconds. Multiply seconds by 1e6
  delay(1000);
}```
1 Like

You might also find this post helpful:

Pete.