Can someone help me with motion sensor code?

Im using bridge function to change relay state on remote esp8266 with motion sensor
Cant some one explain how to do it. Im just learing
Here is my Master module code

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = “xxxxxxxxxxxxMaster”;
char auth1[] = “xxxxxxxSLAVE”;
WidgetBridge bridge1(0);
void setup()

Blynk.begin(auth, “xxxx”, “xxxx”, IPAddress(xxx,xxx,xxx,xxx));
pinMode(12, INPUT);
while (Blynk.connect() == false) {
// Wait until connected
bridge1.setAuthToken(auth1); // Place the AuthToken of the second hardware here
if (digitalRead(12)==LOW) {
bridge1.digitalWrite(2, LOW);
if (digitalRead(12)==HIGH) {
bridge1.digitalWrite(2, HIGH);

void loop()

It does not change relay state on remote side

but if i write something like this

int a = param.asInt();
if (a == 0) {

bridge1.digitalWrite(2, LOW);
} else {

bridge1.digitalWrite(2, HIGH);

Ill get relay working from dashboard button of master ESP

Cant someone help me to find mistake or explain how to read state of gpio 12 and send comand to esp slave on that fact?

My motion sensor is working(just check with rpi), even without it i connect my esp8266 nodemcu pin D6(gpio12) with ground or +3.3, but it does not send comand((((

May be there is a way to write virtual V3 to HIGH, so it’ll be like button press in dasboard?

Maybe something like this
if (digitalRead(12)==HIGH) {
virtualWrite(3, HIGH);
But how and where?

Finally i done it
sorry my Russian acent