abasel
April 22, 2019, 10:33am
1
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.
abasel
April 22, 2019, 5:47pm
3
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:
Okay, here’s the code that I’ve been experimenting with recently, modified to use your sensors and virtual pins.
The code expects a third display widget attached to pin V3, which will show how long (in seconds) your ESP device was awake for.
Previously, the shortest wake time I was getting was around the the 5 second mark, when using Blynk.begin and an IP address assigned by DHCP.
With this code I’m consistently getting wake times around the 1.2 second mark. This is without the two Dallas tem…
Pete.