Patchy connection to the Blynk cloud

Hi All,

I just upgrded my library to 0.2.2 and I am still getting issues with a spark core and a simple BMP180 breakout.

The serial monitor reports “[87100] connecting to cloud.blynk.cc :8442”, as well as some other data to show the breakout is working.

Sometimes it connects and I get fast responses in the iphone app to changes at the sensors. However most of the time the ios app just say’s “core offline”

Any ideas how I can firm this connection up?

Thanks

:smile:

Could you please send us the sketch + the log?

@vhymanskyy Thank you for your super quick response.

What do you want? my .ino code is as follows,

/ This #include statement was automatically added by the Spark IDE.
#include "Adafruit_BMP085.h"
#define BLYNK_PRINT Serial
#include "BlynkSimpleSparkCore.h"

/**************************************************************
 * Blynk is a platform with iOS and Android apps to control
 * Arduino, Raspberry Pi and the likes over the Internet.
 * You can easily build graphic interfaces for all your
 * projects by simply dragging and dropping widgets.
 *
 *   Downloads, docs, tutorials: http://www.blynk.cc
 *   Blynk community:            http://community.blynk.cc
 *   Social groups:              http://www.fb.com/blynkapp
 *                               http://twitter.com/blynk_app
 *
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 *
 **************************************************************/
//#define BLYNK_DEBUG // Uncomment this to see debug prints

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


/*
	Wiring
	------
	BMP085 Vcc to 3.3V
	BMP085 GND to GND
	BMP085 SCL to D1
	BMP085 SDA to D0
*/

Adafruit_BMP085 bmp;

// Initialize BMP085

void InitializeBMP085(){
	if (!bmp.begin()) {
		Serial.println("Could not find a valid BMP085 sensor, check wiring!");
		while (1) {}
	}
}

// Publish Pressure, Altitude
void PublishBMP085Info(){
    Serial.print("Temperature = ");
    Serial.print(bmp.readTemperature());
    Serial.println(" *C");
		Blynk.virtualWrite(0, bmp.readTemperature());


    Serial.print("Pressure = ");
    Serial.print(bmp.readPressure());
		//Blynk.virtualWrite(1, bmp.readPressure());
    Serial.println(" Pa");

    // Calculate altitude assuming 'standard' barometric
    // pressure of 1013.25 millibar = 101325 Pascal
    Serial.print("Altitude = ");
    Serial.print(bmp.readAltitude());
		//Blynk.virtualWrite(2, bmp.readAltitude());
    Serial.println(" meters");

  // you can get a more precise measurement of altitude
  // if you know the current sea level pressure which will
  // vary with weather and such. If it is 1015 millibars
  // that is equal to 101500 Pascals.
    Serial.print("Real altitude = ");
    Serial.print(bmp.readAltitude(101500));
    Serial.println(" meters");

    char szEventInfo[64];

    sprintf(szEventInfo, "Temperature=%.2f °C, Pressure=%.2f hPa", bmp.readTemperature(), bmp.readPressure()/100.0);

    Spark.publish("bmpo85info", szEventInfo);
}

// Initialize applicaiton
void InitializeApplication(){
    Serial.begin(9600);
	pinMode(D7, OUTPUT);
}

// Blink LED and wait for some time
void BlinkLED(){
    digitalWrite(D7, HIGH);
    delay(500);
    digitalWrite(D7, LOW);
    delay(500);
}

void setup() {
    InitializeApplication();
		Serial.begin(9600);
		delay(10000); // Allow board to settle
		Blynk.begin(auth);
	InitializeBMP085();
}

void loop() {
    // Publish events. Wait for 2 second between publishes
    PublishBMP085Info();
		Blynk.run();
    BlinkLED();
//		BLYNK_WRITE(10) {
  //  if (param.asInt()) {
  //      Spark.connect();
  //  } else {
  //      Spark.disconnect();
//    }
delay(1000);}

By log what do you mean??

:smile:

This is generally a bad idea. Try rewriting your periodic actions using the timer library, like this one:
https://build.particle.io/build/551653f618a2e3881a0007b6/lib/54693daa7ab72c41c1001066/tab/PolledTimerExample.ino

Does Blynk work fine with the default example?

1 Like

So I removed the delay (1000) and re-compiled. It started working straight away. Looks good so far. I will test it for robustness.

Thank you very much.

:smile:

@vshymanskyy

Hi… trying to learn one thing or another while going through the posts… could you elaborate shortly why this is a bad idea? As for the link: it would be great, if the sources are available without the need to sign in (thus having to create accounts just to follow a link). Is this something similiar to the SimpleTimer-library?

Thanks

:slight_smile:

Sorry this is a third-party library so we don’t have any control about how the sources are published.
I’m sure it can be found on github.
Yes you’re right - this is similar to SimpleTimer.

Why is that bad: it usually prevents the controller from doing anything useful (like polling events, etc).