[TH] List the serial ports connected to the RPi with pySerial and PyQt5.

จากบทความก่อหน้านี้เราได้อ่านรายชื่ออุปกรณ์ที่เชื่อมต่อกับพอร์ตอนุกรมของบอร์ด Raspberry Pi หรือ RPi ด้วยไลบรารี pySerial ดังภาพที่ 1 ในแบบโหมดตัวอักษรไปแล้ว ในบทความนี้เป็นการผนวกหลักการทำงานจากก่อนหน้าเข้ากับการใช้ส่วนติดต่อกับผู้ใช้แบบกราฟิกส์ หรือ GUI (Graphics User Interface) ผ่านทางไลบรารี PyQt5 โดยแสดงรายการเอาไว้ใน combobox เพื่อให้ผู้ใช้งานเลือกใช้งานได้ แต่ถ้าไม่พบพอร์ตสื่อสารอนุกรมที่เชื่อมต่อกับบอร์ด RPi จะปิดการใช้งานของ combobox ไม่ให้ผู้ใช้งานเลือกใช้งาน ดังนั้น บทความนี้จึงมีเนื้อหาเกี่ยวกับการประยุกต์ใช้ pySerial กับการใช้งานของ QLabel และ QComboBox ในไลบรารี PyQt5

[TH] List the serial ports connected to the RPi with pySerial.

บทความนี้กล่าวถึงการใช้ไลบรารี pySerial ของภาษาไพธอนบนบอร์ด Raspberry Pi หรือ RPi ทั้งรุ่น 3 และ 4 เพื่อเชื่อมต่อกับพอร์ตสื่อสารอนุกรม (Serial Port) ซึ่งตัวบอร์ดสามารถทำได้ 2 ลักษณะคือ ใช้ฮาร์ดแวร์อย่าง ET-CONV10/RS232 HAT ที่ได้เขียนถึงในหนังสือ กับการใช้พอร์ต USB เชื่อมต่อกับตัวแปลงเป็นพอร์ตสื่อสารอนุกรม (USB to Serial Port) ดังภาพที่ 1 โดยบทความนี้เป็นการใช้แบบที่ 2 เพื่อเรียกใช้ pySerial สำหรับตรวจสอบว่ามีพอร์ตอนุกรมเชื่อมต่ออยู่กี่พอร์ตและชื่ออะไรบ้าง ดังตัวอย่างในภาพที่ 8

ภาพที่ 1 การเชื่อมต่อ ET-USB/RS232 Mini เข้ากับพอร์ต USB ของ RPi

[EN] machine.SPI

From the article machine.Pin, it has been discussed using a microcontroller pin to import and export data and in the article I2C bus communication which uses the machine.I2C class to communicate between devices. Now let’s take a look at the machine.SPI class, another form of communication that has been recognized for its speed and is commonly used with a graphics display (esp8266/esp32 article) or SD-Card reader (esp8266, esp32article).

[EN] ESP32 machine.Timer

This article discusses the use of 4 timers of the ESP32 to be used to run the program when it meets the specified time. Difference Between Using Timer and Delay time.sleep()/time.sleep_ms()/time.sleep_us() is that time delay is a loop to allow the processor to spend time looping to complete the specified amount of time whereas the timer uses the principle of having a function run every time a specified time is reached, so while a timer does not call a function to execute the processor has idle time for other processing, and unlike interrupts, it is a timer interrupt instead of a pin state interrupt connected to an external circuit.

[EN] Arduino: Joystick Module

This article is programming to write a program to use the joystick module as shown in Figure 1, in which the module can tell the X-axis movement, Y-axis movement, and the state of pressing the switch on the joystick. An example of this module is to use the esp32 board using C++ to connect to the GPIO using the commands mentioned in this article.

(Figure. 1 esp32 with joystick

[EN] PyQt5

This article provides an example of opening a window and using a button in response to PyQt5, which is the basis for using the other components. The highlight of Qt is that it is a cross-platform C++ development kit and covers the integration for compatibility with languages such as PyQt, “The python binding for the Qt cross-platform C++ framework” developed by Riverbank Computing Limited, currently released in PyQt 6.1.1 (2021-06-29).

[TH] Control movement from a joystick via WiFi with MicroPython.

บทความนี้เกิดจากการนำบทความการเขียนโปรแกรมไคลเอนต์/เซิร์ฟเวอร์สำหรับสถานีอากาศผ่านระบบเครือข่ายไร้สาย หรือ WiFi มาปรับเปลี่ยนจากการอ่านข้อมูลจากเซ็นเซอร์มาเป็นจอยสติกชิลด์ (Arduino Joystick Shield) เพื่อให้กลายเป็นเกมคอนโทรลเลอร์แบบไร้สายโดยใช้ MycroPython กับไมโครคอนโทรลเลอร์ ESP32 ดังภาพที่ 1 ทำให้สามารถควบคุมการเคลื่อนที่ของวัตถุในจอแสดงผลผ่านจอ TFT แบบ ST7735 ที่เชื่อมต่อกับ ESP32 อีกตัวหนึ่งได้ ซึ่งจะพบว่าการใช้งานภาษาไพธอนของ MicroPython นั้นสามารถนำมาใช้งานได้กับกรณีตัวอย่างนี้ และด้วยภาษาที่เขียนได้ง่ายประกอบกับสามารถปรับแก้โค้ดได้โดยไม่ต้องคอมไพล์และอัพโหลดใหม่จึงสะดวกต่อการเขียนโค้ดต้นแบบเพื่อนำไปพัฒนาให้มีความเร็วในการทำงานที่สูงขึ้นต่อไป

Control movement from a joystick via WiFi
ภาพที่ 1 อุปกรณ์การทดลองในบทความ