This application demonstrates an EnviroSense AI system for real-time environmental condition classification using a VEML7700 Ambient Light Sensor (ALS) and a BME680 sensor for temperature and humidity measurement. The sensor readings are continuously acquired over I2C and used as inputs to an embedded SensiML-trained machine learning model running on the microcontroller.
The demo supports both data monitoring and machine learning operation. In one configuration, raw ALS, humidity, and temperature values can be streamed to a host PC for real-time graph plotting and analysis. In the machine learning configuration, the sensor readings are grouped into fixed windows and processed locally on the device to classify the surrounding environmental condition into one of the several labels: Cool_Humid, Humid, Normal, Rainy, Sunny, or Unknown. The measured sensor values and the corresponding classification result are also displayed on an external graphical display for direct user observation.
This demo provides a compact platform for evaluating edge AI in environmental sensing applications through sensor interfacing, live data collection, visualization, on-device inference, and environmental condition classification.
-
Peripheral Modules
- PORT
- SERCOM0 - I2C
- SERCOM1 - UART
- SERCOM5 - I2C
- EVSYS
- EIC
- TCC0
- TCC9
- EBI
-
Board Support Packages
- PIC32CZ CA90 Curiosity Ultra BSP
-
Drivers
- I2C Driver
-
System Services
- Time
- CONSOLE
- DEBUG
- Input System Service
-
Middleware libraries
- Harmony Core
-
Graphics
- GFx Core LE
- LE LCC
- Legato Graphics w/ PDA TM4301B Display
- Max Touch Controller
- PDA TM4301B
- Legato
- PIC32CZ8110CA90208 Product Page
- PIC32CZ8110CA90208 Code Examples on Discover
- PIC32CZ8110CA90208 Code Examples on Github
- Online Documentation of this Demo
- MPLAB® X IDE v6.30 or newer
- MPLAB® XC32 Compiler v5.10 or newer
- MPLAB® Harmony v5.8.4
- MPLAB® Code Configurator (MCC) v5.6.4 or newer
- Microchip PIC32CZ-CA90 Series Device Support v1.7.168 or newer
- CSP v3.25.1
- CORE v3.16.1
- CMSIS_5 v5.9.0
- MCC Core v5.8.4
- PIC32CZ CA90 Curiosity Ultra Development Board
- BME680 Sensor
- Ambient Light Sensor
- Transparent Shoe Storage Box
- Humidifier
- Peltier Module
- Cooling System
- Motor Speed Regulator
- Power Supply
- Proto Click
- 565 LCD ADAPTER GRAPHICS CARD
- HIGH-PERFORMANCE 4.3" WQVGA DISPLAY MODULE WITH MAXTOUCH® TECHNOLOGY
-
Connect a pull-up resistor of 5.1 kOhm between the DISP test point to 3.3V of the 565 Adapter Board. For more information, refer to this article
-
Connect the Peltier Module onto the Cooling System
-
Connect one Motor Speed Regulator to Power Supply and Fan
-
Connect another Motor Speed Regulator to the power supply and to the Peltier module (Cooling system)
-
Solder the BME680 sensor and the Ambient Light sensor onto the ProtoClick
| BME680 wire | ProtoClick pin |
|---|---|
| Red | VCC |
| Black | GND |
| Yellow | SDA |
| Green | SCL |
Figure 4. MikroBUS - Sensor Interface
-
Mount the Modified Protoclick (with ALS and BME680) on the Arduino extension on the PIC32CZ CA90 Curiosity Ultra Evaluation Board
-
Assemble the chamber with all the hardware
-
Place the Humidifer and the Cooling system inside the chamber
-
Place the power supply, motor speed regulators, PIC32CZ CA90 Curiosity Ultra Evaluation board and the graphics display (High-Performance 4.3" WQVGA Display Module with MAXTOUCH® Technology)
-
-
Connect the WQVGA display module to the PIC32CZ CA90 Curiosity Ultra Evaluation board, using the GFx connector, as shown below.
- 1 - Graphics Connector
- 2 - Modified ProtoClick
- 3 - Motor Speed Regulator 1 (for Fan control)
- 4 - Motor Speed Regulator 2 (for Peltier control)
The pre-built .hex file can be programmed by following the steps below:
- Open MPLAB® X IDE
- Close any opened projects in IDE
- Go to File > Import > Hex/ELF File
- In the Import Image File window, at Step 1 - Create Pre-built Project, click the Browse button to select the pre-built .hex file.
- Select Device - "PIC32CZ8110CA90208"
- Ensure the proper tool is selected under Hardware Tool
- Click the Next button
- In the Import Image File window, at Step 2 - Select Project Name and Folder, select the appropriate project name and folder
- Click the Finish button
- In MPLAB® X IDE, click the Make and Program Device button. The device will get programmed in short time.
- Follow the steps in the Running the Demo section below.
- Open the Data Visualizer plug-in in MPLAB X IDE. The connected COM port will be displayed under Serial Ports, in the Connections section
Figure 7. Opening Data Visualizer
Figure 8. MPLAB Data Visualizer Interface
- Click New variable streamer, as shown below
Figure 9. Serial Port Stream Setup
- Configure the Variable Streamer name, all the required variables and the corresponding type of the variables, as shown below
Figure 10. Variable Streamer Configuration Panel
- Select New axis per variable in the How to Plot section to visualize the above three parameters in a separate axis
Figure 11. Variable Plot Selection Options
- The plotted values can be seen in the Time Plot section
Figure 12. Live Sensor Data Plot
- The timeline can be zoomed in or out, as shown below. In this example, the timeline is 80s.
Figure 13. Time Window Zoom Controls
- Click the location symbol to add a vertical cursor to the graph (two vertical cursors need to be added)
Figure 14. Vertical Cursor Tool
- The vertical cursors can be kept in the below mentioned positions
Figure 15. Dual Cursor Measurement View
**Note:** The position of the vertical cursors determines the number of samples collected.
- Click the below mentioned icon to collect data
Figure 16. Data Snapshot Export Control
- The below window mentions the duration by window start and window end timelines
Figure 17. Snapshot Source Selection Panel
- Uncheck the Include timestamps and Allow scientific notation under CSV options and Data value format, respectively. Also change the Sample lines to 100.
Figure 18. CSV Snapshot Format Settings
-
Save the collected .CSV file to your computer.
Note: Collect as many samples as possible; the more samples, the more training for the model, increasing thus the accuracy.
-
After collecting all the data samples, open the ML Suite in MPLAB X IDE and login into ML Suite
-
The home page for the MPLAB ML Model Builder is shown below
Figure 19. Opening MPLAB ML Suite
Figure 20. ML Builder Dashboard
- Click Create Project to create a new model to train
- Click the below highlighted icon to open the Project
Figure 23. Opening the Enviro Sense Project
- The main page for the Enviro_Sense model will look as shown below
Figure 24. Enviro Sense Project Overview
-
Go to Project Settings under Project Summary and add labels as shown below
- Click Add Label to add a label as shown below
Figure 25. Adding New Segment Labels
Figure 26. Creation of a Label
- Add the required labels for the model to train
Figure 27. Viewing Segment Label List
- Go to Data Manager and import all the collected data samples (.CSV files)
Figure 28. Importing Sensor Capture Data
Figure 29. Choosing Capture File Upload
Figure 30. Confirmation of Uploaded Capture Files
Figure 31. Completing Capture File Import
- Open a .CSV file and click the + or + Create icon to select which part of the graph must be used to add a segment of data
Figure 32. Creation of a Data Segment
Note: This segment tells the model the particular data to be considered in order to train the model
- Select the appropriate label for the segmented data and click Save to save the particular segment of data
Figure 33. Selecting Segment Label Category
Note: In this example project, 100 samples are taken in each of the .CSV files; the number of samples can be customized, it does not need to be 100.
-
Do the same for all the collected data sets.
-
Once the segments have been created for all the collected data sets, go to Prepare Data and click Create Query to create a query.
Figure 34. Opening Prepare Data Page
- Configure the query as shown below and click Save
Figure 35. Creating a Data Query
- Click Rebuild as shown below and check if the status is Cached
Figure 36. Viewing Cached Query Status
- Click Build Model and select Create Pipeline
Figure 37. Creating a Model Pipeline
- Click Next, enter the pipeline name and query and click Create Pipeline
Figure 38. Selecting Pipeline AutoML Option
Figure 39. Creating EnviroSense Pipeline
- Follow the steps shown in the below images:
Figure 40. Reviewing Pipeline Creation Settings
Figure 41. Configuring Windowing Segmenter
Figure 42. Feature Extraction Methods
-
Once the configuration of the pipeline has completed, click Run Pipeline
-
Once the pipeline run has completed successfully, five models will be generated as shown below.
Figure 43. Pipeline Training Results
- Next, go to Explore Model and download the model with highest accuracy and with PME classifier
Figure 44. Model Selection for Download
- Click MPLAB XC 32 and Select
Figure 45. MPLAB XC32 Target Selection
- Choose the processor used (PIC32CZ8110CA90208, in this case) and click Download
Figure 46. Knowledge Pack Download Settings
- Follow the below steps for downloading the knowledge pack file
Figure 47. Inference Folder Save Location
Figure 48. Knowledge Pack Add Prompt 1
Figure 49. Knowledge Pack Add Prompt 2
- In MPLAB X IDE, go to Projects > Firmware > Inference and check whether the Knowledge Pack .zip file is available. If it is not available, copy the downloaded Knowledge Pack .zip file into Created Project > Firmware > Inference.
Figure 50. Knowledge Pack Files Menu
Note: Rename the .zip file to "knowledgepack"
-
Extract the contents of the knowledge pack file and delete the original .zip file, retaining only the extracted files for clarity.
-
In MPLAB X IDE, under Projects, right click Header Files and do the following steps:
Figure 51. Existing Items Folder
Figure 52. Source File Folder Dialog
Figure 53. Header Folder Selection Window
Figure 54. Project Source Folder List
- Do the same for Source Files too, but change the file type, as shown below:
Figure 55. C Source Folder Selection
- Right click Libraries, and then click Add Library/Object File
Figure 56. Library and Object File Menu
- Go to Project > Firmware > Inference > Knowledge Pack > Firmware > mplabm > Lib > libmplabml.a and add the libmplabml.a file.
Figure 57. Library Object File Selection
- This is how the file structure will look like once the knowledge pack files and library files have been added
Figure 58. Folder Structures after adding the Knowledge Pack Files
Note: The empty folders from the knowledge pack file can be removed by right clicking on those particular files and selecting Remove From Project.
Figure 59. Library Folder Removal Menu
- Once all the above steps are completed, the output will be displayed as shown below.
Figure 60. Output - Cool_Humid
The EnviroSense AI demo integrates environmental sensors, embedded machine learning, data streaming, and graphical visualization on a Microchip platform to enable real-time environmental condition monitoring and classification. By using the VEML7700 Ambient Light Sensor and BME680 for temperature and humidity sensing, the system captures live environmental data and applies an on-device SensiML-trained model to classify conditions such as Cool_Humid, Humid, Normal, Rainy, Sunny, and Unknown. Its modular software structure supports both raw data visualization and embedded inference, while external display integration improves the user interaction and system observability. This makes the demo a practical foundation for edge AI development in smart environmental monitoring and intelligent sensing applications.








