BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       👉 SKETCH BUILDER

Raspberrypi type error

I am try to run this code in raspberrypi to but i am getting an error.

import BlynkLib
import RPi.GPIO as GPIO
import time

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.OUT)
GPIO.setup(23, GPIO.OUT)
GPIO.setup(24, GPIO.OUT)
GPIO.setup(25, GPIO.OUT)
GPIO.setup(12, GPIO.OUT)
GPIO.setup(26, GPIO.OUT)
GPIO.setup(19, GPIO.OUT)
GPIO.setup(13, GPIO.OUT)
GPIO.setup(6, GPIO.OUT)
GPIO.setup(5, GPIO.OUT)

BLYNK_TEMPLATE_ID = '***********'
BLYNK_DEVICE_NAME = '***********'
BLYNK_AUTH = '**************'
blynk = BlynkLib.Blynk(BLYNK_AUTH)
@blynk.on('V1')
def S1_write_handler(value):
    if int(value[0]) == 1:
        GPIO.output(18, GPIO.HIGH)
        print('Relay 1 ON')
    elif int(value[0]) == 0:
        GPIO.output(18, GPIO.LOW)
        print('Relay 1 OFF')
@blynk.on('V2')
def S1_write_handler(value):
    if int(value[0]) == 1:
        GPIO.output(23, GPIO.HIGH)
        print('Relay 2 ON')
    elif int(value[0]) == 0:
        GPIO.output(23, GPIO.LOW)
        print('Relay 2 OFF')
@blynk.on('V3')
def S1_write_handler(value):
    if int(value[0]) == 1:
        GPIO.output(24, GPIO.HIGH)
        print('Relay 3 ON')
    elif int(value[0]) == 0:
        GPIO.output(24, GPIO.LOW)
        print('Relay 3 OFF')
@blynk.on('V4')
def S1_write_handler(value):
    if int(value[0]) == 1:
        GPIO.output(25, GPIO.HIGH)
        print('Relay 4 ON')
    elif int(value[0]) == 0:
        GPIO.output(25, GPIO.LOW)
        print('Relay 4 OFF')
@blynk.on('V5')
def S1_write_handler(value):
    if int(value[0]) == 1:
        GPIO.output(12, GPIO.HIGH)
        print('Relay 5 ON')
    elif int(value[0]) == 0:
        GPIO.output(12, GPIO.LOW)
        print('Relay 5 OFF')
@blynk.on('V6')
def S1_write_handler(value):
    if int(value[0]) == 1:
        GPIO.output(26, GPIO.HIGH)
        print('Relay 6 ON')
    elif int(value[0]) == 0:
        GPIO.output(26, GPIO.LOW)
        print('Relay 6 OFF')
@blynk.on('V7')
def S1_write_handler(value):
    if int(value[0]) == 1:
        GPIO.output(19, GPIO.HIGH)
        print('Relay 7 ON')
    elif int(value[0]) == 0:
        GPIO.output(19, GPIO.LOW)
        print('Relay 7 OFF')
@blynk.on('V8')
def S1_write_handler(value):
    if int(value[0]) == 1:
        GPIO.output(13, GPIO.HIGH)
        print('Relay 8 ON')
    elif int(value[0]) == 0:
        GPIO.output(13, GPIO.LOW)
        print('Relay 8 OFF')
@blynk.on('V9')
def S1_write_handler(value):
    if int(value[0]) == 1:
        GPIO.output(6, GPIO.HIGH)
        print('Relay 9 ON')
    elif int(value[0]) == 0:
        GPIO.output(6, GPIO.LOW)
        print('Relay 9 OFF')
@blynk.on('V10')
def S1_write_handler(value):
    if int(value[0]) == 1:
        GPIO.output(5, GPIO.HIGH)
        print('Relay 10 ON')
    elif int(value[0]) == 0:
        GPIO.output(5, GPIO.LOW)
        print('Relay 10 OFF')





@blynk.on("connected")
def blynk_connected():
    print('Connected')
while True:
    blynk.run()

@Sourabh53525 please read this topic and edit your post to add-in the missing information, and to correct the formatting of your serial output…

Pete.

Dear Sir,
I am trying to connect blynk2.0 with Raspberry pi but getting this type error from the BlynkLib

[Unformatted error message removed by moderator]

I’d suggest you click the link I provided in post #2 and read it from start to finish before you go any further.

Pete.

Dear Sir,
I have attached tags and changed the category into issues and errors.

[Screenshot of code and error message removed by moderator]

I’ve removed your screenshot. You need to be the serial monitor posting text, with triple backticks at the beginning and end, as explained in the link I provided in post #2 - which I would recommend you read before posting again.

The correct category for this topic is “need help with my project” please don’t keep changing the category.

We have a set of community rules and expectations when it comes to creating topics that are asking for assistance. These expect are outlined in the link I provided in post #2, which you continue to ignore.

If you want assistance then provide ALL of the requested information in the correct format.

Pete.

@Sourabh53525 Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Copy and paste these if you can’t find the correct symbol on your keyboard.

done

So, your first post in this topic now provides what was asked for in one of the four bullet points of item 10 in the topic that I linked to in post #2

Are you going to provide the data requested in the three other bullet points of item 10, and address the issues raised in the other 15 items in that post?

Pete.

[Screenshot remove by moderator]

here is the screenshot of error
Hardware used is Raspberry Pi 3 Model B V1.2

can u please help me, how to get logs in serial monitor in raspberrypi

Do you know how to copy paste text, and can you remember how to insert triple backticks at the beginning and end of that text?

Pete.

    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ for Python v1.0.0 (linux)

Connecting to blynk.cloud:443...
Traceback (most recent call last):
  File "/home/pi/blynk_10_relay.py", line 21, in <module>
    blynk = BlynkLib.Blynk(BLYNK_AUTH)
  File "/home/pi/BlynkLib.py", line 214, in __init__
    BlynkProtocol.__init__(self, auth, **kwargs)
  File "/home/pi/BlynkLib.py", line 81, in __init__
    self.connect()
  File "/home/pi/BlynkLib.py", line 226, in connect
    s.connect(socket.getaddrinfo(self.server, self.port)[0][-1])
TypeError: AF_INET address must be a pair (host, port)

Please check now

That’s fine, so one of the other bullet points for item 10 checked-off.

Pete.

last one screenshot of error but u deleted it

![Screenshot 2023-03-09 172418|617x405](upload://mXrmWahCZmm99oKjWOQjsBnVNwm.png) 

Yes, you need to post text not screenshots, with triple backticks wher appropriate, but how can this be the “last one”

There are 14 things in the list, and you’ve provided two sub-parts of one of those 14 items.

Pete.

1.)There is no iidentical topic we have read almost all.
2.)we checked the blynk docs
3.) we already did it and selected carefully
4.)Our Raspberrypi 3 model B V1.2 works perfectly fine
5.)we have latest version of blynk library from github https://github.com/vshymanskyy/blynk-library-python/blob/master/BlynkLib.py
6.)we are working under tariff limits.
7.) not a beginner
8.) we have read trouble shooting guides.
9.)Installed latest blynk in samsung a20
10.)Already provided sketch with triple backticks
11.)server Region:blr1
12.)Not a problem with mobile app
13.)Not a problem with webconsole
14.)already attached in above comments
15.)no bug
16.)FREE

Sir , I hope this is it if any thing else please tell.

here is all the things from the list