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

Dashboard disconnecting errors, particle photon and bme280

So I got Blynk to work, but after the last few updates and additions to my code the blynk dashboard app is no longer working, it consistently gives me “photon is not connected to network” on my android app.

Android app is updated to latest version, and am using blynk cloud.

If anyone could point out any glaring errors or something somehow blocking threads etc. I would be much obliged.

Hardware is an adafruit BME280 board, using the CE_280 library because it worked, and I am reusing someone’s code.

The dashboard ran for about 30 days fairly reliably.

// This #include statement was automatically added by the Particle IDE.
#include "CE_BME280.h"

// This #include statement was automatically added by the Particle IDE.
#include "blynk/blynk.h"



// This #include statement was automatically added by the Particle IDE.
//#include "CE_BME280/CE_BME280.h"

/************************************************************************************
 * 
 * EnviroMon V1 connected to Blynk app
 * LDR for light level
 * BME280/BMP180 (temperature, humidity, pressure)
 *
 * Written: 19 May 2016
 * Modified v1.0: 17 July 2016
 * Modified v2.0: 10 September 2016
 *
 * Blynk connections:
 * V11 = Light
 * V12 = Temperature
 * V13 = Humidity
 * V14 = Pressure
 * V15 = Dewpoint (calculated)
 *
 * V20 = WiFi Signal Strength
 * V23 = Bridge.Connector "https://github.com/blynkkk/blynk-library/blob/master/examples/Widgets/Bridge/Bridge.ino"
 * 
 * ********************************************************************************/

SYSTEM_MODE(AUTOMATIC);
SYSTEM_THREAD(ENABLED);

 
#define SEALEVELPRESSURE_HPA (1017.2)
CE_BME280 bme; // I2C


// Home - ADU Test Blynk Local-Server Auth
char auth[] = "aaaaaaauuuuuuttttttthhhhh";


IPAddress server_ip (192, 168, 2, 3);


//change double back to float if temp doesn't work and no particle publish event.
float bmeTemperature;
float bmePressure;
float bmeHumidity;
//float Light;
float dewpoint;
int wifiStrength;
float startTime;
float currentTime;
//float sensorValue;
float Temp;

void setup()
{
    //Blynk.begin(auth, server_ip, 8442); // Local Server Version
    Blynk.begin(auth);
    delay(2000);
    ppub();
    if(!bme.begin()){
        String errorMessage;
        errorMessage = "Not found";
        Particle.publish("BME280 Error", errorMessage);
        
        }

    startTime = millis();
}
 
void loop()
{
    Blynk.run();
    delay(200);
    currentTime = millis();
    if (currentTime > startTime + 2000){
        wifiStrength = WiFi.RSSI();
        Blynk.virtualWrite(V20, wifiStrength);        
        //getLight();
        getBME280Data();
        startTime = millis();
        ppub();
        delay(5000);
   // if (Serial)  

    }
}


/*****************************************************************
void getLight(){
    sensorValue = analogRead(A0);
    sensorValue = 0;
    for(int x = 0; x <= 2; x++){
        sensorValue = sensorValue + analogRead(A0);
    }
    sensorValue = sensorValue / 3;
    Light = float(sensorValue) * 100 / 4095;
    Blynk.virtualWrite(V11, Light);
}
*****************************************************************/


void getBME280Data(){
    bmeTemperature = bme.readTemperature() - 4;
    Blynk.virtualWrite(V12, bmeTemperature);
   
    bmeHumidity = bme.readHumidity();
    if (bmeHumidity > 1){
        Blynk.virtualWrite(V13, bmeHumidity);
    }
   
    bmePressure = (bme.readPressure()/100) - 3;
    Blynk.virtualWrite(V14, bmePressure);
 
    dewpoint = bmeTemperature - ((100 - bmeHumidity)/5);
    Blynk.virtualWrite(V15, dewpoint);
}

void ppub(){
  Particle.publish("Pressure : ", String (bmePressure), 60, PRIVATE);
  Particle.publish("TempCpub : ", String (bmeTemperature), 60, PRIVATE);
  Particle.publish("HumidPub: ", String (bmeHumidity), 60, PRIVATE);
  delay(10000);
  
} 

The reason I am doing the particle publish, is the data is also being displayed on Neopixel Led Ring’s on seperate Photon’s.

have you removed the delays from your loop?

delays don’t belong in the loop.

use simple timer for making things happen at certain times.

That seemed to have done the trick, I did not add any simple timer calls, I am using the particle photon and it has it’s own time library, can I just use theirs? (mild noob alert)

Sure, just avoid delays :wink:

Blynk needs to be assured the device is alive lots, delays prevent this…

A post was split to a new topic: BME280 i2c connection issues