What to do when an error occurs when compiling?
Compiling your code can be a challenging experience, especially when unexpected errors arise. Here's how to troubleshoot some common problems that might occur during the compilation process of a microcontroller such as the ESP32.
First, check the error messages carefully. For example, if you get a library not found error, check that the library name is spelled correctly. The convention in programming is to use lowercase letters for libraries, so make sure everything is lowercase.
How to fix an unrecognized variable error?
It is common that sometimes global variables are not recognized due to errors in the name declaration. If the compiler does not recognize your pinchens
variable (or any other), check how you initially defined it. Make sure the name is consistent throughout the code. If you preferred a specific name, such as pinchens
, update all instances where this variable is used to avoid errors.
Does the order of declarations and definitions matter?
Yes, the order does matter. When defining specific configurations or commands such as enabling a serial monitor, be sure to put these proper commands before including the libraries, otherwise they will not have the desired effect.
How to connect and configure the ESP32 correctly?
To connect your ESP32 safely and effectively, follow these steps:
-
Disconnect the power cable: Before making any connections, make sure the power cable is disconnected to prevent short circuits that could damage your computer.
-
Select the correct port: Once connected, select the appropriate port in the Arduino software tools:
- Windows:
COM
- Linux:
tty
- Mac:
dev
-
*Configurethe board: Make sure the board is configured with the default settings and press the button to upload the code.
How to enable serial communication for debugging?
To enable serial communication for debugging purposes you need to properly define the necessary commands before including the relevant libraries. This ensures that the library implements the specified settings.
- Define the reserved word, for example,
_DEBUG_SERIAL
, just before including the libraries to ensure that each debug output is sent through the serial monitor.
How to check the connection and operation of the system?
Once your microcontroller is correctly programmed:
-
Check the serial monitor: Open the serial terminal to verify if information is being communicated correctly. If you see information such as an IP address, it indicates an established connection.
-
Play and adjust the mobile application: Make sure the application is running and receiving data. Use online devices to verify functionality.
-
Control sensors and actuators: Try turning on and off leds or any other connected device to check if the commands are effective.
How to display sensor data in the application?
You can customize how the data is displayed in the application interface. If you are not satisfied with the graphical representation, you can change it:
- Replace line graphs with meters for clearer humidity and temperature indicators.
- Configure the value ranges according to the specifications of your sensors (example: humidity from 0 to 100% and temperature from -10ºC to 70ºC).
- Add suffixes to the units of measurement for better understanding, such as percentage for humidity and degrees Celsius for temperature.
This approach not only improves data visualization, but also allows for customization that serves both personal and shared projects. Remember that you can share the monitoring links so that others can observe and control your device from anywhere in the world.
Want to see more contributions, questions and answers from the community?