Choose your country and language
Language
The goal of this lesson is to give you the skills needed to identify and solve common problems that can arise when coding for the ESP32 and interacting with sensors. We will cover troubleshooting techniques and solutions to errors related to code, hardware connections, and library use.
When you start programming and working with your ESP32 and sensors, it is important to be prepared for possible errors. Debugging is a critical skill that ensures your code works correctly and your hardware operates as intended.
In this lesson, we go through the most common errors and solutions so you can diagnose and solve problems quickly and efficiently.
Symptoms:
Possible causes:
Solutions:
#include statements:
#include directive matches the installed library. For example, if you use Adafruit AHT10, your code should include:#include <Adafruit_AHTX0.h>
Symptoms:
Possible causes:
Solutions:
Check wiring connections:
Verify the power supply:
Initialization code:
aht.begin() is called correctly in the setup() function:if (!aht.begin()) { Serial.println("Failed to find AHT10 chip"); while (1) { delay(10); } // Stopper programmet, hvis initialisering fejler }
Symptoms:
Possible causes:
Solutions:
Check the sensor calibration:
Ensure correct data handling:
getEvent() is used correctly to read data:sensors_event_t humidity_event; sensors_event_t temp_event; aht_humidity->getEvent(&humidity_event); aht_temp->getEvent(&temp_event); Serial.print("Temperature: "); Serial.print(temp_event.temperature); Serial.println(" °C"); Serial.print("Humidity: "); Serial.print(humidity_event.relative_humidity); Serial.println(" % rH");
Symptoms:
Possible causes:
Solutions:
Check the baud rate:
Serial.begin().Serial.begin(115200); // Sørg for at Serial Monitor også er sat til 115200 baud
Verify serial initialization:
Serial.begin() is called in setup():void setup() {
Serial.begin(115200);
}
Check cables and connections:
Use Serial.print() for debugging
Serial.print() statements in the code to follow the execution flow and track variables.Read error messages carefully
Check the documentation
![]() |
AHT10 high-precision temperature and humidity sensor |
![]() |
TTGO T-Display ESP32 16MB with WiFi, Bluetooth and 1.1" color LCD screen |
![]() |
Dupont cables, 40 pcs |
In this lesson, you have learned about the most common problems that can arise when programming the ESP32 and using sensors. We have covered library errors, sensor initialization, incorrect readings and Serial Monitor problems.
By taking a systematic approach to debugging you can efficiently identify and solve problems so your code and hardware work optimally.
Remember: Troubleshooting is an iterative process. Do not get frustrated — every error you solve brings you closer to a successful project!
About the measurements: The station in this series measures temperature and relative humidity using the AHT10. These are indoor climate readings, not direct measurements of CO2, VOCs, or particles. The series name “air quality monitoring” should be understood with this limitation.
Language