XAIO ESP32-C3 Expansion Board Getting Started Guide

Seeed Studios XAIO Expansion Board Getting Started Guide
Seeed Studios XAIO Expansion Board Getting Started Guide

I recently covered using the XAIO-ESP32-C3 with the Grove Expansion shield to create a sensor panel to be used within Home Assistant via ESPHome. That shield is only around $7 and doesn’t have very many bells and whistles on it. That is a really fantastic and inexpensive solution to expand your available Grove ports and add more sensors or other Grove accessories to your build.

Today I want to cover Seeed Studio’s larger and more capable expansion shield. Instead of using ESPHome to program the device for us though we’re going to set up the Arduino IDE to work with the XAIO-ESP32-C3. That means we’ll be able to run our own code and test out the various capabilities of the larger expansion board.

Let’s get started!

Hardware Used

Seeed Studios XAIO-ESP32-C3
Seeed Studios XAIO-ESP32-C3

The Seeed Studios XAIO-ESP32-C3 is a microcontroller board that uses the RISC-V architecture. It has Bluetooth and WiFi capabilities and includes an external antenna.

Links: Amazon.com*, AliExpress*, *Amazon.ca*, Amazon.co.uk*, Amazon.com.au*, Amazon.de*, Amazon.es*, Amazon.fr*, Amazon.it*, Amazon.nl*, Amazon.pl*, Amazon.se*, Amazon.sg*

Seeed Studios XAIO Expansion Board
Seeed Studios XAIO Expansion Board

The Seeed Studios XAIO Expansion board has a screen and several expandable connectors. It also features a battery connector.

Links: Amazon.com*, AliExpress*

Getting Arduino IDE

First we need to get the Arduino IDE. On Linux this is usually as simple as typing:

sudo apt install arduino

If you are using a different operating system or your Linux distribution doesn’t have the package available the Arduino official download page is available here with downloads for all platforms.

Download and install the Arduino IDE for your platform.

Adding Board Configuration

Now we need to add the board configuration to the Arduino IDE. To do this go to File -> Preferences. You should see an “Additional Boards Manager URLs” section like this:

Arduino IDE - Boards Manager
Arduino IDE – Boards Manager

Click the icon to the right that I’ve circled in the screenshot above and add the following URL:

https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json

Now press OK.

Next click “Tools” then “Board” followed by “Arduino ESP32”. Now scroll all the way down the list until you find XAIO-ESP32-C3. Once you select that you are all set!

Testing Display

Let’s start with the screen. To use the screen we need to download an additional library from GitHub here. Go to the bottom of the page and download the latest version. It will come as a zip file.

Now within the Arduino IDE choose “Sketch” from the menu and then choose “Include Library” and then “Add .ZIP library”. Select the zip file you downloaded and it should add the library to the sketch.

Now paste the following code into your sketch:

#include <Arduino.h>
#include <U8x8lib.h>
#include <Wire.h>

U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8( U8X8_PIN_NONE); 

void setup(void) {
  u8x8.begin();
  u8x8.setFlipMode(1);   
}

void loop(void) {
  u8x8.setFont(u8x8_font_chroma48medium8_r);
  u8x8.setCursor(0, 0);
  u8x8.print("Happy Birthday!");
}

Now upload your sketch to the device by pressing the upload button and you should see “Happy Birthday!” on the screen!

Note: If you get an error that you are missing the “serial” library my system needed a:

pip3 install pyserial

After that the sketch would compile.

Testing Buzzer

The board includes a buzzer that can play different tones. The Seeed Studios Wiki has a pretty basic example that plays Happy Birthday on this buzzer. It shows nothing on the screen though and leaves it completely blank.

That’s pretty lame so I decided I wanted to combine the two examples and have it play Happy Birthday but also tell me what note it is playing on the screen (or if it is resting).

Here is the code for the sketch:

#include <U8x8lib.h>
#include <U8g2lib.h>
#include <MUIU8g2.h>

#include <Arduino.h>
#include <Wire.h>

U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8( U8X8_PIN_NONE); 

char names[] = {'C', 'D', 'E', 'F', 'G', 'A', 'B',
                'c', 'd', 'e', 'f', 'g', 'a', 'b',
                'x', 'y'
               };

int speakerPin = A3;
int length = 28; 
char notes[] = "GGAGcB GGAGdc GGxecBA yyecdc";
int beats[] = { 2, 2, 8, 8, 8, 16, 1, 2, 2, 8, 8, 8, 16, 1, 2, 2, 8, 8, 8, 8, 16, 1, 2, 2, 8, 8, 8, 16 };
int tempo = 150;
void playTone(int tone, int duration) {
  for (long i = 0; i < duration * 1000L; i += tone * 2) {
    digitalWrite(speakerPin, HIGH);
    delayMicroseconds(tone);
    digitalWrite(speakerPin, LOW);
    delayMicroseconds(tone);
  }
}
 
void playNote(char note, int duration) {

  int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014,
                  956,  834,  765,  593,  468,  346,  224,
                  655 , 715
                };
  int SPEE = 5;
 

 
  for (int i = 0; i < 16; i++) {
    if (names[i] == note) {
      int newduration = duration / SPEE;
      playTone(tones[i], newduration);
    }
  }
}
 
void setup() {
  u8x8.begin();
  u8x8.setFlipMode(1);   
  pinMode(speakerPin, OUTPUT);
}
 
void loop() {
  u8x8.setFont(u8x8_font_chroma48medium8_r);
  u8x8.setCursor(0, 0);
  u8x8.print("Happy Birthday!");
  for (int i = 0; i < length; i++) {
    if (notes[i] == ' ') {
      u8x8.drawString(0, 1, "Resting...      ");
      delay(beats[i] * tempo); 
    } else {
      u8x8.drawString(0, 1, "Playing Note: ");
      u8x8.drawString(14, 10, String(names[i]).c_str());
      playNote(notes[i], beats[i] * tempo);
    }

    delay(tempo);
  }
}

This should give you the following result:

If it won’t load you can view the short here on YouTube.

Conclusion

The XAIO series expansion board will give you a lot more I/O options. You could similarly use this for a sensor station like I did with my Grove expansion board. It would be nice because you could display the sensor information on the display.

As you can see the code is pretty easy to work with. The Arduino IDE makes it much easier to directly experiment with the different components.

Definitely make sure you check out the rest of Seeed Studio’s official examples here on the wiki. There’s a lot of other cool stuff you can do which I’ll definitely be covering on the site as I play around with them more!

Other Resources

You may also be interested in my Grove expansion board article using Home Assistant and ESPHome

Don’t miss my sensor prototyping setup guide using the K1100 sensor prototyping kit

See here for all of my articles regarding RISC-V open hardware

Subscribe
Notify of
guest

12 Comments
Inline Feedbacks
View all comments
Guy Fauquembergue
Guy Fauquembergue
1 year ago

Hi interesting post thanks, I have tried the same thing with the ESP32-C3 xaio and the expansion board. However I cannot get the IRremote working with the relevant grove device. It seems that there is a library issue with the Arduino-IRremote which supports avr boards. If you could help I would apreciate. Regards.

guy fauquembergue
guy fauquembergue
1 year ago

Hello James thanks for your reply it is a bit complex to explain. I have tried the example in Speed tutorials when it compiles you get a message saying that you are using the old version of the Arduino-IRremote so I have switched to the new version 2. There is an example that I have opened with the new library called Simple receiver to check with my Xiao expansion board and the grove IR receiver. However it is strange since in the example they use a IR_RECEIVE_PIN, and in the pin definition file it is stated IR_INPUT_PIN for the ESP32C3. I have used both and always get a compilation error in reference to IRrecv::decodeHashOld(decode_result*) well I am not an expert in Arduino programming. Everything work fine in the Arduino IDE 2 oled screen, buzzer … Not the IRremote. Thanks in advance for your help. Guy

Guy Fauquembergue
Guy Fauquembergue
1 year ago

Thanks I appreciate

Razor Burn
Razor Burn
1 year ago

I’ll admit when I saw you post the video on Youtube I had the sudden urge to check the blog for any new updates, so I was pleasantly surprised to see you had written a Starter Guide show casing some neat features of the XIAO Expansion board with example codes to use with Arduino IDE. I can’t wait to tinker with my unit over the weekend and greatly appreciate the easy-to-follow steps and pictures so thank you.

I much prefer the layout of this board compared to the other Grove Shield as its packed with cool features such as an SD Card slot, Lipo battery connection and the addition of the OLED screen is fabulous and at half the size of the Raspberry Pi 4 its perfect for wearable projects such as a heart rate monitor which I hope to tryout at a later date, with ultimate plans to use it as a mobile monitoring station for the garage/car until I get a more permanent setup installed on ESPHome as per your previous Guide.

I hope to see some interaction from other users who might have tried or own the XIAO range of products as they’ve been around a while and IMHO don’t get the attention they deserve as they’re well priced, fairly easy to setup with great documentation and for the compact size they offer excellent performance and having the additional access to 400+ Grove sensors means you’re covered for most DIY maker projects… Great tutorial James!

Razor Burn
Razor Burn
1 year ago

You make plenty of valid points and I’ve been enjoying these reviews as not many of us have the expendable cash to drop on the latest/greatest SBCs yet for most smaller projects all you need is a microcontroller with many providing added RAM, storage and peripherals such as wireless/bluetooth and intergrade well with most of the standard programming SW be it Arduino IDE or Phython at a fraction of the cost!

As for the Rock 5Bi, I’m not sure if you saw Jeff Geerling’s latest video where I couldn’t help but feel his bias for RPi has tainted what could’ve been a more fairer review of the RK3588 devices and he highlights many of the glaring issues such as lack of kernel support, ease of use (bad boot loaders, broken software), poor documentation and overall cost where I agree 100% that many of the RK3588/s devices are way over priced with the exception of the OPi 5 which he somewhat praised but the Rock 5B is such an improvement over the RPi and comparing it to a mini PC for value left a bitter taste with me as I don’t see that comparison made when the PRi is mentioned as its no longer available for MRP and as you rightly say “obsolete” in 2023. I did see a commenter recommending the Libre board so it looks like you have some supporters but overall I was hoping for a fairer review and I do hope he comes back soon and does an update as many improvements have been made on these Rockchip devices providing a much better user experience!

Razor Burn
Razor Burn
1 year ago

Hi James,

Thank you so much for the detailed reply as I didn’t mean to have a dig at Jeff as he’s a legend in the community and I value his input highly yet I still feel that the review could’ve been better balanced yet you’re link shows that he’s engaged with Radxa to address the real concerns that have been known since Rockchip released the RK3588 and frankly relying on 2.6.x/5.10.x kernel raises some serious red flags but I’m encouraged to see that work is being done behind the scenes to resolve the issues with hopes that we see stability much like other Rockchip SOCs so thank you for keeping the pressure on them to be accountable to the community through your rigorous testing and critical reviews!

I’m a relatively new adopter to Linux/ARM so its been a steep learning curve and I rely heavily on trusted sources for honest reviews and information so naturally it was easy to get excited about RPi as the alternatives were largely obscure yet having done proper research I tend to side with you and strongly believe that what we see with this generation of boards from Radxa and Orange Pi are a step in the right direction and even say the Pi800 is a welcomed alternative (although copied design) to the popular Pi400 so the common rational for staying with the RPi no longer seems convincing to me unless you’re reliant on them for your applications or a diehard fan who already has a RPi but what about newbies who can’t afford one and see a video like Jeff’s thinking that the RK3588 devices aren’t really worth a look at just yet which is hardly the case!?

I agree with your sentiments and appreciate the sacrifice you made as it proves to me your credibility as the previous work you did covering RPi is valuable yet you’re right to ask the difficult questions and I see smidgeons of that with Jeff who does equally wonderful work but I guess the last video rubbed me the wrong way as my experience using the RK3588S was far from perfect but its getting more use than my RPi 4B 8GB for the clear fact that its more powerful and I can see real dedication to the development which wasn’t the case with previous alt boards and I’m optimistic we’ll see even better support with the next generation of SBCs and if it means RPi actually give us a real upgrade that would be welcomed but I’ll hold my joy until then!!!

Keep up the excellent work and I’d love to see more RISC-V content as its unique so until then thanks and take care…

Razor Burn
Razor Burn
1 year ago

Thanks for the clarification and kind works James and if Jeff reads this I hope he understands my criticism is not personal as he’s one of the true good guys and when he posts something it gets everybody’s attention so he has earned my respect just like you have and all I want to add is that I wish him good health and happiness as he never complains and uses his medical condition to fundraise which is a true reflection of his character! Peace!!!