Virtual pin or iOS bug?

Using Particle Electron and third party sim. iPhone 6 V10.2. Blynk V2.6.1.
As part of a bigger project. I have a relay connected to D1. On the Blynk side of things I have it carried out via BLYNK_WRITE(V6). For some reason I cannot get the relay to energize when I push the button widget assigned to V6. I decided to do some simple testing to see if I could figure out what is going on. So I used this code to test with the button widget assigned to D1

// This #include statement was automatically added by the Particle IDE.
#include "blynk/blynk.h"





#include "cellular_hal.h"
STARTUP(cellular_credentials_set("blah blah blah", "", "", NULL));



void setup()
{
  Serial.begin(9600); // See the connection status in Serial Monitor
  Blynk.begin("***************", IPAddress(45,55,130,102), 8442);  // Here your Arduino connects to the Blynk Cloud.
}

void loop()
{
  Blynk.run(); 
}

With this, I was able to energize the relay connected to D1. Next I used this code

// This #include statement was automatically added by the Particle IDE.
#include "blynk/blynk.h"


#define blower_Relay    D1

#define BLYNK_PRINT Serial // Enables Serial Monitor


#include "cellular_hal.h"
STARTUP(cellular_credentials_set("blah blah blah", "", "", NULL));



void setup()
{
  Serial.begin(9600); // See the connection status in Serial Monitor
  Blynk.begin("***************", IPAddress(45,55,130,102), 8442);  // Here your Arduino connects to the Blynk Cloud.
}

void loop()
{
  Blynk.run(); 
}
BLYNK_WRITE(V6)
{
  if (param[0].asInt() == 1) 
  {
    digitalWrite(blower_Relay, HIGH); 
  }
  else 
  {
    digitalWrite(blower_Relay, LOW); 
  }

}

I assigned the Button Widget to V6. I am not able to energize the relay. Next I assigned the button widget back to D1 using the second code example and the relay works. So, I went back and assigned the button widget to V6 again and now the button controls the relay. What am I missing? Using the second code example, if I reset the sketch the virtual assignment does not work until I change the button to D1. Then I can switch it back to V6 and it works fine as long as I never reset the board. Im lost.

Thanks for the help

Hello,

I’m not really sure, but did you try to take out the [0] from param?
I mean:
BLYNK_WRITE(V6)
{
if (param.asInt() == 1)
{
digitalWrite(blower_Relay, HIGH);
}
else
{
digitalWrite(blower_Relay, LOW);
}

}

I have the same config than you use but the particle (I’m using NodeMCU)

@ darkmoon Thanks for the reply. I did not try that but I will look in to it. I have other widgets where I have them coded the exact same way and they work fine!

I have tried several things including the suggestion by @darkmoon. The only thing that works is to assign the pin to D1. There is something strange going on with this that I cannot figure out. But I do have other button widgets with the exact same code and they work fine. Only this one does not.

Hello,
You mean thar you have other virtual pins and other relays working but this?

Did you use pinMode(blower_Relay, OUTPUT);? I can’t see that in your sketch…

This will help

void setup(){
  pinMode(blower_Relay, OUTPUT);
}

BLYNK_WRITE(V6){
  if (param.asInt()){
    digitalWrite(blower_Relay, HIGH); 
  } else {
    digitalWrite(blower_Relay, LOW); 
  }
}
  • Set pinMode OUTPUT
  • Don’t use param[0]
  • You dont have to check == 1 too… just a waste of bit space
1 Like

@darkmoon, yes I have other relays working just like the code I have shown. But now @Jamin has given me another idea!
Thanks to you both for your time and help. I will try soon

1 Like