Petoi Doc Center
🇹🇭 Thai
🇹🇭 Thai
  • ยินดีต้อนรับสู่ Petoi Doc Center
  • Infrared Remote
    • รีโมทคอนโทรล
  • Mobile App
    • คาลิเบเตอร์และคอนโทรลเลอร์
  • Desktop APP
    • การแนะนำเบื้องต้น
    • ตัวอัปโหลดเฟิร์มแวร์
    • การคาลิเบรทข้อต่อ
    • สกิลคอมโพสเซอร์
  • Arduino IDE
    • อัปโหลด Sketch สำหรับ NyBoard
    • อัปโหลด Sketch สำหรับ BiBoard
    • การคาลิเบรทด้วย Arduino IDE
    • ซีเรียลมอนิเตอร์
  • API
    • 🖇️ซีเรียลโปรโตคอล
    • 🐍คู่มือผู้ใช้ Python SerialMaster
    • 🐛MicroPython คอนโทรลเลอร์
      • การเรียกใช้ MicroPython บน ESP8266
      • ติดตั้ง WebREPL
      • การใช้โปรโตคอล ESP-NOW
    • 🍓การสื่อสารผ่านพอร์ตซีเรียลของ Raspberry Pi
    • 🤖ROS
  • Nyboard
    • NyBoard V1_0
    • NyBoard V1_1
  • BIBOARD
    • คู่มือเริ่มต้นใช้งาน BiBoard ฉบับรวบลัด
    • Demo Applications
      • 1.GPIO port
      • 2.Serial port
      • 3.Analog-digital converter
      • 4.Digital-Analog Converter
      • 5.EEPROM (Electrically Erasable Programmable read only memory)
      • 6.Gyro IMU(MPU6050)
      • 7.Infrared remote control
      • 8.PWM(Pulse Width Modulation)
      • 9.Servo(under construction)
      • 10.Classic Bluetooth serial port SPP
      • 11.Bluetooth low energy (BLE) serial port pass-through
      • 12.File system SPIFFS
      • 13.Add hardware partition configuration option in Arduino IDE
      • 14.Play MP3
      • 15.The usage of Wi-Fi OTA(Over-The-Air)
  • Communication Modules
    • Introduction
    • USB Uploader (CH340C or CH343G)
    • Dual Mode Bluetooth
    • WiFi ESP8266
      • ESP8266 + Python Scripts Implement wireless crowd control
  • Extensible Modules
    • Introduction
    • MU Camera
    • Ultrasonic Sensor
    • Light Sensor
    • Touch Sensor
    • Gesture Sensor
    • PIR Motion Sensor
  • Applications
    • Skill Creation
    • OpenCat Imitation Tutorial
    • Programmable Puppet Character
  • History
    • Upload Sketch For NyBoard (software 1.0)
  • Technical Support
    • 🛠️Supporting Application and Software
    • 🙋‍♂️FAQ(Frequently Asked Questions)
  • Useful Links 🕸
    • 🔭Official Site of Petoi
    • 💿GitHub of OpenCat
    • 🎪PetoiCamp (Forum)
Powered by GitBook
On this page
  • Setup environment
  • Script introduction
  • How to Use

Was this helpful?

Export as PDF
  1. Communication Modules
  2. WiFi ESP8266

ESP8266 + Python Scripts Implement wireless crowd control

PreviousWiFi ESP8266NextIntroduction

Last updated 2 years ago

Was this helpful?

Setup environment

โปรดอ้างอิงคำแนะนำของ และใช้ เพื่อเปิดโปรแกรมตัวอย่าง (ESP8266WiFiController.ino) เพื่ออัปโหลดเฟิร์มแวร์ควบคุม WiFi สำหรับโมดูล ESP8266

Install Python3, and download to control the robot.

Script introduction

สำหรับ Python เวอร์ชัน 3.8 ขึ้นไป มีการเปลี่ยนแปลง Syntax ในการกำหนด Type ของตัวแปร สคริปต์นี้สามารถใช้งานได้แต่ต้อง comment และ uncomment หลายคำสั่งที่เกี่ยวข้องตามรุ่นของ Python ที่คุณได้ติดตั้งไว้ ตัวอย่างเช่นสคริปต์ด้านล่างนี้รองรับ Python เวอร์ชันต่ำกว่า 3.8:

"""
In Python 3.8 and earlier, the name of the collection type is
capitalized, and the type is imported from the 'typing' module
"""
# from typing import Union, Optional             # for Python 3.9+
from typing import Union, Dict, List, Optional   # for Python 3.7

แอปสคริปต์นี้สามารถควบคุมหุ่นยนต์ได้เพียงหนึ่งตัว หรือควบคุมหลายตัวพร้อมกันได้ โดยสามารถทำได้โดยการแก้ไขคำสั่งต่อไปนี้ใน example.py:

# ip = "192.168.0.108"                     # for only one robot
ip = ["192.168.0.110", "192.168.0.108"]    # for multiple robots

How to Use

อ้างอิงถึง ให้กำหนด IP address ของโมดูล ESP8266 ผ่าน WiFi และนำมาต่อกับบอร์ดหลักของหุ่นยนต์ หลังจากนั้นเมื่อเปิดเครื่องหุ่นยนต์แล้ว คุณสามารถใช้ python เพื่อรันสคริปต์ example.py เพื่อควบคุมหุ่นยนต์ได้ผ่านวิธีไร้สาย คุณสามารถปรับแต่งคำสั่งในสคริปต์ต่อไปนี้ (แก้ไขเนื้อหาของ list) ตามความต้องการจริงของคุณ เพื่อให้หุ่นยนต์ทำการแสดงพฤติกรรมต่างๆ ได้:

cmds = [
        Command.sit, Command.balance, Command.stepping, Command.pee,
        Command.stop
    ]

สำหรับคำสั่งการกระทำที่รองรับในปัจจุบันโปรดดูที่ไฟล์โค้ด actions.h(in ).

WiFi ESP8266
Arduino IDE
the Python scripts
the instruction
ESP8266WiFiController