การเชื่อมต่อServer blynk ที่แจก energy 10M free กับบอร์ด raspberry pi 4

รบกวนผู้รู้ช่วยแนะนำหน่อยค่ะ ตอนนี้ได้รับenergy 10M free เรียบร้อยแล้ว แต่ติดปัญหาที่projectใน blynk ยังขึ้น offlineอยู่เลยค่ะ มีโค้ดบรรทัดไหนผิดช่วยแนะนำด้วยนะคะ ขอบคุณค่ะ

เอาโค้ตมาวางเลยครับ แล้วในแอพเลือกเป็นบอร์ดอะไรเอาไว้

ขอบคุณค่ะ
ในแอพเลือกเป็น Raspberry Pi A/B (Rev2) (WIFI) ค่ะ
เอาโค้ดมาวางแล้วนะคะ แต่ติด syntax error ตามภาพเลยค่ะ ไม่แน่ใจว่าต้องแก้โค้ดยังไงค่ะ

อยากให้เอาโค้ตที่เป็น Text มาวางครับ อยู่ในภาพ จะทำให้ทดสอบหรือ แก้ไขโค้ตยาก

Thank you kaa.

import blynklib
import RPi.GPIO as GPIO
import time, sys

BLYNK_AUTH = 'GBbXx7a0xR0yZroYmnEXz59awknEYG63' 
# initialize Blynk
blynk = blynklib.Blynk(BLYNK_AUTH)


blynk.begin(auth); # Change your ethernet sketch from
blynk.begin(auth, "osasiskit.com",8080); # to
blynk.begin(auth,SSID,pass); # Change your WIFI sketch from
blynk.begin(auth,SSID,pass,"osasiskit.com",8080); # to
var blynk = new Blynk.Blynk(AUTH,options = {connector:new Blynk.TcpClient()}); # Change your rasp PI javascript from
var blynk new Blynk.Blynk(AUTH.options = {addr:"128.199173.118",port:8080}); # to


WRITE_EVENT_PRINT_MSG = "[WRITE_VIRTUAL_PIN_EVENT] Pin: V{} Value: '{}'"

#set up relay
relay1 = 11 #define relay1 GPIO17
relay2 = 13 #define relay2 GPIO27
relay3 = 15 #define relay3 GPIO22
GPIO.setmode(GPIO.BOARD) # use PHYSICAL GPIO Numbering
GPIO.setup(relay1, GPIO.OUT) # set the relay1 to OUTPUT mode
# GPIO.output(relay1, GPIO.LOW) # make relay1 output LOW level
GPIO.setup(relay2, GPIO.OUT) # set the relay2 to OUTPUT mode
GPIO.output(relay2, GPIO.LOW) # make relay2 output LOW level
GPIO.setup(relay3, GPIO.OUT) # set the relay3 to OUTPUT mode
GPIO.output(relay3, GPIO.LOW) # make relay3 output LOW level

@blynk.handle_event('write V1')
def write_virtual_pin_handler(pin, value):
        if value == ['255']:
                print(WRITE_EVENT_PRINT_MSG.format(pin, value))
                print('Relay on')
                GPIO.output(relay1, GPIO.HIGH)
        else:
                print(WRITE_EVENT_PRINT_MSG.format(pin, value))
                print('Relay off')
                GPIO.output(relay1, GPIO.LOW)

# register handler for virtual pin V2 write event
@blynk.handle_event('write V2')
def write_virtual_pin_handler(pin, value):
        if value == ['255']:
                print(WRITE_EVENT_PRINT_MSG.format(pin, value))
                print('Relay on')
                GPIO.output(relay2, GPIO.HIGH)
        else:
                print(WRITE_EVENT_PRINT_MSG.format(pin, value))
                print('Relay off')
                GPIO.output(relay2, GPIO.LOW)
                
# register handler for virtual pin V3 write event
@blynk.handle_event('write V3')
def write_virtual_pin_handler(pin, value):
        if value == ['255']:
                print(WRITE_EVENT_PRINT_MSG.format(pin, value))
                print('Relay on')
                GPIO.output(relay3, GPIO.HIGH)
        else:
                print(WRITE_EVENT_PRINT_MSG.format(pin, value))
                print('Relay off')
                GPIO.output(relay3, GPIO.LOW)
while True:
    blynk.run()

ลองดูครับ

import blynklib
import RPi.GPIO as GPIO
import time, sys

BLYNK_AUTH = 'GBbXx7a0xR0yZroYmnEXz59awknEYG63' 
# initialize Blynk
blynk = blynklib.Blynk(BLYNK_AUTH)


blynk.begin(auth); # Change your ethernet sketch from
blynk.begin(auth,SSID,pass,"osasiskit.com",8080); # to
var blynk = new Blynk.Blynk(AUTH,options = {connector:new Blynk.TcpClient()}); # Change your rasp PI javascript from
var blynk new Blynk.Blynk(AUTH.options = {addr:"128.199173.118",port:8080}); # to


WRITE_EVENT_PRINT_MSG = "[WRITE_VIRTUAL_PIN_EVENT] Pin: V{} Value: '{}'"

#set up relay
relay1 = 11 #define relay1 GPIO17
relay2 = 13 #define relay2 GPIO27
relay3 = 15 #define relay3 GPIO22
GPIO.setmode(GPIO.BOARD) # use PHYSICAL GPIO Numbering
GPIO.setup(relay1, GPIO.OUT) # set the relay1 to OUTPUT mode
# GPIO.output(relay1, GPIO.LOW) # make relay1 output LOW level
GPIO.setup(relay2, GPIO.OUT) # set the relay2 to OUTPUT mode
GPIO.output(relay2, GPIO.LOW) # make relay2 output LOW level
GPIO.setup(relay3, GPIO.OUT) # set the relay3 to OUTPUT mode
GPIO.output(relay3, GPIO.LOW) # make relay3 output LOW level

@blynk.handle_event('write V1')
def write_virtual_pin_handler(pin, value):
        if value == ['255']:
                print(WRITE_EVENT_PRINT_MSG.format(pin, value))
                print('Relay on')
                GPIO.output(relay1, GPIO.HIGH)
        else:
                print(WRITE_EVENT_PRINT_MSG.format(pin, value))
                print('Relay off')
                GPIO.output(relay1, GPIO.LOW)

# register handler for virtual pin V2 write event
@blynk.handle_event('write V2')
def write_virtual_pin_handler(pin, value):
        if value == ['255']:
                print(WRITE_EVENT_PRINT_MSG.format(pin, value))
                print('Relay on')
                GPIO.output(relay2, GPIO.HIGH)
        else:
                print(WRITE_EVENT_PRINT_MSG.format(pin, value))
                print('Relay off')
                GPIO.output(relay2, GPIO.LOW)
                
# register handler for virtual pin V3 write event
@blynk.handle_event('write V3')
def write_virtual_pin_handler(pin, value):
        if value == ['255']:
                print(WRITE_EVENT_PRINT_MSG.format(pin, value))
                print('Relay on')
                GPIO.output(relay3, GPIO.HIGH)
        else:
                print(WRITE_EVENT_PRINT_MSG.format(pin, value))
                print('Relay off')
                GPIO.output(relay3, GPIO.LOW)
while True:
    blynk.run()

Thank you very much but I got syntax error in below.

blynk.begin(auth,SSID,pass,“osasiskit.com”,8080); # to
^
SyntaxError: invalid syntax

ขอที่มาของโค้ตชุดนี้หน่อยครับ