Hi,
The following code interacts with a second file which controls the pinout of a Raspberry board.
For some reason, the relay I’m activating gets turned on twice when selected from the app.
I’ve a similar code running on a Arduino Yun for over a year without a problem.
I’m probably doing some wrong since this’ the first time I’m playing with the Blynk-Python lib .
Any help is appreciated.
#!/usr/bin/python3
#import libraries
import BlynkLib
from gpio import relayOn #from gpio.py script
BLYNK_AUTH = '***'
# Initialize Blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH)
@blynk.VIRTUAL_WRITE(8)
def my_write_handler(value):
if value: # is the button pressed?
print('test.........')
relayOn(8)
#start Blynk
blynk.run()
Printout from the console…
pi@pi:~/sketches $ python3 test.py
___ __ __
/ _ )/ /_ _____ / /__
/ _ / / // / _ / '/
///_, /////_
/__/
Give Blynk a Github star! => https://github.com/vshymanskyy/blynk-library-python
TCP: Connecting to blynk-cloud.com:80
Blynk connection successful, authenticating…
Access granted, happy Blynking!
test…
test…