Skip to main content

Getting Started with Microphone

This wiki introduces how to use the built-in microphone for audio input in Wio Terminal. The microphone can be used to detect surrounding sound and respond accordingly.


This wiki only demonstrates the very basic of the microphone, and we are working on a microphone library for Wio Terminal to enable much more functions! Stay tuned!

Example Code

Note: WIO_MIC is defined for the built-in microphone.

void setup() {
pinMode(WIO_MIC, INPUT);

void loop() {
int val = analogRead(WIO_MIC);

Example Code with LCD Screen

Libraries Installation

#include"seeed_line_chart.h" //include the library
#include <math.h>

TFT_eSPI tft;

#define max_size 50 //maximum size of data
doubles data; //Initilising a doubles type to store data
TFT_eSprite spr = TFT_eSprite(&tft); // Sprite

void setup() {
pinMode(WIO_MIC, INPUT);


void loop() {

int val = analogRead(WIO_MIC);

if (data.size() == max_size) {
data.pop();//this is used to remove the first read variable
data.push(val); //read variables and store in data

//Settings for the line graph title
auto header = text(0, 0)
.value("Microphone Reading")

header.height(header.font_height() * 2);
header.draw(); //Header height is the twice the height of the font

//Settings for the line graph
auto content = line_chart(20, header.height()); //(x,y) where the line graph begins
.height(tft.height() - header.height() * 1.5) //actual height of the line chart
.width(tft.width() - content.x() * 2) //actual width of the line chart
.based_on(0.0) //Starting point of y-axis, must be a float
.show_circle(true) //drawing a cirle at each point, default is on.
.value(data) //passing through the data to line graph
.color(TFT_RED) //Setting the color for the line

spr.pushSprite(0, 0);
Loading Comments...