Build, test, and develop Arduino firmware projects using PlatformIO with Docker-based tooling
This skill guides Claude Code when working with Arduino firmware projects built with PlatformIO, particularly for Arduino MKR WiFi 1010 boards with automated distillation control systems.
The codebase follows a modular architecture with clear separation of concerns:
```bash
pio run
pio run -e prod # Production build
pio run -e native # Native build for development
pio run -e test # Test build
pio run -e ci # CI build with warnings as errors
pio run -t upload
pio run -t clean
```
```bash
./scripts/pio-tools.sh test
pio test -e test
pio test -e test -f test_thermometer
```
```bash
./scripts/pio-tools.sh format
./scripts/pio-tools.sh tidy
./scripts/pio-tools.sh all
```
The project uses Docker for consistent development environments:
```bash
docker build -t distiller-tools .
docker run -v $(pwd):/project distiller-tools [command]
```
Tests use Google Test and Google Mock with a mock Arduino implementation:
```cpp
#ifdef UNIT_TEST
// Test-specific constructor with dependency injection
Controller(MockHardware* mock) : hardware(mock) {}
#else
// Production constructor
Controller() : hardware(new RealHardware()) {}
#endif
```
Key Arduino libraries used:
Test libraries:
Distillation processes follow a state machine:
1. HEAT_UP → STABILIZING (temp > 40°C)
2. STABILIZING → EARLY_FORESHOTS (temperature stabilizes)
3. EARLY_FORESHOTS → LATE_FORESHOTS (200ml collected)
4. LATE_FORESHOTS → HEADS (400ml collected)
5. HEADS → HEARTS (900ml collected)
6. HEARTS → EARLY_TAILS (5000ml or temperature rise)
7. EARLY_TAILS → LATE_TAILS (700ml collected)
8. LATE_TAILS → FINALIZING (600ml collected)
9. FINALIZING → OFF (10 minutes elapsed)
When working with this codebase:
1. **Always run tests** after making changes to hardware controllers or state logic
2. **Use Docker tools** for consistent formatting and linting
3. **Add unit tests** for new controller methods using Google Mock
4. **Preserve hardware abstraction** when modifying controller classes
5. **Use TaskManagerIO** for any new timed or repeated operations
6. **Follow state machine** patterns when modifying process flow
7. **Test on native environment** before uploading to Arduino hardware
8. **Keep mocks updated** when changing hardware interfaces
1. Create hardware abstraction interface
2. Implement production and mock versions
3. Add controller class with conditional constructor
4. Write unit tests with Google Mock
5. Integrate with TaskManagerIO for scheduling
6. Update main controller orchestration
1. Update state transition logic in DistillationStateManager
2. Adjust condition thresholds if needed
3. Update tests to cover new transition conditions
4. Verify state machine flow with integration tests
1. Add sensor abstraction in HAL
2. Create mock implementation for testing
3. Update relevant controller (Thermometer, Scale, etc.)
4. Add calibration routines if needed
5. Test with mock values before hardware integration
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/platformio-arduino-development/raw