blynkkk / blynk_Issues

6 stars 6 forks source link

BLYNK_WRITE(V0) affecting temperature sensor on V5 #20

Closed spiutm closed 3 years ago

spiutm commented 3 years ago

Blynk.syncVirtual(V0) affecting temperature sensor on V5

with BLYNK_CONNECTED() { // when device is conneceted to Blynk Cloud... Blynk.syncVirtual(V0); // syncs V0 pin only (even if sync setting is off for V0 } and sensor on V5 i get this: 13:42:09.792 -> Temp = 20.94 13:42:11.995 -> Temp = 20.88 13:42:14.292 -> Temp = 20.88 13:42:15.084 -> Temp = -127.00 13:42:17.235 -> Temp = 20.94 13:42:19.478 -> Temp = 20.94 13:42:20.221 -> Temp = 20.94 13:42:22.464 -> Temp = 20.94

removing the sync i get this: 13:43:33.822 -> Temp = 20.88 13:43:36.019 -> Temp = 20.94 13:43:38.265 -> Temp = 20.94 13:43:39.009 -> Temp = 20.88 13:43:41.209 -> Temp = 20.94 13:43:43.408 -> Temp = 20.88

Peterkn2001 commented 3 years ago

The -127.00 reading means that the temperature sensor library (DallasTemperature.h maybe?) failed to read the sensor. That's probably happening because of the code that you're running in your BLYNK_WRITE(V0) callback function.

The solution is to simply ignore any -127.00 readings.

Pete.

spiutm commented 3 years ago

can't ignore, i'm using alerts for drop or temp rise, i use: Blynk.virtualWrite(V5

on DallasTemperature sketch standalone or in new blynk sketch works fine if i remove sync, but i need sync for leds, works fine on old blynk

spiutm commented 3 years ago

tested like this, i removed sync and results are , every time i use slider to move v0, v5 gets -127, so is as Peterkn2001 mentioned above BLYNK_WRITE(V0) resets sensor on v5, any fix for this?

Peterkn2001 commented 3 years ago

can't ignore, i'm using alerts for drop or temp rise, You're taking a reading every 2 seconds. Ignoring one reading that is an outlier isn't going to make much difference!

Pete.

spiutm commented 3 years ago

tried delay 2000 still keeps messaging me alerts low tem as it is set drop below 20 and i have 21-22 temp

Peterkn2001 commented 3 years ago

I don't think you understood my suggestion. You need an if statement that checks whether the result of the sensor is -127.00 something like this...

void sendSensor()
{ 
  sensors.requestTemperatures();
  temp = sensors.getTempCByIndex(0);
  if(temp==-127)
  {
    // do nothing
   }
  else
  {
    Blynk.virtualWrite(V0, String(temp, 2));
  }
} 

Pete.

spiutm commented 3 years ago

thank you, i will try