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

SOLVED: Particle.variable and Particle.function doesn't work with Blynk on Particle Photon

nonblynkrelated

#1

I’m new to blynk and try to combine the Particle world with Blynk. Now I’m facing the problem, that my sketch either works with the pure Particle.variable / function or works with only Blynk. when both are enabled, only the Blynk part is working. Any hint for me? The system firmware is 0.7.0, Particle.pubish is fuctional

code:

#include <LiquidCrystal_I2C_Spark.h>
#include "Adafruit_DHT.h"
#include <blynk.h>
#define DHTPIN 3    
#define DHTTYPE DHT22		
#define BLYNK_PRINT Serial


DHT dht(DHTPIN, DHTTYPE);
double h,t;
LiquidCrystal_I2C *lcd;
BlynkTimer timer;
char auth[] = "xxx";


void myTimerEvent()
{
  lcd->clear();
  lcd->print("Temp/Feuchte:");lcd->setCursor(0,1);
  lcd->print( String(t,2)+" : "+String(h,2));

  Blynk.virtualWrite(V1, t);
  Blynk.virtualWrite(V2, h);
  Blynk.virtualWrite(V5, millis() / 1000);
}

void setup() {
    lcd = new LiquidCrystal_I2C(0x3F, 16, 2);
	lcd->init();
	lcd->backlight();
	lcd->clear();
	dht.begin();
	Time.zone(+1);
	Blynk.begin(auth,IPAddress(172,23,56,222), 8080);
	Particle.variable("Temperatur",&t,DOUBLE);
	Particle.variable("Luftfeuchte",&h,DOUBLE);
    timer.setInterval(1000L, myTimerEvent);
    h = dht.getHumidity();  	
    t = dht.getTempCelcius();     
}	

void loop()
{
  Blynk.run();
  timer.run(); // Initiates BlynkTimer
  delay(500);
  h = dht.getHumidity();  	
  t = dht.getTempCelcius(); 
}

#2

Topic / Problem solved… Particle.variable or Particle.function must be first in setup().

Got the solution from the Particle Community