Comments (4)
Which hardware/os do you have? Please also provide your script code.
from blynk-library-python.
Hi, I'm using a raspberry pi 3 running Raspbian 9 stretch and Python 3.5.3.
Here is my code:
import serial
import yaml
import BlynkLib
from time import sleep
MENU = [[1], [2, 3], [4], [5], [2], [3], [1, 2, 3, 4, 5]]
BLYNK_AUTH = 'my token'
serial = serial.Serial("/dev/ttyACM0", 9600, timeout=1)
blynk = BlynkLib.Blynk(BLYNK_AUTH)
def read_config_file(conf=2):
with open("config.yaml", "r") as codes_file:
config = yaml.load(codes_file)
if conf == 2:
return config
if conf == 1:
return config["configuration"]
if conf == 0:
return config["persianas"]
def send_command(cmd):
if not lock:
for blind in current_blind:
command = blind_config[blind-1][cmd]
print(command)
serial.write(command.encode())
sleep(0.1)
serial.write(command.encode())
sleep(0.5)
@blynk.VIRTUAL_WRITE(0)
def lock_handler(status):
global lock
lock = int(status[0])
@blynk.VIRTUAL_WRITE(1)
def blind_handler1(sel):
blind_read_handler1()
sel = int(sel[0])
global current_blind
current_blind = []
for i in range(len(MENU[sel-1])):
current_blind.append(MENU[sel-1][i])
@blynk.VIRTUAL_WRITE(3)
def blind_handler2(sel):
blind_read_handler2()
sel = int(sel[0])+4
global current_blind
current_blind = []
for i in range(len(MENU[sel-1])):
current_blind.append(MENU[sel-1][i])
@blynk.VIRTUAL_READ(3)
def blind_read_handler2():
blynk.virtual_write(1, 0)
@blynk.VIRTUAL_READ(1)
def blind_read_handler1():
blynk.virtual_write(3, 0)
@blynk.VIRTUAL_WRITE(2)
def command_handler(cmd):
cmd = int(cmd[0])
if cmd == 1:
send_command("up")
if cmd == 2:
send_command("down")
if cmd == 3:
send_command("stop")
full_config = read_config_file()
blind_config = full_config["persianas"]
setting_config = full_config["configuration"]
current_blind = []
lock = 1
while True:
blynk.run()
from blynk-library-python.
It's been working now for a week without any error. The program remains unchanged.
from blynk-library-python.
I am facing the same issue and not solved.
I am using NodeMCU ESP8266 and micropython.
I get the error Unexpected command: 41 when using blynk:
Below is my code ....
import BlynkLib
import network
import machine
WIFI_SSID = 'HamzaJraiwi'
WIFI_PASS = ''
BLYNK_AUTH = ''
print("Connecting to WiFi...")
wifi = network.WLAN(network.STA_IF)
wifi.active(True)
wifi.connect(WIFI_SSID, WIFI_PASS)
while not wifi.isconnected():
pass
print('IP:', wifi.ifconfig()[0])
print("Connecting to Blynk...")
blynk = BlynkLib.Blynk(BLYNK_AUTH)
@blynk.on("connected")
def blynk_connected(ping):
print('Blynk ready. Ping:', ping, 'ms')
def runLoop():
while True:
blynk.run()
machine.idle()
Run blynk in the main thread:
runLoop()
from blynk-library-python.
Related Issues (20)
- ssl error on connection HOT 2
- raspbery pi 3+ not running
- RPI disconnects HOT 8
- Invalid Auth Token
- Invalid auth token with both py libraries for Blynk console 2.0 HOT 3
- Pycom Lopy4 disconnects HOT 4
- Invalid Token RPi4b HOT 8
- Notify HOT 2
- Socket Disconnects - Blynk offline HOT 4
- pip install blynk-library-python doesn't pull 1.0.0 HOT 5
- How to use Blynk.Inject with ESP32? HOT 6
- Does not recover after disconnect
- An Example might be wrong when I demo it on ubuntu. @blynk.on => @blynk.ON
- BrokenPipeError HOT 6
- Connection doesn't work, requires server="blynk.cloud" HOT 1
- Pin Handlers
- Install BlynkLib using mip.install HOT 1
- AttributeError: module 'os' has no attribute 'uname'. Did you mean: 'name'? HOT 3
- 'Blynk' object has no attribute 'VIRTUAL_WRITE' on a raspberry pi pico w HOT 3
- Unable to sync manual switch with the blynk app button
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blynk-library-python.