Trying Out XIAO ESP32C3 Part 3 (OLED Display and Continuous Rotation Servo)

Info

This article is translated from Japanese to English.

https://404background.com/program/esp32c3-3/

Introduction

In this post, I experimented with controlling an OLED display and a continuous rotation servo using the XIAO ESP32C3. When using a tiny microcontroller, it’s only natural to want to pair it with a tiny display.

The OLED display uses I2C communication, which requires only two signal lines, and the continuous rotation servo requires only one. This setup should significantly contribute to miniaturization. After all, controlling a DC motor with a motor driver typically requires at least two lines...

▼The product page for the XIAO ESP32C3 is here:

https://akizukidenshi.com/catalog/g/g117454

ノーブランド品
¥1,275 (2026/02/21 19:12時点 | Amazon調べ)

▼Previous article:

Trying Out XIAO ESP32C3 Part 2 (analogWrite Function and Servo Motors)

Info This article is translated from Japanese to English. Introduction In this post, I experimented with the analogWrite function and servo motor control using…

OLED Display

▼Product page:

https://akizukidenshi.com/catalog/g/gP-12031/

For this setup, I am using the Adafruit library. I plan to use it later to display sensor values, so for now, I just tested the sample programs.

▼Library:

https://github.com/adafruit/Adafruit_SSD1306

▼Adafruit OLED product page (you can see the program in action):

LCDs & Displays, OLED Products Category on Adafruit Industries

Trying the Sample Program

Among the samples for I2C communication, there were ssd1306_128x32_i2c and ssd1306_128x64_i2c. However, since the 128x64 version didn't work initially, I used the 128x32 version this time.

▼Wiring setup. I purchased additional small breadboards.

▼Operation with ssd1306_128x32_i2c:

▼Operation when SCREEN_HEIGHT is changed from 32 to 64 in ssd1306_128x32_i2c:

You can see that if the scale is incorrect, it doesn't display properly. It seems that up to 4 lines for 128x32 and up to 8 lines for 128x64 would be readable for displaying text.
I have used 2-line LCD displays before, but since this OLED works with I2C and offers more flexibility, it might be easier to use.

Continuous Rotation Servo

Reading the Datasheet

In the previous article, I controlled a servo motor that rotates to a specific angle, but this time I’m using a continuous rotation servo. It can be used just like a DC motor.

I previously tested it with a dedicated servo testing board, and it worked fine with Servo.h. Assuming the control method is essentially the same, I checked the datasheet.

▼It also worked with the XIAO nRF52840 board I made previously:

Using nRF52840 Part 1 (Seeed Studio XIAO nRF52840 Sense)

Info This article is translated from Japanese to English. Introduction This time, I tried using the Seeed Studio XIAO nRF52840, a compact microcontroller equip…

▼This time, I used the SG90-HV and FS90R.

360°連続回転サーボ(ローテーションサーボ) SG90-HV: パーツ一般 秋月電子通商-電子部品・ネット通販 (akizukidenshi.com)

360°連続回転サーボ(ローテーションサーボ) FS90R: パーツ一般 秋月電子通商-電子部品・ネット通販 (akizukidenshi.com)

▼I tested it with tires compatible with the FS90R:

https://akizukidenshi.com/catalog/g/gP-13207/

▼Some versions are also sold with wheels on Amazon.

▼While researching, I found a comparison table for Feetech servos on the Switch Science page:

https://pages.switch-science.com/comparison/feetech-servos

The FS90R datasheet states:

  • CW(when 1500~700 µsec)
  • CCW(when 1500~2300 µsec)

It seems that the pulse width controls the forward and reverse rotation. Let’s try running the program.

Executing the Program

I modified the pulse width values from the 180-degree servo program. The pulse width is set to increase from 700 to 2300 and then decrease.

▼SG90-HV operation:

▼FS90R operation:

Both operated similarly. The rotation stops when the pulse width is around 1500, and the speed increases as the pulse width moves further away from 1500.

Finally

I’ve been verifying the operation of various electronic components using the XIAO ESP32C3, and I think it’s about time to integrate them. I’ve already built a small two-wheeled robot, so I plan to summarize that in a future article.

I found out later that the 128x64 OLED display has patterns on the back for changing the I2C address. This means I should be able to use multiple displays selectively.
▼Since it involves chip resistors, it might be a bit tricky?

Leave a Reply

Your email address will not be published. Required fields are marked *