Param.AsInt Returns incorrect value

Hi,
Creating a new project to control temperature via a NodeMCU, I have 3 parameters passing from the dashboard to my Arduino.
For each I am displaying the value passed in via Param.AsInt from a BLYNK_WRITE subroutine.

BLYNK_WRITE(V4) {  //HeaterOn
  ledState = param.asInt();
  digitalWrite(ledPin1, !ledState);  // invert as low = on
  Serial.print("Switch Change: ");
  Serial.println(V4);
}
BLYNK_WRITE(V5) {   //MaxTimer
  MaxTimer = param.asInt();
  Serial.print("Timer Change: ");
  Serial.println(MaxTimer);
}
BLYNK_WRITE(V6) {  //MaxTemp
  MaxTemp = param.asInt();
  Serial.print("Temp Change: ");
  Serial.println(V6);
}

However, for 2 of the values it is passing the NUMBER of the data stream, not the actual value.
So I have a button on V4, which shows “4” each time I turn the button on or off.
I have a slider on V6, which shows “6” no matter what the slider is set to.

But I also have another slider on V5, which shows the CORRECT value of the slider as it changes

Switch Change: 4
Timer Change: 778
Temp Change: 6

This datastream was declared as a Float, the others as Integer; I have changed V6 to datastream declaration to Float to see if that fixes the issue, but no joy.

Am I doing something wrong, or is this a bug?
Regards
Kevin

Yes.

In the V4 and V6 BLYNK_WRITEs your aren’t doing a serial print of the variable that you’ve captured the incoming value to.

Should be

Serial.println(ledState;

Pete.

Thanks Pete, forgot that V4 etc are macro defs, not variables.
Regards
Kevin

1 Like