[EN] u8g2 Library

From the article on using the ESP8266 with an OLED graphical display written in Python, you’ll find that it’s fast and easy but when used with other microcontrollers that cannot use Micropython or CircuitPython, what must be done? One of the many options is the u8glib or u8g2 (Universal 8 bit Graphics Library) libraries, designed to work with monochromatic 8-bit graphics over either I2C or SPI communication. In this article, we are using I2C OLED as shown in Figure 1.

(Figure. 1 STM32F401CCU6 with I2C OLED)
Read More

[TH] How to render the Thai string correctly?

จากบทความการใช้งาน u8g2 ที่สามารถเรนเดอร์ (Render) ภาษาไทย (Thai string) ได้ผ่านทางฟังก์ชัน drawUTF8() ของไลบรารี u8g2 แต่การแสดงผลไม่ถูกต้อง ดังภาพที่ 1 ด้วยเหตุนี้จึงต้องปรับปรุงโค้ดของไลบรารีเพิ่มเติมเพื่อให้การแสดงผลถูกต้องดังภาพที่ 2

ภาพที่ 1 การแสดงผลของ drawUTF8() ก่อนปรับปรุง
ภาพที่ 2 การแสดงผลของ drawUTF8() หลังปรับปรุง
Read More

[EN] SPI Bus

This article discusses the SPI bus functionality of the Arduino framework for use with the STM32F030F4P6, STM32F103C8, STM32F401, esp8266 and esp32. The operation of this bus requires at least 3 intercommunication cables: SCLK, MISO. and MOSI for transmitting the clock signal between the sender and the receiver. It serves to receive information from the sender. and used for sending information to the recipient.

From the use of 3 signal lines, it is found that data can be transmitted and received simultaneously. This is different from I2C bus communication that uses only one SDA cable to communicate. At the same communication speed, the SPI bus will receive and transmit data without waiting for an idle line, while I2C will have to wait for idle. With this in mind, SPI can send/receive data faster.

In addition, SPI uses a method to select the destination to communicate by instructing the endpoint to know by sending a signal to the SS pin of the terminal. Therefore, when connecting to multiple devices, SPI requires a larger number of pins to operate, while I2C uses device identification to communicate with each other by still using only one SDA cable, which saves more pins.

Read More

[EN] I2C Bus/Wire.h

This article describes the methods of Wire.h, a class for communicating with devices over an I2C bus that uses two signal wires called SDA and SCL to transmit data between them. We have quite a number of articles about this type of communication and used as the main bus to develop devices by yourself and run through the bus, for example, articles on using esp8266 to connect to Arduino Uno or using esp8266 with stm32f030f4p6, etc.

Read More

[EN] Arduino : DHT Sensor

This article describes how Adafruit’s DHT Sensor library is compatible with all Arduino-compatible architectures, making it easier to deploy DHT sensors for humidity and temperature readings across multiple platforms. This article has tested with ESP32, ESP8266, Arduino UNO and stm32f103c and found that it can be used without modifying the code in the working part or having to modify the source code to make it compatible with the platform.

(Figure. 1 dht22 and BluePill)
Read More

[EN] Bare Metal Cortex-M Ep.1

This article is a series of programming articles focused on the Cortex-M0 via the STM32F030F4P6 or any other STM32 microcontroller based on CMSIS, an ARM firmware compiled from vivonomicon.com‘s series of Bare Metal: STM32 Programming articles without using the Arduino framework. In the article EP.1 is a matter of preparation. It consists of creating a link file to link different parts of the code together and the working part file. After that, the result file is uploaded into the microcontroller to complete the program development process.

(Figure. 1 STM32F030F4P6)
Read More

[TH] ST7735s

บทความนี้กล่าวถึงการตั้งค่าไลบรารี TFT_eSPI ของ Arduino เพื่อใช้งาน TFT LCD ที่ควบคุมด้วยชิพ ST7735s ที่ได้เคยเขียนเป็นตัวอย่างในบทความก่อนหน้านี้ด้วยภาษาไพธอน แต่จากการใช้งานของทีมงานเราพบว่า ST7735s ที่เป็น LCD IPS ขนาด 0.96″ นั้นมี 2 รุ่น ซึ่งเป็น GREENTAB160x80 กับ REDTAB160x80 โดยโมดูลทั้ง 2 ประเภทแตกต่างกันที่การเว้นวรรคช่องว่างระหว่างกันดังภาพที่ 1 ซึ่งในบทความนี้ใช้ ESP8266, ESP32 รุ่น DO-IT DevKit กับ ESP32CAM และ STM32F103C8T6 เป็นบอร์ดทดสอบการทำงานของโปรแกรม

ภาพที่ 1 โมดูลแสดงผล TFT ขนาด 0.96″ แบบ IPS
Read More

[TH] Bare Metal Cortex-M Ep.4

บทความนี้กล่าวถึงการใช้งานพอร์ตสื่อสารอนุกรม UART ซึ่งนิยมใช้มานาน และสะดวกต่อการใช้งาน โดยใช้ขา PA9 และ PA10 ต่อเข้าเป็นขา Tx และ Rx ของไมโครคอนโทรลเลอร์ทั้ง cortex-M0/M3/M4 เชื่อมต่อกับขา Rx/Tx ของตัวแปลงระดับแรงดันสัญญาณสำหรับสื่อสารผ่านทางพอร์ต USB ซึ่งตัวอย่างโปรแกรมเป็นการประมวลผลในไมโครคอนโทรลเลอร์และนำออกผลลัพธ์ผ่านทางพอร์ตสื่อสารอนุกรมที่ใช้งานโปรแกรม moserial เป็นซอฟต์แวร์สื่อสารข้อมูลดังภาพที่ 1

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

[TH] u8g2 Library

จากบทความการใช้ ESP8266 กับจอแสดงผลกราฟิกแบบ OLED ซึ่งเขียนด้วยภาษาไพธอนจะพบว่าการทำงานนั้นสะดวกรวดเร็วในระดับดี แต่เมื่อต้องใช้กับไมโครคอนโทรลเลอร์ตัวอื่นที่ไม่สามารถใช้ Micropython หรือ CircuitPython ได้นั้นจะต้องทำอย่างไร ซึ่งหนึ่งในหลายทางเลือกคือไลบรารี u8glib หรือ u8g2 (Universal 8 bit Graphics Library) ที่ออกแบบมาเพื่อทำงานกับกราฟิกแบบ 8 บิตแบบโมโนโครมทั้งผ่านการสื่อสารแบบ I2C หรือ SPI โดยบทความนี้ใช้อุปกรณ์ต่อเชื่อมกันดังภาพที่ 1 ด้วยการใช้ OLED แบบ I2C

ภาพที่ 1 การเชื่อมต่อ STM32F401CCU6 กับ OLED แบบ I2C
Read More