[EN] Tic-Tac-Toe

This article is a collection of examples of Tic-Tac-Toe games that our team uses to teach game development in different languages ​​as appropriate for the group of learners. But most of them use Python for teaching because it is easier to explain and write than other languages. In addition to wanting to see how it can be implemented on other platforms, we used an example with the MicroPython of a board we named ml4m. Based on this board, TensorFlow Lite is installed on an ESP32 with a 4MB ROM. The board looks like Figure 1.

(Figure. 1 ml4m for testing Tic-Tac-Toe)
Read More

[EN] Display time from NTP and TimeLib with esp8266

This article is an example of using the Arduino framework’s NTP and TimeLib libraries with either the ESP-01s (Figure 1) or esp8266 to report the current time via the web served by the esp8266, which in this example is called NTPClient and TimeLib libraries. An Internet connection is required to read the date and time from an NTP provider such as time.nist.gov.

(Figure. 1 ESP-01s on dCore-0 v.0.7)
Read More

[EN] Temperature and humidity indicator bar

This article is an example program for cases where you want to display the temperature and humidity bar as shown in Figure 1 with MicroPython and esp32 board with OLED. How to write? The equipment in this experiment used DHT22 as a humidity and temperature measurement device. The board is connected to the I2C bus to communicate with the OLED via pins GPIO4 and GPIO5 for SCL and SDA respectively. At the same time, the signal pin of DHT22 is connected to pin GPIO15 for communication between the sensor and the microcontroller.

(Figure. 1 Example output of temperature and humidity bar display)
Read More

[TH] Arduino: ESP32 PWM.

บทความนี้กล่าวถึงการใช้ PWM (Pulse Width Modulate) ของไมโครคอนโทรลเลอร์ ESP32 ในเฟรมเวิร์ก Arduino หลังจากที่ได้กล่าวถึงการทำงานของส่วนนี้ใน ESP-IDF และ MicroPython ไปแล้ว โดยบทความกล่าวถึงฟังก์ชัน การใช้งาน และตัวอย่างโปรแกรม ด้วยการเชื่อมต่อบอร์ดกับลำโพงดังภาพที่ 1

ภาพที่ 1 บอร์ด esp32G2 ที่ติดตั้งลำโพงแบบบัซเซอร์ไว้ที่ GPIO19
Read More

[EN] DHT11 Web Report

This article is an application of Python programming for Micropython used with esp8266 or esp32 attached to DHT11 for temperature and humidity storage. The last 10 temperature results collected every 5 seconds are reported as shown in Figure 1.

(Figure. 1 Result from report)
Read More

[TH] How to build MicroPython for SAM-D21.

หลังจากที่ได้แนะนำบอร์ดไมโครคอนโทรลเลอร์ SAM-D21 ดังภาพที่ 1 และการใช้ ADC/DAC ของชิพตัวนี้ที่เป็นไมโครคอนโทรลเลอร์สถาปัตยกรรม ARM 32 บิต แบบ Cortex-M0+ ในครั้งนี้เรามาลองคอมไพล์และใช้ภาษาไพธอนสำหรับบอร์ดตัวนี้กัน

ภาพที่ 1 บอร์ด SAM-D21
Read More

[EN] Queue Data Structure

This article introduces the use of the list class in Micropython as a queue data structure with a limited number of members. It works according to the FIFO (First-In-First-Out) principle, which can be applied in a variety of applications, such as being used as a storage, and when the data is full but we need to insert new data, the old data must be pop out. The example in this article uses the dCore-miniML board (Figure 1) to read the temperature of the chip and store it in a Queue structure and display it in a bar graph and Micropython implemented firmware version 1.16 (2021-06-23) for the ESP Module (SPIRAM).

(Figure. 1 An example of drawing a graph with data stored in a queued data structure)
Read More

[TH] Arduino: ESP32-S2’s DAC&ADC.

หลังจากที่ทดสอบ DAC และ ADC ของทั้ง ESP32, SAM-D21, LGT8F328P และ STM32L432KC เป็นที่เรียบร้อย ครั้งนี้ก็เป็นคราวของ ESP32-S2 ที่ทางเรามีใช้งานอยู่ โดยการทดสอบการทำงานยังคงเป็นเหมือนก่อนหน้านี้ที่ใช้ DAC ส่งคลื่น 3 ลักษณะคือ ฟันปลา สามเหลี่ยม และคลื่นรูปไซน์ออกมา และเขื่อมต่อเข้ากับขาของ ADC เพื่อนอ่านค่า พร้อมทั้งทดสอบดูกราฟว่ามีลักษณะออกมาเป็นอย่างไร

ในการทดลองนี้ได้เชื่อมต่อ DAC1 เข้ากับ ADC ดังภาพที่ 1 โดย ESP32-S2 มี DAC ขนาด 8 บิตจำนวน 2 พอร์ตเรียกว่า DAC1 และ DAC2 ส่วน ADC มีความละเอียด 12 บิต ซึ่งจะเห็นว่ามีคุณสมบัติเหมือนกับ ESP32 แต่จะได้ผลลัพธ์เหมือนกันหรือไม่นั้นคงบอกได้ว่าน่าจะแตกต่างเนื่องจากใช้ไมโครคอนโทรลเลอร์คนละรุ่นกัน โดยใน ESP32-S2 ใช้ตัวเดียวกับ ESP32-S3 ที่มีเพียงแกนเดียว และไม่มี BLE

ภาพที่ 1 บอร์ด Neucleo L432KC เชื่อมต่อขา A3 เข้ากับ D3
Read More

[TH] Try the SoftHost USB library for ESP32.

บทความนี้เป็นตัวอย่างการนำ ESP32 Soft Host ของ nathalis มาทดลองใช้งานและทดลองแสดงผลที่จอแสดงผล OLED ที่มีความละเอียด 128×64 จุด ดังภาพที่ 1 เพื่อรับข้อมูลจากแป้นพิมพ์ หรือเมาส์ ทำให้ใช้ GPIO เพียงไม่กี่ขาแต่สามารถรับข้อมูลจากแป้นพิมพ์ที่มีจำนวนปุ่มที่เยอะได้ ซึ่งโดยปกติแล้วตัวไมโครคอนโทรลเลอร์ ESP32 ไม่รองรับการทำเชื่อมต่อกับ USB โดยตรงจึงต้องอาศัยการเขียนโปรแกรมด้วยการใช้ตัวตั้งเวลาหรือ Timer มาตรวจสอบสถานะของสายสัญญาณขา D- และ D+ เพื่อนำมาประกอบกันเป็นข้อมูลในระดับไบต์และนำมาประกอบกันเป็นแพ็คของข้อมูลเพื่อทำการตีความต่อไป

ภาพที่ 1 อุปกรณ์และบอร์ดที่เชื่อมต่อกันเพื่อเป็นตัวอย่างในบทความนี้
Read More