ESP32 UNO - Multi-Function Shield

Want one board that gives your ESP32 Uno a display, keys, LEDs, a buzzer and two sensors at once? Press the multi-function shield onto the ESP32 Uno form board, add a short GPIO map to your sketch, and every part works from Arduino code. You get a 74HC595 4-digit 7-segment display, three push buttons, four LEDs, a beeper, a trimmer knob and an LM35 temperature sensor, with no breadboard and no loose wires.

By the end, you can:

  1. Plug the shield in and pass the correct GPIO numbers to the DIYables_MultiFuncShield library
  2. Print numbers, decimals and short words on the 4-digit 7-segment display
  3. Catch key presses and drive the LEDs and buzzer without delay()
  4. Read the trimmer value and the room temperature on the ESP32 Uno
ESP32 Uno multi-function shield

The video walks through every example on this page, one after another.

Components You Need

1×ESP32 Uno-form Board
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×DIYables Multi-Function Shield
3×15 kΩ Resistor (optional divider, holds the 5V key pull-ups near 3.0V)

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

What Is on the Multi-Function Shield

After this part, you know each part on the shield, the Uno header it uses, and its GPIO on the ESP32 Uno.

Part Details Logic
4-digit 7-segment display Fed by a 74HC595 shift register, so only 3 pins drive it. Shows numbers, decimals, letters A to Z and symbols like ° Output only
Keys S1, S2, S3 Pull-up resistor on the shield for each key. The library filters bounce Active LOW (pressed = LOW)
LEDs D1 to D4 On, off, toggle, blink, or all four together Active LOW (LOW = lit)
Buzzer Single beep, or a beep after a pause, without blocking Active LOW
Trimmer potentiometer Multi-turn type. Library returns a raw value or 0 to 100% Analog, 0 to 4095 on the ESP32 Uno
LM35 temperature sensor 10 mV per °C. Works only after jumper J1 comes off Analog

The shield keeps the classic Uno positions. Here is where each part lands and the GPIO number your ESP32 Uno code must use:

Shield Part Uno Header ESP32 Uno GPIO
LED D1 D13 GPIO18
LED D2 D12 GPIO19
LED D3 D11 GPIO23
LED D4 D10 GPIO5
Key S1 A1 GPIO4
Key S2 A2 GPIO35
Key S3 A3 GPIO34
Buzzer D3 GPIO25
Display LATCH D4 GPIO17
Display CLOCK D7 GPIO14
Display DATA D8 GPIO12
Trimmer A0 GPIO2
LM35 sensor A4 GPIO36
Multi-Function Shield Pinout

Good to know: A4 on the ESP32 Uno is GPIO36, a plain analog input. The I2C lines are on the separate SDA (GPIO21) and SCL (GPIO22) header pins, so the LM35 never fights with an I2C module on this board.

ESP32 Uno Pinout

Your sketch talks to GPIO numbers, not to the D and A labels printed on the headers. Keep this map open while you set up the pin list for the shield.

ESP32 Uno pinout diagram

How to Connect

By the end of this part, the shield sits on the board and you know the three safety steps for 3.3V pins.

Line up the shield pins with the ESP32 Uno headers and press it down evenly. No jumper wires are needed.

The wiring diagram between ESP32 Uno Multi-Function Shield

This image is created using Fritzing. Click to enlarge image

※ NOTE THAT:

The picture shows only how the shield plugs into the ESP32 Uno. The three 15 kΩ resistors from the warning below sit under the shield, so you cannot see them in the picture. Turn the trimmer to 0 before you stack the shield.

Shield Part ESP32 Uno Pin
5V 5V
GND GND
LED D1 D13 (GPIO18)
LED D2 D12 (GPIO19)
LED D3 D11 (GPIO23)
LED D4 D10 (GPIO5)
Key S1 A1 (GPIO4)
Key S2 A2 (GPIO35)
Key S3 A3 (GPIO34)
Buzzer D3 (GPIO25)
Display LATCH D4 (GPIO17)
Display CLOCK D7 (GPIO14)
Display DATA D8 (GPIO12)
Trimmer A0 (GPIO2)
LM35 sensor A4 (GPIO36)

WARNING

ESP32 Uno pins are 3.3V only. The shield, however, runs on 5V, and two parts push voltage back into the board. (1) The trimmer is wired between 5V and GND, so its wiper on A0 (GPIO2) can reach 5V. Before you stack the shield, spin the trimmer screw about 20 turns counter-clockwise to park it at the 0V end, and later stop turning as soon as the Serial Monitor shows 100%. (2) The keys on A1, A2 and A3 have pull-ups to 5V (usually 10 kΩ). For long-term use, solder a 15 kΩ resistor from each of these three pins to GND under the shield. That divider holds an idle key line near 3.0V, which still reads HIGH.

WARNING

Boot strapping pins are under three shield parts. D8 (GPIO12) carries the display DATA line and must be LOW at boot. The 74HC595 input does not pull it, so this is normally fine. D10 (GPIO5) carries LED D4, and its LED pulls the line high, which is the state GPIO5 wants at boot. A0 (GPIO2) carries the trimmer. If the trimmer sits at the high end when you upload, the board can refuse to enter download mode. Keep the trimmer near 0% while you upload code.

WARNING

Pull jumper J1 off the shield before you use the LM35. On most shield versions, J1 connects a pull-up resistor (meant for a DS18B20) to the A4 line. With J1 on, A4 (GPIO36) is pulled toward 5V and the temperature is wrong.

Good to know: A2, A3 and A4 (GPIO35, GPIO34, GPIO36) are input only and have no internal pull-up. That is fine here: the keys use the pull-ups on the shield, and the LM35 drives its own output.

Install the DIYables_MultiFuncShield Library

After this part, the library that handles the display refresh, key debounce, LED blinking and buzzer timing is ready in your IDE.

  1. Connect the board to your computer with the USB Type-C cable.
  2. Choose the board in Arduino IDE: pick ESP32 Dev Module (esp32 by Espressif Systems core) and the CH340 COM port.
  3. Open the Library Manager with the Libraries icon on the left side.
  4. Search for "DIYables_MultiFuncShield" and find the entry from DIYables.
  5. Click Install.
  • Search for DIYables_MultiFuncShield created by DIYables.io and click the Install button.
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32 Dev Module
Library Manager
Type:
All
Topic:
All
DIYables_MultiFuncShield by DIYables.io
Self-contained library for Multi-Function Shield components including 4-digit 7-segment display, buttons, LEDs, buzzer, potentiometer, and temperature sensor. No external dependencies. Uses Arduino standard APIs for compatibility across all platforms. More info
1.0.0
INSTALL
Newbiely.ino
···
1 void setup() {
Output
Serial Monitor
Ln 1, Col 1
ESP32 Dev Module on COM15
1

The library needs nothing else. It also detects the ESP32 Uno by itself and uses a 12-bit ADC with a 3.3V reference.

The Starting Frame for Every Sketch

By the end of this part, you know the one change every ESP32 Uno sketch for this shield needs: a GPIO pin list.

The library ships with Uno pin numbers (13, 12, 11, 10 and so on). On the ESP32 Uno those numbers mean other GPIOs, and GPIO10 and GPIO11 are even wired to the flash chip. So you fill an MFS_Pins list with the real GPIOs and build your own shield object from it.

#include <DIYables_MultiFuncShield.h> // Uno header position -> ESP32 Uno GPIO MFS_Pins esp32UnoPins() { MFS_Pins p; p.led1 = 18; // D13 (GPIO18) p.led2 = 19; // D12 (GPIO19) p.led3 = 23; // D11 (GPIO23) p.led4 = 5; // D10 (GPIO5) p.button1 = 4; // A1 (GPIO4) p.button2 = 35; // A2 (GPIO35) p.button3 = 34; // A3 (GPIO34) p.buzzer = 25; // D3 (GPIO25) p.dispLatch = 17; // D4 (GPIO17) p.dispClock = 14; // D7 (GPIO14) p.dispData = 12; // D8 (GPIO12) p.pot = 2; // A0 (GPIO2) p.lm35 = 36; // A4 (GPIO36) return p; } DIYables_MultiFuncShield shield(esp32UnoPins()); void setup() { shield.begin(); // prepares display, keys, LEDs and buzzer } void loop() { shield.loop(); // keeps the display, keys, LEDs and buzzer running }
Code Part What It Does
MFS_Pins esp32UnoPins() Returns the 13 GPIO numbers of the shield parts on the ESP32 Uno
DIYables_MultiFuncShield shield(...) Builds a shield object that uses those GPIOs
shield.begin() Sets the pin modes and clears the display
shield.loop() Multiplexes the digits, debounces the keys, times LED blinks and beeps

Call shield.loop() on every pass of loop() and keep long delay() calls out of it, or the display starts to flicker.

WARNING

The library already defines a global object named MFS that holds the Uno pin numbers. Never name your own object MFS (the build fails with "multiple definition of MFS"), and never call MFS.begin() on the ESP32 Uno. It would set GPIO10 and GPIO11 as outputs, and those pins belong to the flash chip, so the board crashes and restarts.

7-Segment Display Example

After this part, the display shows a new format every 3 seconds.

/* * This ESP32 Uno code was developed by newbiely.com * * This ESP32 Uno code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-uno/esp32-uno-multi-function-shield */ /* * Multi-Function Shield - Display Example (ESP32 Uno) * * Shows a new display view every 3 seconds: * 1. whole number * 2. whole number padded with zeros * 3. decimal number * 4. letters * 5. letters with a dot * 6. degree sign and C (special symbols) * 7. a row of dashes * * Shield: DIYables Multi-Function Shield, stacked on the ESP32 Uno form board * * Shield product page: * - https://diyables.io/products/multi-function-shield-for-arduino-uno-mega * * Board product page: * - https://diyables.io/products/esp32-wroom-32-development-board-compatible-with-uno-form-factor-shields-wifi-bluetooth-ch340-usb-type-c-4mb-flash * * Keep in mind: the ESP32 Uno I/O pins work at 3.3V and do NOT accept 5V. */ #include <DIYables_MultiFuncShield.h> // The library default pins are Uno numbers (13, 12, 11, 10 ...). On the // ESP32 Uno these numbers point to other GPIOs (GPIO10/11 even belong to the // flash chip), so this function hands the library the real GPIO numbers. MFS_Pins esp32UnoPins() { MFS_Pins p; p.led1 = 18; // LED D1 on D13 (GPIO18) p.led2 = 19; // LED D2 on D12 (GPIO19) p.led3 = 23; // LED D3 on D11 (GPIO23) p.led4 = 5; // LED D4 on D10 (GPIO5) - boot strapping pin p.button1 = 4; // key S1 on A1 (GPIO4) p.button2 = 35; // key S2 on A2 (GPIO35) - input only, shield pull-up does the job p.button3 = 34; // key S3 on A3 (GPIO34) - input only, shield pull-up does the job p.buzzer = 25; // buzzer on D3 (GPIO25) p.dispLatch = 17; // 74HC595 latch on D4 (GPIO17) p.dispClock = 14; // 74HC595 clock on D7 (GPIO14) p.dispData = 12; // 74HC595 data on D8 (GPIO12) - boot strapping pin p.pot = 2; // trimmer wiper on A0 (GPIO2) - ADC2, no reads while WiFi is on p.lm35 = 36; // LM35 output on A4 (GPIO36) - ADC1, input only return p; } // Do not start the built-in MFS object - it carries the Uno pin numbers. // This object works with the ESP32 Uno GPIO list above. DIYables_MultiFuncShield shield(esp32UnoPins()); uint8_t step = 0; unsigned long lastUpdate = 0; void setup() { shield.begin(); } void loop() { shield.loop(); if (millis() - lastUpdate >= 3000) { lastUpdate = millis(); switch (step) { case 0: // plain number, right aligned: " 42" shield.display.print(42); break; case 1: // same number with zeros in front: "0042" shield.display.print(42, true); break; case 2: // decimal value, two digits after the dot: "3.14" shield.display.print(3.14, 2); break; case 3: // four letters: "HELP" shield.display.print("HELP"); break; case 4: // letters with a dot in the middle: "Ab.Cd" shield.display.print("Ab.Cd"); break; case 5: // build "25°C" digit by digit, then push it out shield.display.clear(); shield.display.setNumber(1, 2); shield.display.setNumber(2, 5); shield.display.setChar(3, SegChars::DEGREE); shield.display.setChar(4, SegChars::C); shield.display.show(); break; case 6: // four dashes: "----" shield.display.print("----"); break; } step = (step + 1) % 7; } }

Upload and Test

  1. First time with this board? Set it up with ESP32 Uno - Getting Started before you continue.
  2. Build the circuit: park the trimmer at 0V, remove J1 if you plan to use the LM35, then press the shield onto the ESP32 Uno.
  3. Plug in the USB Type-C cable between the ESP32 Uno and your computer.
  4. Select the board in Arduino IDE: pick ESP32 Dev Module and the COM port of the board (CH340).
  5. Paste the sketch above into a new Arduino IDE window.
  6. Click Upload and wait for "Done uploading".
  7. Pro tip: if the upload stops at "Connecting...", hold the BOOT button until the dots stop, and check that the trimmer is still near 0%.

The display cycles through seven views, one every 3 seconds:

Step Display Shows Call Used
1 42 print(42)
2 0042 print(42, true)
3 3.14 print(3.14, 2)
4 HELP print("HELP")
5 Ab.Cd print("Ab.Cd")
6 25°C setNumber + setChar + show
7 ---- print("----")

Display Methods

Method Result Example Call
print(int) A whole number shield.display.print(42)
print(int, true) A whole number with zeros in front shield.display.print(42, true) → 0042
print(float, dp) A decimal number with dp digits after the dot shield.display.print(3.14, 2)
print(text) A short word (A-Z, 0-9, -, _) shield.display.print("HELP")
setNumber(pos, val) One digit at position 1 to 4 shield.display.setNumber(1, 5)
setChar(pos, ch) One letter at a position shield.display.setChar(2, 'A')
setChar(pos, SegChars) One special symbol at a position shield.display.setChar(3, SegCharsDEGREE)
setDot(pos) The dot at a position shield.display.setDot(2)
clear() Turns off every segment shield.display.clear()
show() Sends hand-built content to the display shield.display.show()

Each print() call runs show() by itself. For a hand-built screen, start with clear(), place the digits with setNumber(), setChar() or setDot(), and finish with show().

Good to know: SegChars holds six symbols: DASH, UNDERSCORE, C, E, F and DEGREE.

Button Example

After this part, every key press and key release prints one line on the Serial Monitor.

/* * This ESP32 Uno code was developed by newbiely.com * * This ESP32 Uno code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-uno/esp32-uno-multi-function-shield */ /* * Multi-Function Shield - Buttons Example (ESP32 Uno) * * Prints a line on the Serial Monitor each time a key goes down or up. * * Shield: DIYables Multi-Function Shield, stacked on the ESP32 Uno form board * * Shield product page: * - https://diyables.io/products/multi-function-shield-for-arduino-uno-mega * * Board product page: * - https://diyables.io/products/esp32-wroom-32-development-board-compatible-with-uno-form-factor-shields-wifi-bluetooth-ch340-usb-type-c-4mb-flash * * Keep in mind: the ESP32 Uno I/O pins work at 3.3V and do NOT accept 5V. */ #include <DIYables_MultiFuncShield.h> // The library default pins are Uno numbers (13, 12, 11, 10 ...). On the // ESP32 Uno these numbers point to other GPIOs (GPIO10/11 even belong to the // flash chip), so this function hands the library the real GPIO numbers. MFS_Pins esp32UnoPins() { MFS_Pins p; p.led1 = 18; // LED D1 on D13 (GPIO18) p.led2 = 19; // LED D2 on D12 (GPIO19) p.led3 = 23; // LED D3 on D11 (GPIO23) p.led4 = 5; // LED D4 on D10 (GPIO5) - boot strapping pin p.button1 = 4; // key S1 on A1 (GPIO4) p.button2 = 35; // key S2 on A2 (GPIO35) - input only, shield pull-up does the job p.button3 = 34; // key S3 on A3 (GPIO34) - input only, shield pull-up does the job p.buzzer = 25; // buzzer on D3 (GPIO25) p.dispLatch = 17; // 74HC595 latch on D4 (GPIO17) p.dispClock = 14; // 74HC595 clock on D7 (GPIO14) p.dispData = 12; // 74HC595 data on D8 (GPIO12) - boot strapping pin p.pot = 2; // trimmer wiper on A0 (GPIO2) - ADC2, no reads while WiFi is on p.lm35 = 36; // LM35 output on A4 (GPIO36) - ADC1, input only return p; } // Do not start the built-in MFS object - it carries the Uno pin numbers. // This object works with the ESP32 Uno GPIO list above. DIYables_MultiFuncShield shield(esp32UnoPins()); void setup() { Serial.begin(9600); shield.begin(); } void loop() { shield.loop(); if (shield.button1.isPressed()) Serial.println("Button 1 pressed"); if (shield.button1.isReleased()) Serial.println("Button 1 released"); if (shield.button2.isPressed()) Serial.println("Button 2 pressed"); if (shield.button2.isReleased()) Serial.println("Button 2 released"); if (shield.button3.isPressed()) Serial.println("Button 3 pressed"); if (shield.button3.isReleased()) Serial.println("Button 3 released"); }

Upload and Test

  1. Upload the sketch from Arduino IDE.
  2. Open the Serial Monitor and set the speed to 9600 baud.
  3. Press the keys in any order. Hold one key, then press another, to see that each key is tracked on its own.
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32 Dev Module' on 'COM15')
New Line
9600 baud
Button 2 pressed Button 2 released Button 1 pressed Button 3 pressed Button 3 released Button 1 released
Ln 11, Col 1
ESP32 Dev Module on COM15
2

Button Methods

Method Result
isPressed() true once, at the moment the key goes down
isReleased() true once, at the moment the key comes back up
setDebounceTime(ms) Changes the debounce window (default 50 ms)

Pick a key by name (shield.button1 to shield.button3) or by number (shield.button(1) to shield.button(3)). The library sets INPUT_PULLUP, but GPIO35 and GPIO34 ignore it because they have no internal pull-up. The shield's own pull-ups keep those two keys working.

LED Example

After this part, the four LEDs light up in turn, go dark, and then blink together.

/* * This ESP32 Uno code was developed by newbiely.com * * This ESP32 Uno code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-uno/esp32-uno-multi-function-shield */ /* * Multi-Function Shield - LEDs Example (ESP32 Uno) * * Walks through on, off and blink for the four LEDs. * * Shield: DIYables Multi-Function Shield, stacked on the ESP32 Uno form board * * Shield product page: * - https://diyables.io/products/multi-function-shield-for-arduino-uno-mega * * Board product page: * - https://diyables.io/products/esp32-wroom-32-development-board-compatible-with-uno-form-factor-shields-wifi-bluetooth-ch340-usb-type-c-4mb-flash * * Keep in mind: the ESP32 Uno I/O pins work at 3.3V and do NOT accept 5V. */ #include <DIYables_MultiFuncShield.h> // The library default pins are Uno numbers (13, 12, 11, 10 ...). On the // ESP32 Uno these numbers point to other GPIOs (GPIO10/11 even belong to the // flash chip), so this function hands the library the real GPIO numbers. MFS_Pins esp32UnoPins() { MFS_Pins p; p.led1 = 18; // LED D1 on D13 (GPIO18) p.led2 = 19; // LED D2 on D12 (GPIO19) p.led3 = 23; // LED D3 on D11 (GPIO23) p.led4 = 5; // LED D4 on D10 (GPIO5) - boot strapping pin p.button1 = 4; // key S1 on A1 (GPIO4) p.button2 = 35; // key S2 on A2 (GPIO35) - input only, shield pull-up does the job p.button3 = 34; // key S3 on A3 (GPIO34) - input only, shield pull-up does the job p.buzzer = 25; // buzzer on D3 (GPIO25) p.dispLatch = 17; // 74HC595 latch on D4 (GPIO17) p.dispClock = 14; // 74HC595 clock on D7 (GPIO14) p.dispData = 12; // 74HC595 data on D8 (GPIO12) - boot strapping pin p.pot = 2; // trimmer wiper on A0 (GPIO2) - ADC2, no reads while WiFi is on p.lm35 = 36; // LM35 output on A4 (GPIO36) - ADC1, input only return p; } // Do not start the built-in MFS object - it carries the Uno pin numbers. // This object works with the ESP32 Uno GPIO list above. DIYables_MultiFuncShield shield(esp32UnoPins()); void setup() { Serial.begin(9600); shield.begin(); // light the LEDs one after another Serial.println("Turn ON LEDs one by one"); for (uint8_t i = 1; i <= 4; i++) { shield.led(i).turnON(); delay(500); } delay(1000); // switch them off again in the same order Serial.println("Turn OFF LEDs one by one"); for (uint8_t i = 1; i <= 4; i++) { shield.led(i).turnOFF(); delay(500); } delay(1000); // let only LED 1 blink for about 3 seconds Serial.println("Blink LED 1 individually"); shield.led(1).blink(300); unsigned long start = millis(); while (millis() - start < 3000) shield.loop(); shield.led(1).turnOFF(); delay(1000); // finish with all four blinking at the same time Serial.println("Blink all LEDs together"); shield.allLedsBlink(500); } void loop() { shield.loop(); }

Upload and Test

  1. Upload the sketch.
  2. Open the Serial Monitor at 9600 baud to follow each stage.
  3. Watch the LEDs: they switch on one by one every half second, switch off the same way, LED 1 blinks alone for 3 seconds, and then all four blink.
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32 Dev Module' on 'COM15')
New Line
9600 baud
Turn ON LEDs one by one Turn OFF LEDs one by one Blink LED 1 individually Blink all LEDs together
Ln 11, Col 1
ESP32 Dev Module on COM15
2

LED Methods

Method Result
turnON() Lights the LED
turnOFF() Turns the LED off
toggle() Swaps between on and off
blink(interval) Blinks with the same on and off time
blink(onTime, offTime) Blinks with separate on and off times
isOn() true while the LED is lit

Group calls for all four LEDs at once:

Method Result
allLedsOn() Lights all four LEDs
allLedsOff() Turns all four LEDs off
allLedsBlink(interval) Blinks all four in step
allLedsBlink(onTime, offTime) Blinks all four with custom timing

Use shield.led1 to shield.led4, or the numbered form shield.led(1) to shield.led(4). All LEDs are active LOW.

Good to know: the LEDs connect to 5V on the shield. A 3.3V HIGH may leave a faint glow on some units. That is normal and does not harm the board.

Buzzer Example

After this part, the buzzer gives a short beep every 2 seconds.

/* * This ESP32 Uno code was developed by newbiely.com * * This ESP32 Uno code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-uno/esp32-uno-multi-function-shield */ /* * Multi-Function Shield - Buzzer Example (ESP32 Uno) * * Gives one short beep every 2 seconds. * * Shield: DIYables Multi-Function Shield, stacked on the ESP32 Uno form board * * Shield product page: * - https://diyables.io/products/multi-function-shield-for-arduino-uno-mega * * Board product page: * - https://diyables.io/products/esp32-wroom-32-development-board-compatible-with-uno-form-factor-shields-wifi-bluetooth-ch340-usb-type-c-4mb-flash * * Keep in mind: the ESP32 Uno I/O pins work at 3.3V and do NOT accept 5V. */ #include <DIYables_MultiFuncShield.h> // The library default pins are Uno numbers (13, 12, 11, 10 ...). On the // ESP32 Uno these numbers point to other GPIOs (GPIO10/11 even belong to the // flash chip), so this function hands the library the real GPIO numbers. MFS_Pins esp32UnoPins() { MFS_Pins p; p.led1 = 18; // LED D1 on D13 (GPIO18) p.led2 = 19; // LED D2 on D12 (GPIO19) p.led3 = 23; // LED D3 on D11 (GPIO23) p.led4 = 5; // LED D4 on D10 (GPIO5) - boot strapping pin p.button1 = 4; // key S1 on A1 (GPIO4) p.button2 = 35; // key S2 on A2 (GPIO35) - input only, shield pull-up does the job p.button3 = 34; // key S3 on A3 (GPIO34) - input only, shield pull-up does the job p.buzzer = 25; // buzzer on D3 (GPIO25) p.dispLatch = 17; // 74HC595 latch on D4 (GPIO17) p.dispClock = 14; // 74HC595 clock on D7 (GPIO14) p.dispData = 12; // 74HC595 data on D8 (GPIO12) - boot strapping pin p.pot = 2; // trimmer wiper on A0 (GPIO2) - ADC2, no reads while WiFi is on p.lm35 = 36; // LM35 output on A4 (GPIO36) - ADC1, input only return p; } // Do not start the built-in MFS object - it carries the Uno pin numbers. // This object works with the ESP32 Uno GPIO list above. DIYables_MultiFuncShield shield(esp32UnoPins()); unsigned long lastBeep = 0; void setup() { shield.begin(); } void loop() { shield.loop(); if (millis() - lastBeep >= 2000) { lastBeep = millis(); shield.buzzer.beep(100); } }

Upload and Test

  1. Upload the sketch.
  2. Listen: a 100 ms beep sounds every 2 seconds.
  3. Change the sound by editing beep(100) to a longer time, like beep(400).

Buzzer Methods

Method Result
beep(ms) Sounds for ms milliseconds
beep(ms, delayMs) Waits delayMs, then sounds for ms
stop() Silences the buzzer at once
isBeeping() true while the buzzer is on

Potentiometer Example

After this part, the Serial Monitor shows the trimmer as a raw 12-bit value and as a percent.

/* * This ESP32 Uno code was developed by newbiely.com * * This ESP32 Uno code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-uno/esp32-uno-multi-function-shield */ /* * Multi-Function Shield - Potentiometer Example (ESP32 Uno) * * Prints the raw trimmer value (0-4095) and the percent value * on the Serial Monitor two times per second. * * The shield trimmer is a multi-turn type: it takes MANY turns to go * from 0% to 100%. If the number does not move, turn the other way. * * CAUTION: the shield feeds the trimmer from 5V, but A0 (GPIO2) on the * ESP32 Uno must stay at 3.3V or lower. Stop turning once you see 100%. * * Shield: DIYables Multi-Function Shield, stacked on the ESP32 Uno form board * * Shield product page: * - https://diyables.io/products/multi-function-shield-for-arduino-uno-mega * * Board product page: * - https://diyables.io/products/esp32-wroom-32-development-board-compatible-with-uno-form-factor-shields-wifi-bluetooth-ch340-usb-type-c-4mb-flash * * Keep in mind: the ESP32 Uno I/O pins work at 3.3V and do NOT accept 5V. */ #include <DIYables_MultiFuncShield.h> // The library default pins are Uno numbers (13, 12, 11, 10 ...). On the // ESP32 Uno these numbers point to other GPIOs (GPIO10/11 even belong to the // flash chip), so this function hands the library the real GPIO numbers. MFS_Pins esp32UnoPins() { MFS_Pins p; p.led1 = 18; // LED D1 on D13 (GPIO18) p.led2 = 19; // LED D2 on D12 (GPIO19) p.led3 = 23; // LED D3 on D11 (GPIO23) p.led4 = 5; // LED D4 on D10 (GPIO5) - boot strapping pin p.button1 = 4; // key S1 on A1 (GPIO4) p.button2 = 35; // key S2 on A2 (GPIO35) - input only, shield pull-up does the job p.button3 = 34; // key S3 on A3 (GPIO34) - input only, shield pull-up does the job p.buzzer = 25; // buzzer on D3 (GPIO25) p.dispLatch = 17; // 74HC595 latch on D4 (GPIO17) p.dispClock = 14; // 74HC595 clock on D7 (GPIO14) p.dispData = 12; // 74HC595 data on D8 (GPIO12) - boot strapping pin p.pot = 2; // trimmer wiper on A0 (GPIO2) - ADC2, no reads while WiFi is on p.lm35 = 36; // LM35 output on A4 (GPIO36) - ADC1, input only return p; } // Do not start the built-in MFS object - it carries the Uno pin numbers. // This object works with the ESP32 Uno GPIO list above. DIYables_MultiFuncShield shield(esp32UnoPins()); unsigned long lastUpdate = 0; float lastPct = -1; void setup() { Serial.begin(9600); // set the ADC attenuation to 11 dB (up to ~3.3V input) analogSetAttenuation(ADC_11db); shield.begin(); Serial.println("Rotate potentiometer knob (multi-turn trimmer)."); Serial.println("It requires many turns to go from 0% to 100%."); } void loop() { shield.loop(); if (millis() - lastUpdate >= 500) { lastUpdate = millis(); int raw = shield.readPot(); // 12-bit result, 0 to 4095 float pct = shield.readPotPercent(); Serial.print("Raw: "); Serial.print(raw); Serial.print(" Percent: "); Serial.print(pct, 1); Serial.print("%"); if (pct <= 0.1) Serial.print(" ← MIN (rotate clockwise to increase)"); else if (pct >= 99.9) Serial.print(" ← MAX (rotate counter-clockwise to decrease)"); Serial.println(); lastPct = pct; } }

Good to know: the sketch calls analogSetAttenuation(ADC_11db) in setup(). The 11 dB attenuation lets the ESP32 Uno analog pin read the full range, from 0V up to about 3.3V. With a narrower range, the value hits 4095 too early and the readings look wrong.

Upload and Test

  1. Upload the sketch.
  2. Open the Serial Monitor at 9600 baud.
  3. Turn the trimmer screw clockwise with a small screwdriver. It is multi-turn, so many turns move it from 0% to 100%.
  4. Stop at 100%. Past that point the wiper goes above 3.3V. Turn back a little until the value drops.
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32 Dev Module' on 'COM15')
New Line
9600 baud
Rotate potentiometer knob (multi-turn trimmer). It requires many turns to go from 0% to 100%. Raw: 0 Percent: 0.0% ← MIN (rotate clockwise to increase) Raw: 1187 Percent: 29.0% Raw: 2650 Percent: 64.7% Raw: 4095 Percent: 100.0% ← MAX (rotate counter-clockwise to decrease)
Ln 11, Col 1
ESP32 Dev Module on COM15
2

Potentiometer Methods

Method Returns Result
readPot() int Raw ADC value, 0 to 4095 on the 12-bit ESP32 Uno ADC
readPotPercent() float The same value scaled to 0.0 to 100.0

LM35 Temperature Example

After this part, the room temperature in Celsius shows on the display and on the Serial Monitor.

Before you start: take jumper J1 off the shield. It ties a pull-up to the A4 line, and the LM35 reading is wrong while it is on.

/* * This ESP32 Uno code was developed by newbiely.com * * This ESP32 Uno code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-uno/esp32-uno-multi-function-shield */ /* * Multi-Function Shield - Temperature Example (ESP32 Uno) * * Reads the LM35 sensor and shows degrees Celsius on the display * and on the Serial Monitor. * Take jumper J1 off the shield first (it pulls A4 = GPIO36 toward 5V). * * Shield: DIYables Multi-Function Shield, stacked on the ESP32 Uno form board * * Shield product page: * - https://diyables.io/products/multi-function-shield-for-arduino-uno-mega * * Board product page: * - https://diyables.io/products/esp32-wroom-32-development-board-compatible-with-uno-form-factor-shields-wifi-bluetooth-ch340-usb-type-c-4mb-flash * * Keep in mind: the ESP32 Uno I/O pins work at 3.3V and do NOT accept 5V. */ #include <DIYables_MultiFuncShield.h> // The library default pins are Uno numbers (13, 12, 11, 10 ...). On the // ESP32 Uno these numbers point to other GPIOs (GPIO10/11 even belong to the // flash chip), so this function hands the library the real GPIO numbers. MFS_Pins esp32UnoPins() { MFS_Pins p; p.led1 = 18; // LED D1 on D13 (GPIO18) p.led2 = 19; // LED D2 on D12 (GPIO19) p.led3 = 23; // LED D3 on D11 (GPIO23) p.led4 = 5; // LED D4 on D10 (GPIO5) - boot strapping pin p.button1 = 4; // key S1 on A1 (GPIO4) p.button2 = 35; // key S2 on A2 (GPIO35) - input only, shield pull-up does the job p.button3 = 34; // key S3 on A3 (GPIO34) - input only, shield pull-up does the job p.buzzer = 25; // buzzer on D3 (GPIO25) p.dispLatch = 17; // 74HC595 latch on D4 (GPIO17) p.dispClock = 14; // 74HC595 clock on D7 (GPIO14) p.dispData = 12; // 74HC595 data on D8 (GPIO12) - boot strapping pin p.pot = 2; // trimmer wiper on A0 (GPIO2) - ADC2, no reads while WiFi is on p.lm35 = 36; // LM35 output on A4 (GPIO36) - ADC1, input only return p; } // Do not start the built-in MFS object - it carries the Uno pin numbers. // This object works with the ESP32 Uno GPIO list above. DIYables_MultiFuncShield shield(esp32UnoPins()); unsigned long lastUpdate = 0; void setup() { Serial.begin(9600); // set the ADC attenuation to 11 dB (up to ~3.3V input) analogSetAttenuation(ADC_11db); shield.begin(); shield.display.print(0); } void loop() { shield.loop(); if (millis() - lastUpdate >= 500) { lastUpdate = millis(); float temp = shield.readTemperature(); shield.display.print(temp, 1); Serial.print("Temp: "); Serial.print(temp, 1); Serial.println(" C"); } }

Upload and Test

  1. Remove jumper J1 from the shield.
  2. Upload the sketch.
  3. Open the Serial Monitor at 9600 baud.
  4. Hold the LM35 between two fingers for a few seconds and watch the number climb on both the display and the monitor.
∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32 Dev Module' on 'COM15')
New Line
9600 baud
Temp: 23.8 C Temp: 23.9 C Temp: 24.3 C Temp: 25.1 C Temp: 26.0 C
Ln 11, Col 1
ESP32 Dev Module on COM15
2

The library averages the last 4 readings to smooth the value. The first reading fills the whole buffer, so you see a steady number from the start.

Good to know: the LM35 output is only about 0.24V at 24 °C. The ESP32 Uno ADC is less exact near 0V, so a reading can be 1 to 2 °C off. Check against a known thermometer and add a small offset in code if needed.

Full Demo Video

See the ESP32 Uno build in action in the video below.

ESP32 Uno vs UNO R4 for This Project

This table lists what changes when you move the shield from an UNO R4 to the ESP32 Uno.

Item Arduino UNO R4 ESP32 Uno
Logic voltage 5V 3.3V (pins are not 5V tolerant)
Shield object Built-in MFS with default pins Own shield object with an MFS_Pins GPIO list
Display pins D4, D7, D8 GPIO17, GPIO14, GPIO12
Trimmer and LM35 pins A0 and A4 GPIO2 and GPIO36
ADC range 0 to 16383 (14-bit) 0 to 4095 (12-bit)
Extra code line None analogSetAttenuation(ADC_11db) in the analog sketches
Arduino IDE board Arduino UNO R4 WiFi or Minima ESP32 Dev Module

The shield plugs in at the same positions, so no rewiring is needed. Watch the 5V trimmer and the 5V key pull-ups, and always use the GPIO pin list instead of MFS.begin().

Platform Support

The DIYables_MultiFuncShield library is built for every Arduino architecture (architectures=*). On the ESP32 Uno it picks the 12-bit ADC and the 3.3V reference by itself. The one thing you add is the esp32UnoPins() list shown in each sketch above.

Go Wireless: See the Shield Temperature on Your Phone

After this part, you have an idea for taking the shield readings off the desk and onto your phone.

The ESP32 Uno has WiFi and Bluetooth (Classic and BLE), so the LM35 reading can go to a web page or a phone app while the 7-segment display still shows it locally. The LM35 sits on A4 (GPIO36), an ADC1 pin, so it keeps working with WiFi on. The trimmer on A0 (GPIO2) is an ADC2 pin and cannot be read while WiFi runs, so use Bluetooth if you want the knob value too. You can also switch the four LEDs from your phone.

Troubleshooting

Problem Possible Cause Solution
No COM port appears in Arduino IDE CH340 driver missing or a charge-only USB cable Install the CH340 driver and use a USB cable that carries data
Upload ends with "Failed to connect" or "Waiting for download" Board did not enter download mode, or the trimmer holds A0 (GPIO2) high Hold BOOT while the upload starts, and turn the trimmer back toward 0%
Board does not boot or upload with the shield on A boot strapping pin (D8 GPIO12, D10 GPIO5 or A0 GPIO2) is pulled the wrong way Unplug the shield while uploading, then plug it back and press RST
Board resets again and again after upload Sketch calls MFS.begin(), which touches the flash pins GPIO10 and GPIO11 Use the esp32UnoPins() list and the shield object
Build error "multiple definition of MFS" Your object has the same name as the library object Rename it to shield and change every MFS. call
Display stays blank or shows random segments Shield not pressed fully down, or 3.3V signals are weak for the 5V 74HC595 Seat the shield firmly, check 5V and GND, and use a strong USB port
Key S2 or S3 never reacts Pull-up missing on GPIO35 or GPIO34, or wrong GPIO in the list Check that the shield pull-ups are fitted and that button2 is 35 and button3 is 34
Trimmer reads 100% for many turns Wiper is above 3.3V, so the ADC is full Turn it back until the value drops and do not turn further
Temperature reads far too high Jumper J1 is still on Remove J1 and press RST
Trimmer reads 0 or stays fixed in a WiFi sketch A0 (GPIO2) is an ADC2 pin, blocked while WiFi is on Use Bluetooth instead, or wire a separate knob to GPIO32 or GPIO33

FAQ

Does the multi-function shield fit the ESP32 Uno form board?

Yes. The ESP32 Uno uses the Uno header layout, so the shield presses on at the same spots. What changes is the code: you give the library a GPIO list with MFS_Pins, because the Uno numbers point to different pins on this board.

Why do I need my own shield object instead of MFS?

The ready-made MFS object stores the Uno pin numbers. On the ESP32 Uno, pins 10 and 11 are flash pins, so MFS.begin() would crash the board. Your own object, built from esp32UnoPins(), uses the right GPIOs.

Can the 5V shield damage the 3.3V pins?

Most parts only receive signals, so they are safe. The trimmer and the key pull-ups are tied to 5V and can push more than 3.3V into A0 to A3. Park the trimmer at 0V, stop at 100%, and add 15 kΩ resistors from A1, A2 and A3 to GND for long-term use.

What raw range does the trimmer give on the ESP32 Uno?

It gives 0 to 4095, because the ESP32 Uno ADC is 12-bit. The UNO R4 gives 0 to 16383 with its 14-bit ADC. readPotPercent() always returns 0 to 100%, so code that uses the percent works on both boards.

Why does the code call analogSetAttenuation(ADC_11db)?

It sets the ESP32 Uno ADC input range to about 0 to 3.3V, so the full trimmer and LM35 signal maps to 0 to 4095. With a smaller range, the readings saturate early. The UNO R4 sketch does not have this line, because only ESP32 chips need it. Keep every analog input at 3.3V or less.

How accurate is the LM35 on this shield?

The LM35 itself is good to about ±0.5 °C at room temperature. The ESP32 Uno ADC adds some error at low voltages, so expect 1 to 2 °C. Compare once with a trusted thermometer and add a fixed offset in your code.

Why do A2 and A3 need the shield's pull-ups?

A2 (GPIO35) and A3 (GPIO34) are input-only pins with no internal pull-up resistor. The INPUT_PULLUP mode has no effect on them. The pull-up resistors on the shield keep the keys at HIGH until you press them.

Are D8, D10 and A0 safe to use on the ESP32 Uno?

They are boot strapping pins (GPIO12, GPIO5, GPIO2). With this shield they normally boot fine, because the display input does not pull D8 and the LED keeps D10 high. A0 is the one to watch: keep the trimmer low during uploads.

Can I use the trimmer and WiFi in the same sketch?

Not on A0. A0 (GPIO2) and A1 (GPIO4) are ADC2 pins, and ADC2 cannot be read while WiFi is on. The keys on A1 still work, because they are digital reads. For an analog knob in a WiFi project, move it to A2 to A5 (GPIO35, 34, 36, 39) or GPIO32/33 and change the pin in code.

Do I need a driver to upload code to the ESP32 Uno?

The board uses a CH340 USB-to-serial chip. Windows and macOS often need the CH340 driver once. After that, the board appears as a COM port in Arduino IDE.

What if my project needs more pins than the shield leaves free?

The shield covers most Uno headers, but the ESP32 Uno has a few extra holes near the power header: GPIO32 and GPIO33 (I/O, PWM, analog on ADC1, so they work with WiFi on) and GPIO15 (I/O, PWM, analog on ADC2). Solder pin headers to them and write the GPIO number in code. For an extra sensor in a WiFi version of this project, use GPIO32 or GPIO33. Two warnings: GPIO15 and GPIO0 (the IO0 pin at the unused Uno NC position) are boot strapping pins, and a wrong connection can stop the board from booting or uploading code, so try GPIO32/33 first. Also never use the six holes under the digital header (SD0 to SD3, CMD, CLK = GPIO6 to GPIO11). They connect to the flash chip, and using them crashes the board.

How to Connect Other Components

The Multi-Function Shield covers all the pins of the ESP32 Uno, and it has no female headers on top. So how can you connect other components, such as sensors, relays or motors, to the ESP32 Uno?

The answer is simple: put a Proto Screw Terminal Block Shield or a Screw Shield V2 between the ESP32 Uno and the Multi-Function Shield.

ESP32 Uno Multi-Function Shield with Screw Shield

The screw shield has a screw terminal for each pin. It lets you connect the ESP32 Uno to other components. Do not use the pins that the Multi-Function Shield already uses: D3, D4, D7, D8, D10 to D13 and A0 to A3, and also A4 when you use the LM35 sensor. The free pins are D2, D5, D6, D9 and A5. D2 is free when the U4 socket (for an IR receiver) is empty. On the ESP32 Uno, these free pins are D2 (GPIO26), D5 (GPIO16), D6 (GPIO27), D9 (GPIO13) and A5 (GPIO39, input only). Every screw terminal goes straight to a 3.3V pin, so keep each signal at 3.3V or less.

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!