[EN] Binary Search Tree data structure programming with Python.

In the previous article, programming to implement queue-based data structures was introduced. In this article, we introduce programming to manage another type of data structure which has different storage and management methods called BST tree or Binary Search Tree, as shown in Figure 1, which is a structure that can be applied to data collection with attributes in which the data in the left branch is less than itself and the right branch is greater than itself or the opposite, i.e. the left branch has a greater value and the right branch is less. It enables searching for data in cases where the tree is balanced on the left and right in the BST structure, saving half the time or number of search times per round of available data, e.g. 100 data sets in the first round if it is not the information you are looking for will be left with a choice to find from the left or right branches which the selection causes the information of the other side is not considered or cut off approximately half. However, if the Binary Search Tree is out of balance, the search speed is not much different from the sequential search.

In this article, we use Python that works on either a Python 3 or MicroPython interpreter to store the data, adding information ,searching for information as an example of further development.

BST : Binary Search Tree
Figure 1 BST
Read More

[EN] The MaixPy’s image class Part 1. draw and find something.

This article discusses how to use image class with TFT-LCD display module of Sipeed M1W dock suit board via lcd class (MaixPy’s lcd class) as shown in Figure 1 provided with MaixPy to study the list of commands provided by image class and an example program using commands about creating a buffer object, clearing the value in the buffer, deleting the buffer, drawing straight lines, circles, squares, character display, saving data from the buffer to memory card (microSD Card), searching for straight lines in buffer (find_lines), finding circles in the buffer, find_circles and find squares (find_rects) in buffers with built-in functionality. It uses the Hough Transform principle to find the position and parameters of the searched object.

(Figure. 1 Sipeed M1W dock suit)
Read More

[EN] Understand and use the ESP32-C3

We have been using the esp8266, especially the esp-01 and esp-01s modules, to manage the sensor network for quite some time and with the limitation in terms of the number of pins used, the system must be designed to work with STM32F103C8T6 or STM32F401CCU6/STM32F411CEU6. To ensure stable operation, no problems with the esp8266’s WDT were encountered, and over time, espressif released several other microcontrollers such as esp32, esp32-s2, esp32-c3 and esp32-s3.

We have tested and used esp32 almost all the time until esp32-s2 with LILYGO board made us try to order it. The main problem is that the development tools are very late. However, as of now, espressif has released a development kit for Arduino or Arduino Core for ESP32 version 2.0 with support for esp32 esp32-s2 and esp32c3, making it work with ESP32 and ESP32-S2. We got the esp-c3-32s board so this article was born.

This article is compiled from the datasheet of ESP32-C3 WROOM-02, in this article we use the board as shown in Figure 1. The example program is to drive an RGB LED on the board to work by using Arduino Core for ESP32 and the improved ESP-IDF from the article in Ep. 3

(Figure. 1 ESP32-C3)
Read More

[TH] Binary Search Tree data structure programming with Python.

ในบทความก่อนหน้านี้ได้แนะนำการเขียนโปรแกรมเพื่อใช้โครงสร้างข้อมูลแบบคิวไปแล้ว ในบทความนี้จึงแนะนำการเขียนโปรแกรมจัดการโครงสร้างข้อมูล (Data Structure) อีกประเภทหนึ่งซึ่งมีวิธีการจัดเก็บและจัดการที่แตกต่างกันไปอันมีชื่อว่าต้นไม้แบบ BST หรือ Binary Search Tree ดังในภาพที่ 1 ซึ่งเป็นโครงสร้างที่สามารถนำไปประยุกต์เกี่ยวกับการเก็บข้อมูลที่มีคุณลักษณะที่ข้อมูลทางกิ่งด้านซ้ายมีค่าที่น้อยกว่าตัวเอง และกิ่งด้านขวามีค่ามากกว่าต้นเอง หรือทำตรงกันข้ามคือกิ่งซ้ายมีค่ามากกว่า และกิ่งด้านขวามีค่าน้อยกว่า ทำให้การค้นหาข้อมูลในกรณีที่ต้นไม้มีความสมดุลย์ทั้งทางซ้ายและทางขวาบนโครงสร้าง BST ประหยัดเวลาหรือจำนวนครั้งในการค้นหาลงรอบละครึ่งหนึ่งของข้อมูลที่มี เช่น มีข้อมูล 100 ชุด ในรอบแรกถ้าตัวเองยังไม่ใช่ข้อมูลที่กำลังค้นหา จะเหลือทางเลือกให้หาจากกิ่งทางซ้ายหรือขวา ซึ่งการเลือกทำให้ข้อมูลของอีกฝั่งนั้นไม่ถูกพิจารณา หรือตัดทิ้งไปครึ่งหนึ่งโดยประมาณ แต่ถ้าเป็นกรณีที่ Binary Search Tree นั้นขาดความสมดุลย์จะส่งผลให้การค้นหามีความเร็วไม่แตกต่างกับการค้นหาแบบลำดับ (Sequential Search) เท่าใดนัก

ในบทความนี้ใช้ภาษาไพธอนที่ทำงานได้ทั้งบนตัวแปลภาษา Python 3 หรือ MicroPython เพื่อจัดเก็บข้อมูล การเพิ่มข้อมูล การค้นหาข้อมูล เพื่อเป็นตัวอย่างของการนำไปพัฒนาต่อไป

BST : Binary Search Tree
ภาพที่ 1 ตัวอย่าง BST
Read More

[TH] Calculate Regression with MicroPython on esp32-C3.

บทความนี้กล่าวถึงการคำนวณค่าถดถอย (Regression) ด้วยภาษาไพธอนของ MicroPython โดยใช้บอร์ดไมโครคอนโทรลเลอร์ ESP32-C3 พร้อมทั้งแสดงผลด้วยจอแสดงผลกราฟิกแบบ 2 สี (แสดงกับไม่แสดงเม็ดสี) แบบ OLED ดังภาพที่ 1 ซึ่งค่าที่นำมาใช้เป็นตัวอย่างในการใช้งานเป็นค่าที่ได้จากการอ่านอุณหภูมิ

ภาพที่ 1 บอร์ด ESP32-C3 ที่ต่อเติมโมดูล OLED และขาสำหรับเชื่อมต่อภายนอก
Read More

[TH] How to build MicroPython for esp32-C3.

บทความนี้กล่าวถึงการคอมไพล์ (build) และใช้งาน MicroPython สำหรับไมโครคอนโทรลเลอร์ esp32-C3 ที่ได้เคยแนะนำไปแล้ว โดยขั้นตอนยังเหมือนกับการคอมไพล์สำหรับ esp32-s2 นอกจากนี้ทีมงานได้ดำเนินการแก้ไขปัญหาเรื่องของ RS232-to-USB จากที่บอร์ดใช้ CH340 ไปต่อขาภายนอกโดยใช้ CP2102 แทน และต่อโมดูลแสดงผลด้วย OLED ดังภาพที่ 1

ภาพที่ 1 บอร์ด ESP32-C3 ที่ต่อเติมโมดูล OLED และขาสำหรับเชื่อมต่อภายนอก
Read More

[TH] The MaixPy’s image class Part 1. draw and find something.

บทความนี้กล่าวถึงการใช้คลาส image กับโมดูลแสดงผล TFT-LCD ของบอร์ด Sipeed M1W dock suit ผ่านทางคลาส lcd (MaixPy’s lcd class) ดังภาพที่ 1 ที่มีมากับ MaixPy เพื่อศึกษารายการคำสั่งที่คลาส image เตรียมไว้ให้ และตัวอย่างโปรแกรมการใช้งานคำสั่งเกี่ยวกับการสร้างวัตถุบัฟเฟอร์ การล้างค่าในบัฟเฟอร์ การลบบัฟเฟอร์ การวาดเส้นตรง วงกลม สี่เเหลี่ยม แสดงตัวอักษร การบันทึกข้อมูลจากบัฟเฟอร์ลงการ์ดหน่วยความจำ (microSD Card) การค้นหาเส้นตรงในบัฟเฟอร์ (find_lines) การค้นหาวงกลมในบัฟเฟอร์ (find_circles) และการค้นหาสี่เหลี่ยม (find_rects) ในบัฟเฟอร์ด้วยฟังก์ชันทำงานที่มีมาให้ ซึ่งใช้หลักการของ Hough Transform เพื่อหาตำแหน่งและพารามิเตอร์ของวัตถุที่ค้นหา

ภาพที่ 1 บอร์ด Sipeed M1W dock suit
ภาพที่ 1 บอร์ด Sipeed M1W dock suit
Read More

[TH] Understand and use the ESP32-C3

หลังจากที่พวกเราใช้งาน  esp8266 โดยเฉพาะโมดูล esp-01 และ esp-01s เพื่อเป็นตัวบริหารจัดการเครือข่ายเซ็นเซอร์มาเป็นระยะเวลาพอสมควร และด้วยขีดจำกัดในเรื่องของจำนวนขาใช้งานทำให้ต้องออกแบบระบบให้ทำงานคู่กับ  STM32F103C8T6 หรือ STM32F401CCU6/STM32F411CEU6 เพื่อให้การทำงานมีความสเถียรไม่ประสบปัญหาเกี่ยวกับ WDT ของ esp8266 และด้วยเวลาที่ผ่านไป ทาง espressif ออกไมโครคอนโทรลเลอร์ตามมาอีกหลายตัว เช่น esp32, esp32-s2, esp32-c3 และ esp32-s3

ทางเราได้ทดสอบและใช้งาน esp32 จนแทบจะเป็นตัวหลักในการทำงาน จน esp32-s2 กับบอร์ดของ LILYGO ทำให้เราลองสั่งมาใช้งาน ปัญหาหลักอยู่ที่เครื่องมือในการพัฒนานั้นออกมาล่าช้ามาก แต่อย่างไรก็ดี ณ​ ตอนนี้ทาง espressif ได้ออกชุดพัฒนาสำหรับ Arduino หรือ Arduino Core for ESP32 รุ่น 2.0 พร้อมรองรับการใช้กับ esp32 esp32-s2 และ esp32c3 ทำให้การใช้งานกับ ESP32 และ ESP32-S2 ใช้งานได้ดี และล่าสุดทางทีมงานเราได้บอร์ด esp-c3-32s มาจึงเกิดมาเป็นบทความนี้

สำหรับบทความนี้เป็นการเรียบเรียงจาก datasheet ของ ESP32-C3 WROOM-02 ซึ่งในบทความนี้เราใช้บอร์ดดังภาพที่ 1 ส่วนตัวอย่างโปรแกรมเป็นการขับหลอด LED แบบ RGB บนบอร์ดให้ทำงานโดยใช้ Arduino Core for ESP32 และ ESP-IDF ที่ปรับปรุงมาจากบทความใน Ep.3

ภาพที่ 1 บอร์ดไมโครคอนโทรลเลอร์ ESP32-C3
Read More

[EN] Hi, MaixPy

This article introduces the features of the Sipeed M1w dock suit board, which is a board designed to process AI on edge devices, enabling IoT applications to support artificial intelligence computing by using the KPU K210 chip as the core of computing.

(Figure. 1)
Read More