[EN]Calculate Regression with NumPy.


This article is to convert the implementation of the regression model from the article of ESP32-C3 to NumPy on Raspberry Pi and PC and use the display as Matplotlib, as shown in Figure 1, which can be found from the previous article. The temperature and humidity from the 1-day data were obtained from parameters a and b of the regression equation and the resulting equation or model was used to determine the possible temperature values over the 1 day.

Figure 1 Result of the program
Read More

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

In the previous article, we have read the list of devices connected to the serial port of the Raspberry Pi board or RPi with the pySerial library in text mode as shown in Figure 1. This article combines the previous working principles with the use of a graphical user interface via the PyQt5 library, listed in the combobox for users to choose from. If no serial port connected to the board is found, the RPi disables the combobox from user selection. Therefore, this article discusses the implementation of pySerial with the QLabel and QComboBox libraries. PyQt5.

Read More

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

This article discusses the use of Python language pySerial library on Raspberry Pi or RPi both 3rd and 4th generation to connect to the serial port. It can be done in 2 ways, the first is to use hardware like ET-CONV10/RS232 HAT that has been written in the book and with the use of a USB port connected to a converter to be a serial communication port (USB to Serial Port) as shown in Figure 1. This article uses the second method to run pySerial to check how many serial ports are connected and what are their names as an example in Figure 8.

Figure 1 Connect ET-USB/RS232 Mini to RPi’s USB
Read More

[TH] Calculate Regression with NumPy.

บทความนี้เป็นการแปลงการใช้งานโมเดลรีเกรสชันจากบทความของ ESP32-C3 มาเป็น NumPy บน Raspberry Pi และ PC พร้อมทั้งใช้การแสดงผลเป็น Matplotlib ดังภาพที่ 1 ซึ่งจะพบว่า จากบทความก่อนหน้านี้ได้นำค่าอุณหภูมิและความชื้นจากข้อมูล 1 วันมาหาพารามิเตอร์ a และ b ของสมการถดถอยหรือรีเกรสชัน (regression) และนำสมการหรือโมเดลที่ได้นี้มาหาค่าของอุณหภูมิที่เป็นไปได้ในช่วงเวลา 1 วัน

ภาพที่ 1 ผลลัพธ์ของตัวอย่างโปรแกรม
Read More

[EN] PyGlet

pyglet is a Python library to create windows and cross-platform multimedia on Windows (Windows), MacOS (macOS) and Linux (Linux) for developing games or visualization applications. The library itself supports creating windows, integration with users through an event-based system, support OpenGL graphics, image/video loading support, and playing music. This article discusses installing and using pyglet on Raspberry Pi 3 B+ and Raspberry Pi 4 as a test device.

(Figure. 1 Example from 1-6)
Read More

[TH] LEDs on/off via PyQt5 and serial communication.

ในบทความนี้ใช้ความรู้จากบทความการอ่านรายชื่อพอร์ตอนุกรมที่ถูกเชื่อมต่อมาปรับปรุงให้เป็นการส่งข้อมูลส่งไปให้บอร์ด Arduino Uno ที่มีหลอดแอลอีดี (LED) เชื่อมต่ออยู่ที่ขา 2,3,4,5,6,7,8 และ 9 ทำให้ผู้ใช้งานสามารถสั่งเปิดหรือปิดหลอดดังกล่าวด้วยการสั่งงานผ่าน GUI (Graphics User Interface) ของ PyQt5 ดังภาพที่ 1 และส่งข้อมูลไปให้บอร์ด Uno ทางพอร์ตสื่อสารอนุกรมด้วย pySerial โดยในตัวอย่างครั้งนี้ การทำงานรองรับทั้งระบบปฏิบัติการ Windows, macOS และ Linux ซึ่งจะทำให้เห็นว่า PyQt5 และ pySerial สามารถรองรการทำงานกับทั้ง 3 ระบบได้

Read More

[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

Read More

[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
Read More