This project demonstrates how embedded machine learning can be used to classify different coffee brands using gas sensing technology. By leveraging the BME688 4-in-1 environmental sensor and Microchipβs PIC32CX-BZ2 / WBZ451 microcontrollers, we built a complete workflow from data collection β model training β deployment on hardware.
The project highlights how low-cost sensors and TinyML techniques can be applied to real-world use cases such as food authentication, air quality monitoring, and industrial predictive maintenance.
- Problem: Coffee authenticity and quality control are often expensive and require lab-grade instruments.
 - Solution: Use gas sensor readings (VOC/VSC, carbon monoxide, hydrogen signatures) + embedded ML to classify coffee brands in real time.
 - Approach:
- Capture sensor data from different coffee brands.
 - Train an ML classifier using Microchipβs MPLAB ML Development Suite.
 - Deploy the model on a low-power PIC32CX-BZ2 MCU for on-device inference.
 
 
- 2 Γ PIC32CX-BZ2 / WBZ451 Curiosity Boards
- One board + BME688 sensor inside a sealed jar with coffee (sensor node).
 - Second board connected to PC via USB (host node).
 
 - BME688 Environmental Sensor β measures temperature, humidity, pressure, and gas resistance.
 - 3.7V Li-Po Battery Pack β powers the sensor node for portable operation.
 
βββ firmware/
β βββ sensor_node/ # Firmware for data collection setup with BME688
β βββ host_node/ # Firmware for USB host board
β
βββ user_guide/ # PDF guide (detailed setup, usage, ML workflow)
β
βββ README.md # Project overview & documentation
- Warm up sensor for 20 minutes before recording.
 - Capture 30-minute sessions for each coffee brand.
 - Use MPLAB Data Collector to log sensor data.
 - Import datasets into ML Model Builder for training.
 - AutoML pipeline used to find optimal features + model.
 - Best model achieved ~97% accuracy, with small memory footprint (<20 KB).
 
- Exported model as a Knowledge Pack.
 - Integrated into MCU firmware with simple API calls (
kb.h,kb_model_init()). - Flashed onto PIC32CX-BZ2 board using MPLAB X IDE.
 - Real-time predictions streamed to PC via MPLAB Data Visualizer.
 
- Fully embedded ML workflow (no cloud dependency).
 - Works on resource-constrained MCUs.
 - Portable, battery-powered setup.
 - Generalizable to multiple applications:
- Food authentication (spices, tea, wine).
 - Environmental monitoring (indoor air quality, VOC detection).
 - Industrial gas sensing and predictive maintenance.
 - Healthcare (VOC-based breath diagnostics).
 
 
