Overview
Effective debugging is crucial for embedded systems development. Kinematrix provides powerful debugging tools including SerialDebuggerV2 for comprehensive logging and built-in sensor diagnostics.SerialDebuggerV2
The SerialDebuggerV2 class provides advanced debugging with log levels, filtering, timestamps, and memory monitoring.Quick Start
Log Levels
SerialDebuggerV2 supports hierarchical log levels:Custom Log Levels
Create application-specific log levels:Debugging Sensor Issues
Sensor Diagnostics
Use the built-indebugAll() method to inspect all sensors:
Output Example:
Multi-Value Debugging
Debug multiple values in a single line:Advanced Debugging Features
Array Debugging
Print arrays and matrices:Memory Monitoring
Track memory usage:Execution Time Profiling
Measure function execution time:Section Formatting
Organize debug output:Complete Debugging Example
Here’s a comprehensive example combining multiple debugging techniques:Serial Commands for Debugging
Implement interactive debugging commands:Platform-Specific Debugging
ESP32 Debug Output
Memory Debugging
Common Debugging Scenarios
Scenario 1: Sensor Not Updating
Scenario 2: I2C Communication Issues
Scenario 3: Timing Issues
Best Practices
Use Log Levels
Organize debug output with appropriate log levels for filtering
Add Timestamps
Enable timestamps to track when events occur
Monitor Memory
Watch memory usage to prevent out-of-memory crashes
Profile Performance
Use execution time logging to identify bottlenecks
Troubleshooting Tips
No debug output appearing
No debug output appearing
- Verify
debug.begin()is called - Check baud rate matches Serial Monitor
- Ensure log level allows the message
- Try
debug.enable()explicitly
Garbled output
Garbled output
- Verify baud rate consistency (115200)
- Check for buffer overflows
- Reduce debug output frequency
- Use
debug.enableBuffering(true)
System crashes when debugging
System crashes when debugging
- Reduce buffer sizes
- Disable memory monitoring
- Use lighter debug levels
- Check for stack overflow
Next Steps
Basic Sensor Reading
Apply debugging to sensor applications
IoT Data Logger
Debug data logging systems
Multi-Platform Development
Platform-specific debugging
LED Control
Debug I2C and LED issues