29-12-2021 - NodeMCU-32S


Connect to the NodeMCU development kit and send a program to it.

Do this through the Arduino IDE

Prepare Arduino IDE:

I used this guide to prepare the Arduino IDE for ESP32.
While testing the installation, it turned out, that my ES32 was a complete different one.
It seemed to be this one.

Connection solution:

And... there is something special about connecting (see the revision log about the driver).
After downloading and installing the driver.... no connection.
Hmmm... While my Arduino IDE is installed in a VMware Vertual machine, I changed the USB compatibility to USB 2.0, and I changed the connection parameters to (see below picture - in the red box).


And then... succes.

I could test the installation and the Wifi of the ESP following the guide, mentioned before.
The test program "WiFaScan" returned all my WiFi networks with an appropiate strength.

Connecting DS18B20 for temperature measurement

I tried to hook up a temperature sensor of the type DS18B20, which is a One Wire Sensor.
I used this guide to hook up one DS18B20 sensor.
???Without succes.???
At the bottom of this page, the pin-out of the module is described.
But... there is no reference to e.g. the USB port, front side or back side.
Furthermore the module has no readable identifications at the pins like we know from Arduino.
So I tried to measure and follow the print layout of the module. The reference to the USB port is shown in below picture. It presents the component sode of the module.


This page confirms my research.
Also there is more information about the reprogramming of the firmware.
Loading the program and testing is ok now. Temperature readings are given in the terminal window.


It is not very convenient to read the temperature(s) in the terminal window.
Also, if you have more than one temperature reading, the information in the terminal windows gets unclear.
So, lets build a web server on the ESP to show the data.
Most of the information is from randomnerds.com tutorials.

Step 1 - Install the ESPAsyncWebServer Library

  1. Click here to download the ESPAsyncWebServer library.
  2. This will give you a .zip file with the name ESPAsyncWebServer-master.zip.
  3. Unzip the file, which will give you a ESPAsyncWebServer-master folder.
  4. Rename this folder to ESPAsyncWebServer
  5. Move this folder to your Arduino IDE libraries folder. (C:\Program Files (x86)\Arduino\libraries)

Step 2 - Install the Async TCP Library

The ESPAsyncWebServer library depends the AsyncTCP library.

  1. Click here to download the AsyncTCP library.
  2. This will give you a .zip file with the name AsyncTCP-master.zip.
  3. Unzip the file, which will give you a AsyncTCP-master folder.
  4. Rename this folder to AsyncTCP
  5. Move this folder to your Arduino IDE libraries folder. (C:\Program Files (x86)\Arduino\libraries)

Step 3 - Restart your Arduino IDE

Setp 4 - Code for DS18B20 Async Web Server

The code:
Click here to show the code.
Click here to download the code.

This is how it works:

  1. First import the libraries for the project.
  2. Define the OnwWire data bus.
  3. Instanciate the sensor.
  4. Set network credentials.
  5. Create a server object.
  6. Perform temperature reading.
  7. Build the web page.

    The next step is building the web page.
    The HTML and CSS needed to build the web page are saved on the index_html variable.

    In the HTML text we have TEMPERATUREC and TEMPERATUREF between % signs.
    This is a placeholder for the temperature values.

    This means that this %TEMPERATUREC% text is like a variable that will be replaced by the actual temperature value from the sensor.
    The placeholders on the HTML text should go between % signs.

    This is explained in great detail how the HTML and CSS used in this web server works in a another tutorial.

    So, if you want to learn more, refer to this tutorial.

  8. The processor.

    The processor() function replaces the place holders in our HTML with the actuel values of the sensor.

    When the web page is requested, we check if the HTML has any placeholders.
    If it finds the %TEMPERATUREC% placeholder, we return the temperature in Celsius
    by calling the readDSTemperatureC() function created previously.

    If the placeholder is %TEMPERATUREF%, we return the temperature in Fahrenheit.

  9. setup()

    In the setup() we initialize the serial monitor and the DS18B20 sensor.

    And we connect to the local network and print the ESP32 IP address.

  10. Handle web server
  11. Start server
  12. Main program
Back to top