BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Blynk and the BME280

esp8266

#1

I looked a rond but don`t see my problem in the topic,
So this is my problem i maked a wheaterstation and use blynk for the read out, i use a BME/BMP 280 in the serial monitor i see all the values that are there, but when i use blynk and add V3 for the huminity there is no read out the value is – and stays that way. can someone help me out here.

This is the part from the sketch that is running.
//get and print humidity data
float humidity = bme280.getHumidity();
Serial.print(“Humidity: “);
Serial.print(humidity);
Serial.println(”%”);
Blynk.virtualWrite(3, humidity); // virtual pin 3

This is the readout wirh the serial mon.
[7717] Ready (ping: 5ms).
Temp: 27.14C
Pressure: 1018.83hPa
Altitude: -46.35m
Humidity: 44.00% < — this part will not turn on the blynk app.

Thanx in advance.
Willy


#2

Full code pls


#3

Here by the full code

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include "Seeed_BME280.h"
#include <Wire.h>


BME280 bme280;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "**********";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "*******";
char pass[] = "*******";
void setup()
{
  
  Serial.begin(9600);
//  Blynk.begin(auth, ssid, pass);
  Blynk.begin(auth, ssid, pass, IPAddress(192,168,168,205), 8080);
  Serial.begin(9600);
  if(!bme280.init()){
  Serial.println("Device error!");
  }
}

void loop()
{
  Blynk.run();
  
  //get and print temperatures
  float temp = bme280.getTemperature();
  Serial.print("Temp: ");
  Serial.print(temp);
  Serial.println("C");//The unit for  Celsius because original arduino don't support speical symbols
  Blynk.virtualWrite(0, temp); // virtual pin 0
  Blynk.virtualWrite(4, temp); // virtual pin 4
  
  
  //get and print atmospheric pressure data
  float pressure = bme280.getPressure(); // pressure in Pa
  float p = pressure/100.0 ; // pressure in hPa
  Serial.print("Pressure: ");
  Serial.print(p);
  Serial.println("hPa");
  Blynk.virtualWrite(1, p); // virtual pin 1

  
  //get and print altitude data
  float altitude = bme280.calcAltitude(pressure);
  Serial.print("Altitude: ");
  Serial.print(altitude);
  Serial.println("m");
  Blynk.virtualWrite(2, altitude); // virtual pin 2

  //get and print humidity data
  float humidity = bme280.getHumidity();
  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.println("%");
  Blynk.virtualWrite(3, humidity); // virtual pin 3
  ESP.deepSleep(5 * 60 * 1000000); // // deepSleep time is defined in microseconds. Multiply seconds by 1e6 
}

#4

#5

@Willy_Wva I fixed your code formatting… as per the instructions you seem to have missed when creating this topic :wink:

Blynk - FTFC

Pleas read the void loop() advice a bit more thoroughly, as no one will fix that but you.


#6

This could work in your case with deepSleep:

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include "Seeed_BME280.h"
#include <Wire.h>


BME280 bme280;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "**********";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "*******";
char pass[] = "*******";
void setup()
{
  
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass, IPAddress(192,168,168,205), 8080);
  if(!bme280.init())
  {
    Serial.println("Device error!");
  }
  else
  {  
    Blynk.connect();  
    
    //get and print temperatures
    float temp = bme280.getTemperature();
    Serial.print("Temp: ");
    Serial.print(temp);
    Serial.println("C");//The unit for  Celsius because original arduino don't support speical symbols
    Blynk.virtualWrite(0, temp); // virtual pin 0
    Blynk.virtualWrite(4, temp); // virtual pin 4
    
    //get and print atmospheric pressure data
    float pressure = bme280.getPressure(); // pressure in Pa
    float p = pressure/100.0 ; // pressure in hPa
    Serial.print("Pressure: ");
    Serial.print(p);
    Serial.println("hPa");
    Blynk.virtualWrite(1, p); // virtual pin 1 
    
    //get and print altitude data
    float altitude = bme280.calcAltitude(pressure);
    Serial.print("Altitude: ");
    Serial.print(altitude);
    Serial.println("m");
    Blynk.virtualWrite(2, altitude); // virtual pin 2
  
    //get and print humidity data
    float humidity = bme280.getHumidity();
    Serial.print("Humidity: ");
    Serial.print(humidity);
    Serial.println("%");
    Blynk.virtualWrite(3, humidity); // virtual pin 3
    
    ESP.deepSleep(5 * 60 * 1000000); // // deepSleep time is defined in microseconds. Multiply seconds by 1e6     
  } //else
}

void loop()
{
}

#7

I try it out but it still is not working, the temp and altitude and pressure are working fine and with the monitor i can read everything.

The sleeping from the WeMos was the wakeup call before it got send the humidity it was falling in sleep and not send the value from the reading after setting the line for the second time it was send to Blynk (wait or pauze thit not the trick) :slight_smile:


#8

I think you need the Blynk.run() in the loop. “All the Blynk Magic happens here…”