Das einundzwanzigste Türchen

3x ESP32 Dev Kit CV 4 (unsoldered)

We are already at number 21. Not much is missing until the last door. Today, you can find the Development board ESP32 Dev Kit CV 4 in a bundle of three in the variant without soldered header pins (pin headers).

The advantage here is that you only have to solder the components you need. As a result, the installation size in housings is even smaller. Of course, you can still solder the complete header pins yourself. A little guide was behind door number two of the AZ advent calendar. My personal tips for soldering:

  • use a suitable soldering iron
  • use flux
  • a breadboard is suitable for fixing the component (for soldering header pins)
  • Hold the soldering iron and solder to the soldering point and let the solder flow

If you want to use a component like this ESP32 development board, it is recommended to have a look at the data sheet and the Pinout diagram. This tells you which processor it is and which peripherals are available to you. In this case, the most important facts are the built-in WiFi and Bluetooth connectivity options. The CPU clocks with a maximum of 240 MHz. Our interfaces include I²C, SPI, UART and 1-Wire. Almost all pins can be used for PWM (pulse width modulation, e.g. for dimming LEDs).

A Hall-Effect sensor (not to be confused with an echo) is integrated to detect changes in a magnetic field. A temperature sensor that can monitor the CPU temperature is no longer included on these newer ESP boards. 16 pins are connected to integrated analog-to-digital converters, two pins to digital-to-analog converters. Here is a small pin overview as a supplement to the pinout:

Pins (GPIO)

function

21, 22

I²C (SDA, SCL)

5, 18, 19, 23

SPI (SS, SCK, MISO, MOSI)

1, 3 / 9, 10 / 16, 17

UART (TX0, RX0) / RX1, TX1 / RX2, TX2)

0, 2, 4, 12, 14, 15, 25, 26, 27, 32, 33, 34, 35, 36, 39

Analog-to-digital converter

25, 26

Digital-to-analog converter

There are a few more things to consider when using the pins:

  • GPIO1 should not be used as an input and GPIO3 not as an output
  • GPIO6 to GPIO11 should not be used as input or output
  • GPIO34, GPIO35, GPIO36 and GPIO39 can only be used as inputs
  • GPIO12 on HIGH prevents booting
  • GPIO0, GPIO1 and GPIO3 can show unexpected behavior because they are used by the system for other purposes (e.g. during the boot process)

At this point I would like to refer to the very detailed blog post ESP32 - the all-rounder by Gerald Lechner. There you will find a comprehensive comparison with other ESP32 boards, connection options, installation in the Arduino IDE and much more. Well worth reading the article before you get started.

When everything is installed and the ESP32 Dev Module is selected in the Arduino IDE  you of course want to upload your first sketch. Numerous sample programs are included.

Since this package contains three ESP32, I would like to exchange data between the individual boards. For this I use the ESPNow Sketches Master and Slave. With the Uno or Nano you are used to starting the upload and everything runs until the program has been transferred. However, you may also see this error message:


In this case, you need to put the board in bootloader mode. To do this, you have to press the boot button on the board and possibly hold it down until the connection is established:


Since that always bothered me a little, I followed these instructions and added a 10 nF capacitor (connected + to EN and - to GND). It is no longer necessary to press the button.

Tip: If nothing appears in the serial monitor after uploading a program, briefly press the reset button on the micro controller.

So that we can use two micro controllers at the same time on one computer, we start two separate processes of the Arduino IDE (currently only tested under Windows). That means, you just have to start the program again. If two ESP32 are connected, two COM devices should also be displayed under Tools-> Port:

The numbers of the virtual COM ports can be different for you

We open the two examples Master and Slave from the examples ESP32 -> ESPNow -> Basic. Make sure that you start them in two different Arduino instances and that the other port is set. Load the two sketches onto the micro controller and open the serial monitor (CTRL + SHIFT + M). Data is then exchanged between the two devices:


In this example, data of type uint8_t i.e. 1 byte (8 bit) is transferred. The recipient automatically recognizes via callback that a data block has arrived. Hence the loop ()-Function in slave source code is empty.

Would you like to transfer your own data, e.g. that of a sensor, then look for the function in the master's source code sendData (). The variable data is declared outside with:

uint8_t data = 0;

and then with

data ++;

counted up after each run. The output from both monitors shows these values. Assign your own values ​​to this variable e.g. with:

data = sensorRead ();

The sensorRead () function call is fictitious!

For more than two micro controllers you can use the examples Master and Slave under ESP32 -> ESPNow -> use multi-slave.

I would now like to show you how to set up a small text chat with several micro controllers. For this we need a server that distributes the messages centrally. In addition, of course, other participants, the clients. We use the example sketch as the basis for the server AsyncUDPServerwhich you can find under "ESP Async UDP".

We use the sketch under "Wifi" for the clients WiFiUDPClient. The server "listens" on a specified port for incoming messages that are sent by the clients via the same port. When the server is started, the IP address is displayed in the serial monitor as soon as a connection to the WLAN network has been established. This must then be entered in the source code for the clients. The name of your network (SSID) and the associated password must also be entered there.

You load the async server onto one of the ESP32s, the client onto the other two. If you start the Arduino IDE three times separately, you can also run all three participants on one computer for a test. The server can also participate in the chat:


UDP is a connectionless transmission. This means that data packets are sent without checking whether they have reached the recipient. You can use it to generate your own protocols and secure the transmission yourself. It requires less overhead, i.e. control code, than for e.g. TCP. UDP is e.g. used to transmit video or audio data.

Here you can download my modified source codes.

The ESP32 naturally offer even more options. For calendar door number 11, I had already shown you how you can display the data from the BME280 sensors in the browser with an ESP8266. Of course, this also works with an ESP32. To do this, test the sketch AdvancedWebServer under "WebServer". Enter your Wi-Fi data there. After uploading, start the Serial Monitor in the Arduino IDE. The IP address is displayed there. On a device that is on the same network, open an Internet browser and enter the IP address. The ESP32 then greets with a diagram. The Advanced Server automatically updates the page at specified intervals, which can also be useful for your own projects.

If you don't have your own Wi-Fi network and still want to connect the micro controllers or other devices via Wifi, you can use an ESP32 as a Wi-Fi access point. To do this, see the examples under "WiFi" in the Sketch WiFiAccessPoint. Assign your own access data and upload the program to the micro controller. The other devices can then use the newly created Wi-Fi network for their communication:

 
The ESP32 has one advantage over the ESP8266: the Bluetooth connection (LowEnergy and Classic). You can also find sample sketches in the Arduino IDE. For a test, you can install the Serial Bluetooth Terminal app on your smartphone. In the examples in the Arduino IDE, locate the "BluetoothSerial" point and open the sketch SerialToSerialBT. After successful upload, the ESP32 should be available as a Bluetooth device.

First, open the Serial Monitor in the Arduino IDE. Then connect your smartphone to "ESP32test" via Bluetooth and then open the above app. There, tap the menu (three strokes) at the top left corner and select "Devices". You would also have to see "ESP32test" in the list that is now appearing. Select the point and wait briefly for the connection to be established. You can then exchange text messages between your smartphone and PC (via the Serial Monitor).

The other example sketches show even more possibilities for the implementation of your own projects. You can also connect sensors, LEDs, or displays. The ESPs have a DeepSleep mode that is interesting for battery-powered projects.

If you connect a potentiometer (changeable resistor) to one of the pins with analog-to-digital converter (see table above), you can use the analogRead (PINNUMMER) a range of 0 and 4095. Unlike uno or nano microcontrollers, which do not go beyond 1023.

Important: Use the 3.3V pin, NOT the 5V pin, to connect the potentiometer!


Void setup()
Serial.begin(115200);
}

void loop()
Serial.println(analogRead(33));
delay(30);
}

 

 

I wish you a Merry Christmas.

Andreas Wolter

for AZ-Delivery Blog

Specials

2 comments

Gerald Lechner

Gerald Lechner

ESP32 kann nicht über ESP_Easy geflasht werden. Das Tool von ESPRESSIF sollte funktionieren. https://www.espressif.com/en/support/download/other-tools

Reinhardt Schiffke

Reinhardt Schiffke

Kann man den ESP-32 Dev Kit C V4 über esp_easy flashen ? habe alles versucht ,bekomme es nicht hin.

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