📖
CorgiDude
  • Introduction
  • Specification
  • Installation
    • การใช้งาน Maixpy IDE เบื้องต้น
    • วิธีการลง Maixpy ใน Sipeed Maix Bit
    • การใช้งาน Kflash GUI และการอัพโหลดไฟล์ .bin kmodel
  • Lessons
  • Article & API
    • การใช้งาน GPIO
    • การอ่านและเขียนไฟล์ SD Card
    • การเชื่อมต่อ WiFi
    • การใช้งาน HTTP Request
    • การใช้งาน MQTT
    • การใช้งาน Google Spreadsheet ผ่านทาง IFTTTT
    • การใช้งาน LINE Notify
    • การใช้งาน ThingSpeak
    • การใช้งาน Google Vision
  • Modules
    • Button Switch
    • Drive Motor
    • GPIO Input
    • Servo Motor
  • Demo Projects
    • Face Recognition
      • ตอนที่ 1
      • ตอนที่ 2
      • ตอนที่ 3
      • ตอนที่ 4
    • Image Classification
      • CorgiDude บอร์ด Image Classification โดยใช้ MobileNetV1
      • CorgiDude บอร์ด Image Classification โดยใช้ Transfer Learning MobileNetV1
    • Object Detection
      • CorgiDude บอร์ดกับการทำ Object Detection โดยใช้ Yolo
      • CorgiDude บอร์ด ตรวจจับใบหน้าด้วย Yolo Face Detection
      • CorgiDude บอร์ดกับการทำ Cat Face Detection โดยใช้ Yolo2
      • การทำ Dataset แบบ Object Detection ชนิด VOC ที่สามารถเอาไปใช้ตอนเทรนใน Yolo2 ได้เลย
      • CorgiDude บอร์ดกับการทำ License Plate Detection ของรถมอเตอร์ไซค์ โดยใช้ Yolo2
      • CorgiDude บอร์ด ตรวจจับใบหน้า และ Mask ด้วย Yolo2 Face Mask Detection
  • Downloads
    • Firmware
    • Models
Powered by GitBook
On this page

Was this helpful?

  1. Article & API

การใช้งาน LINE Notify

Previousการใช้งาน Google Spreadsheet ผ่านทาง IFTTTTNextการใช้งาน ThingSpeak

Last updated 4 years ago

Was this helpful?

สำหรับบทความนี้ เราจะลองมาใช้ LINE notify จาก CorgiDude ด้วย library Corgi85 กันนะครับ

ก่อนอื่นเพื่อนๆ จะต้องทำการอัพเกรดเฟิร์มแวร์ CorgiDude และโปรแกรม library Corgi85 ลงใน ESP 8285 ก่อน โดยสามารถดูรายละเอียดได้จาก จากนั้นเพื่อนๆก็ต้องสร้างตัว LINE bot ซึ่งจะเชื่อมต่อกับ LINE ID ของเรา โดยจะทำให้เราสามารถแจ้งเตือนในกลุ่มที่เราแอด bot เข้าไปด้วยได้ สามารถดูรายละเอียดเพิ่มได้ที่ (เมื่อทำการสร้างตัว LINE bot เรียบร้อยแล้ว เราจะต้องใช้ตัวรหัส token ในการใช้งาน) โดยวิธีการดังนี้**

เปิดเว็ป ทำการสแกน QR Code เพิ่ม "LINE Notify" เป็นเพื่อน

กด "เข้าสู่ระบบ" ใส่ E-mail และ password ของ LINE ที่เราลงทะเบียนไว้จากนั้นกด "LOGIN"

จากนั้นเปิด tap เลือก "My page"

กด "Generate token"

ตั้งชื่อให้ LINE bot และกลุ่มแชทที่ต้องการให้แจ้งเตือน โดยผมจะเลือกเป็น 1-no-1 เพื่อทำการทดสอบ **กด "Generate token"**

เราจะได้รหัส token ที่ใช้ในการแจ้งเตือนให้กด Copy ไว้ เป็นการเสร็จเรียบร้อย

import sensor, image, time, lcd
from Corgi85 import corgi85


token = "sqdSuyH9oidoRBZG5T72UdpYiMFcgeUEifAYTmSfdo8"

#reset esp8285
corgi85.reset()
#print(dir(corgi85))

#setup camera
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)

#sensor.set_windowing((224, 224))
#sensor.set_vflip(1)
#sensor.set_hmirror(0)
sensor.run(1)

#setup LCD screen
lcd.init()
lcd.rotation(0)

time.sleep(1)

count = 0
while(corgi85.wifi_check() == 0):
    print("WIFI Connecting")
    time.sleep(1)

print("\n\nWIFI Connected")

print("\n\nSet line Token:",token)
corgi85.LINE_setToken(token)  #set line Token

print("\n\nsend line image")
img = sensor.snapshot() # camera capture image
lcd.display(img)        # lcd  display image
corgi85.LINE_notifyPicture(img, "CorgiDude LINE notify Picture")   # send image to line noti
time.sleep(3)

print("\n\nsend message to line noti: Hello From CorgiDude")
corgi85.LINE_notify("Hello From CorgiDude")
time.sleep(3)

print("\n\nsend line sticker")
corgi85.LINE_notifySticker(1, 1)   # detail : https://devdocs.line.me/files/sticker_list.pdf
time.sleep(3)

print("\n\nsend line sticker & message")
corgi85.LINE_notifySticker_text("Hello From CorgiDude", 1, 1) #detail :  https://devdocs.line.me/files/sticker_list.pdf

##print("\n\n",dir(corgi85))



## https://github.com/AiDude-io/CorgiDude/tree/master/08%20-%20Face%20Detection << download kmodel
#import sensor
#import image
#import lcd
#import KPU as kpu
#from Corgi85 import corgi85


#while(corgi85.wifi_check() == 0):
    #print("WIFI Connecting")
    #time.sleep(1)

#token = "sqdSuyH9oidoRBZG5T72UdpYiMFcgeUEifAYTmSfdo8"
#corgi85.LINE_setToken(token)  #set line Token


#lcd.init()
#lcd.rotation(0)

#sensor.reset()
#sensor.set_pixformat(sensor.RGB565)
#sensor.set_framesize(sensor.QVGA)
#sensor.run(1)

#task = kpu.load(0x300000)

#anchor = (1.889, 2.5245, 2.9465, 3.94056, 3.99987, 5.3658, 5.155437, 6.92275, 6.718375, 9.01025)
#a = kpu.init_yolo2(task, 0.5, 0.3, 5, anchor)

#while(True):
    #img = sensor.snapshot()

    #faces = kpu.run_yolo2(task, img)

    #if faces:
        #for face in faces:
            #img.draw_rectangle(face.rect(),color=(0,255,0),thickness=2)
    #img = img.resize(240,240)
    #lcd.display(img)

    #if faces:
        #img2 = sensor.snapshot()
        #corgi85.LINE_notifyPicture(img2, "Detected some people")

#kpu.deinit(task)

เท่านี้เพื่อนๆก็สามารถแจ้งเตือนผ่าน LINE ด้วย CorgiDude ได้แล้วครับ

เมื่อเราได้รหัส **token มาแล้วก็สามารถเอามาใช้ใน code micropython ที่ใช้ใน** **CorgiDude ได้เลย** โดย ตัวอย่าง code เป็นแบบนี้ครับ ()

รายละเอียดเพิ่มเติม LINK
https://www.aiiotshop.com/b/22
https://www.aiiotshop.com/article/21/
https://notify-bot.line.me/en/
https://notify-bot.line.me/en/