ESP32 D1 Mini NodeMCU WiFi Module

Today there is a special variant of the ESP32, namely the ESP32-Mini. This board is characterized by the fact that it is pin-compatible with the D1-Mini. That means shields for the D1-Mini can be used without any problems.


The pins with the white border are those that are identical with the D1-Mini. If you equip these with the enclosed combined pin and spring strips, you can also use the ESP32-Mini on the Dual-Base Shield use.

The board has two additional rows of pins so that as many of the ESP32's GPIOs as possible can be used. Here is the complete pinout.


In today's project we want to work with the ESP32-Mini and one 0.66 inch OLED display shield and realize a small, compact I2C scanner. The wiring is very simple because the display only has to be plugged onto the ESP32-Mini. We equip the ESP32 board with the four ten-pin socket strips. We plug the display shield onto the two internal socket strips, leaving the two pins in the direction of the USB connector free.

For the I2C bus to be examined, it would be nice if the required pins are next to each other in such a way that the I2C module can simply be plugged in. This can be done easily if the I2C module is supplied via GPIO pins. The only restriction with this method, the module must not require more than 30 mA, which is certainly the case with all sensor modules.
We will use the pins GPIO27, GPIO25, GPIO32 and GPIO12 on the right, outer socket strip for this.

  • GPIO27 = Vcc 3.3V
  • GPIO25 = GND 0V
  • GPIO32 = SCL
  • GPIO12 = SDA

This is the typical pin assignment of most modules with an I2C bus.

The picture shows the ESP32-Mini with attached display and a BMP180 sensor module.


However, this structure still has a small disadvantage. There are also sensor modules with the same pin assignment, but with additional pins. These pins should not be connected to the neighboring pins on the ESP32 female connector. In addition, the test module can no longer simply be plugged in when the scanner is to be built into a housing. The solution is a four-pole extension for the test pins.

We manufacture this extension from one of the two enclosed, combined pin and spring strips. We cut them off so that there are four pins left. We put this extension on our test pins. Now additional pins of the sensor modules are simply outside the socket. When installed in a housing, the test pins protrude easily accessible from the housing.

The program is very simple. A connection is attempted to be established one after the other with all 127 I2C addresses for scanning. If the connection is successful, the corresponding address is shown on the display. The measurement is carried out for different bus speeds.

  • 100kHz standard I2C
  • 400kHz Fast I2C
  • 1 MHz Fast Plus I2C
  • 4 MHz high speed I2C

For compilation we need the ESP32 package and the Adafruit_GFX.h and Adafruit_SSD1306.h libraries for the display

#include<Wire.h> //I2C Bibliothek im Package enthalten
#include <Adafruit_GFX.h> //Allgemeine Grafik Bibliothek
#include <Adafruit_SSD1306.h> //Bibliothek für den verwendeten Display Treiber

#define SDA1 21 //Daten Pin für den ersten I2C Bus für das Display
#define SCL1 22 //Takt Pin für den ersten I2C Bus für das Display

#define SDA2 12 //Daten Pin für den zweiten I2C Bus verwendet als Testbus
#define SCL2 32 //Takt Pin für den zweiten I2C Bus verwendet als Testbus
#define MVIN 27 //Pin für die Stromversorgubg immer auf HIGH
#define MGND 25 //Pin für GND immer auf LOW

#define X0 32 //Das Display hat nur 64 Pixel in der Breite, der SSD1306 kann aber nur mindestens
//96 Pixel richtig verarbeiten, wobei sich die übrigen 32 Pixel am linken Rand
//befinden. Alle Ausgaben auf das Display haben daher einen Offset von 32 Pixeln

//Instanzen für die beiden I2C Busse
TwoWire I2Ca = TwoWire(0);
TwoWire I2Cb = TwoWire(1);

//Instanz für das Display die Parameter sind
//Display-Breite, Display-Höhe und Adresse der I2C Bus Instanz
Adafruit_SSD1306 display(96,48,&I2Ca);

//Bufferspeicher für die gefundenen Adressen
//"--" bedeutet keine Adresse gefunden
char adresse[4][3] = {"--","--","--","--"};

//Ein Scan mit einer bestimmten Frequenz wird durchgeführt
//Der Parameter step gibt die Nummer der Messung an
void scan(uint32_t frequency, uint8_t step) {
bool error = false;
bool found = false;
I2Cb.setClock(frequency); //I2C Busfrequenz setzen
for(int i=1; i<128; i++){
I2Cb.beginTransmission(i); //I2C Übertragung starten
error = I2Cb.endTransmission(); //Beim Beenden prüfen wir auf Fehler
if(error == 0){ //War kein Fehler aufgetreten, merken wir uns die Adresse
sprintf(adresse[step],"%02x",i);//Adresse als zweistellige HEX Zahl speichern
if (!found) {
strcpy(adresse[step],"--"); //es wurde keine funktionierende Adresse gefunden

//Die gefundenen Adressen in der zweiten Spalte des Displays anzeigen
void displayResult(){
for (uint8_t i = 0;i<4; i++){
display.fillRect(X0+45,8*i+16,12,8,BLACK); //Zuerst einen alten Wert löschen
display.setCursor(X0+45,16+i*8); //Cursor setzen X=45 und Y ab Zeile 3 daher + 16
display.print(adresse[i]); //Daten aus dem Bufferspeicher ausgeben
display.display(); //Display aktualisieren

void setup() {
//Pins für die Stromversorgung des Testmodul
//Beide i2C Busse initialisieren
//Display initialisieren
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
//Leeres Formular anzeigen
void loop() {
//Scans für die verschiedenen Frequenzen durchführen
//Ergebnis anzeigen
//1s warten

And this is what our I2C scanner looks like in a housing:

Have fun building it.

Here are the links to that sketch and the 3D print files Lower part / Top.



Andreas Wolter

Andreas Wolter

@Fabio Tensi:
You can power the board in three different ways: via USB port, via Vin 5V pin (unregulated), via Vin 3.3V (regulated).
If you want to use the 5V Vin pin, you should apply a voltage between 5V and 12V. The higher the voltage, the warmer the voltage regulator becomes. Therefore, 9V is often used.
If the 3.3V Vin Pin is used, the 3.3V should not be exceeded. Also, avoid using multiple voltage sources at the same time.

Fabio Tensi

Fabio Tensi

Hi I bought 3 x D1 mini esp-32, all 3 work correctly when I use the usb port, when I use the 5V power supply connected to the VCC PIN (+ 5V),it does not boot.
I have tried with the D1-mini and the D1-mini-pro which are currently working.
Can you help me ?
Thank you.
Fabio Tensi

Leave a comment

All comments are moderated before being published

Recommended blog posts

  1. Install ESP32 now from the board manager
  2. Lüftersteuerung Raspberry Pi
  3. Arduino IDE - Programmieren für Einsteiger - Teil 1
  4. ESP32 - das Multitalent
  5. OTA - Over the Air - ESP programming via WLAN