[SOLVED] Bridge function

I’m not sure wether it’s an error or intended behavior but I’m having some issues with the Bridge widget. The follow situation takes place between 5am and 10pm …

I have an ESP-01 attached to a board with two relays. This ESP works standalone and has the following (excerpt) code:

BLYNK_WRITE(V24)
{
  int valueV24 = param.asInt();
  if(valueV24 == 1)
  {
    digitalWrite(0, LOW); 
  }
  else
  {
    digitalWrite(0, HIGH);
  }
}

BLYNK_WRITE(V25)
{
  int valueV25 = param.asInt();
  if(valueV25 == 1)
  {
    digitalWrite(2, LOW); 
  }
  else
  {
    digitalWrite(2, HIGH);
  }
}

The function looks obvious. When I press a button attached to either V24 or V25 in my App the relay switches state. Easy enough and this works fine. However, I recycle the auth code. All my current ESP’s have the same auth code. Hence, this is why I want to use virtual pins because otherwise all pins will go nuts

On my “Controller” (Arduino Mega), I have the follow code (excerpt):

BLYNK_WRITE(V10)
{
  valueV10 = param.asInt();
  
  if(valueV10 == 1)
  {
    lights.virtualWrite(V24, LOW);
    lamp1.on();
  }
  else
  {
    lights.virtualWrite(V24, HIGH);
    lamp1.off();
  }
}

BLYNK_WRITE(V11)
{
  valueV11 = param.asInt();
  
  if(valueV11 == 1)
  {
    lights.virtualWrite(V25, LOW);
    lamp2.on();
  }
  else
  {
    lights.virtualWrite(V25, HIGH);
    lamp2.off();
  }
}

Now, obviously, what happens here is that I create two buttons on my Mega dashboard which in turn have to turn in other virtual buttons on the slave-ESP (via Bridge widget of course). However, I can’t get it to work. Digital pins are no problem (I use those for one light on another ESP-01 and that works fine), but when I try to command a virtual pin on the remote ESP via a virtual pin on the Mega it just doesn’t respond.

I’m thinking there is something wrong with my logic or with some sort of type-casting. Maybe the ESP get’s a char while it should be a int? I don’t know. I’ve tried replacing the sent command with “0”, “1” (both with and without quotes) and tried to catch the sent values on the ESP side with param.asStr but that didn’t work at all (something with const* char conversion etc.).

Any thoughts out there? Tnx!

Not sure what was wrong, but it started working… weird …

Please confirm that it works and mark topic as [SOLVED] + topic name (if it was solved)

Thanks

It’s still working… so I’m guess I’m good for now, but I’m still unclear as why it didn’t work the first couple of times.

Well, at the moment we found 1 bug on server that may be related. It is hard to say if that exactly your case.

Probably not, I’ve been messing with my setup now for the whole day so it’s very likely I missed something or overlooked something. For now it’s working very well, except I made a HUGE error in my logic which is breaking my brains at the moment, haha.