Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to sync manual switch with the blynk app button #78

Open
kausarn3 opened this issue Sep 8, 2023 · 0 comments
Open

Unable to sync manual switch with the blynk app button #78

kausarn3 opened this issue Sep 8, 2023 · 0 comments

Comments

@kausarn3
Copy link

kausarn3 commented Sep 8, 2023

Blynk version = 1.0.0
Code used :

`SWITCH_PIN = Pin(13, Pin.IN, Pin.PULL_UP)
RELAY_PIN = Pin(5, Pin.OUT)

blynk = BlynkLib.Blynk(auth_token)
blynk = BlynkLib.Blynk(auth_token)

@blynk.VIRTUAL_WRITE(0)
def v0_write_handler(value):
global relay_state
relay_state = int(value[0])
if relay_state == 1:
RELAY_PIN.on()
else:
RELAY_PIN.off()

def switch_callback(pin):
global relay_state
relay_state = SWITCH_PIN.value()
blynk.virtual_write(0, relay_state) # Update the virtual pin in Blynk
if relay_state == 1:
RELAY_PIN.on()
else:
RELAY_PIN.off()

SWITCH_PIN.irq(trigger=Pin.IRQ_FALLING | Pin.IRQ_RISING, handler=switch_callback)

while True:
blynk.run()`

Error:
File "boot.py", line 26, in
AttributeError: 'Blynk' object has no attribute 'VIRTUAL_WRITE'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant