Category Archives: ESP32

ESP32 Internal Temperature Sensor Example

ESP32 has on chip temperature sensor, This sensor is not usable to monitor external temperature, It is used to monitor its core temperature. In this tutorial we are monitoring on chip temperature sensor data.

Update: The temp sensor is obsolete on most of the ESP32. 

ESP32 Internal Temperature Sensor

Arduino Code for ESP32 Internal Temperature Sensor

/* 
 *  https://circuits4you.com
 *  ESP32 Internal Temperature Sensor Example
 */

 #ifdef __cplusplus
  extern "C" {
 #endif

  uint8_t temprature_sens_read();

#ifdef __cplusplus
}
#endif

uint8_t temprature_sens_read();
//====================================================
//         Setup
//====================================================
void setup() {
  Serial.begin(115200);
}

//====================================================
//         Loop
//====================================================
void loop() {
  Serial.print("Temperature: ");
  
  // Convert raw temperature in F to Celsius degrees
  Serial.print((temprature_sens_read() - 32) / 1.8);
  Serial.println(" C");
  delay(1000);
}

Results

Open Serial monitor at baud rate of 115200 and see the temperature of chip.

Example shows 53.33 ° C because the function just returns 128 (sensor not present).

ESP32 Internal Hall Sensor Example

ESP32 comes with in build hall sensor, this sensor can be used to detect presence of magnet, Like door sensor. In this tutorial we will see how to read its value and detect presence of magnet.

A Hall effect sensor is a transducer that varies its output voltage in response to a magnetic field. Hall effect sensors are used for proximity sensing, positioning, speed detection, and current sensing applications.[1]

ESP32 Internal Hall Effect Sensor

Continue reading ESP32 Internal Hall Sensor Example

ESP32 Hardware Serial2 Example

There are three serial ports on the ESP32 known as U0UXD, U1UXD and U2UXD all work at 3.3V TTL Level. There are three hardware supported serial interfaces on the ESP32 known as UART0, UART1 and UART2. Like all peripherals, the pins for the UARTs can be logically mapped to any of the available pins on the ESP32. However, the UARTs can also have direct access which marginally improves performance. The pin mapping table for this hardware assistance is as follows.

UART RX IO TX IO CTS RTS
UART0 GPIO3 GPIO1 N/A N/A
UART1 GPIO9 GPIO10 GPIO6 GPIO11
UART2 GPIO16 GPIO17 GPIO8 GPIO7

Having said that, the UART drivers that I recommend to use don’t have this level of optimization built into them and as a result, you are pretty much free to use any pins you choose. Continue reading ESP32 Hardware Serial2 Example

ESP32 Capacitive Touch Pad Example

Introduction

A touch-sensor system is built on a substrate which carries electrodes and relevant connections under a protective flat surface. When a user touches the surface, the capacitance variation is triggered and a binary signal is generated to indicate whether the touch is valid.

ESP32 can provide up to 10 capacitive touch pads / GPIOs. The sensing pads can be arranged in different combinations (e.g. matrix, slider), so that a larger area or more points can be detected. The touch pad sensing process is under the control of a hardware-implemented finite-state machine (FSM) which is initiated by software or a dedicated hardware timer.

Continue reading ESP32 Capacitive Touch Pad Example