The ML model is made on a very simple, convenient yet powerful platform Edge Impulse.
Description of Components
The SparkFun Environmental Combo Breakout boards described below are used to get PHT, CO2, VOC etc. environmental data. This environment data is further transmitted by using the LoRa RYLR896 module for further analysis.
SparkFun Qwiic Environmental Combo Breakout Board – CCS811/BME280 helps determine:
- Total Volatile Organic Compound (TVOC) sensing from 0 to 1,187 ppb
- eCO2 sensing from 400 to 8,192 parts per million
- Temp Range: -40C to 85C
- Humidity Range: 0–100% RH, =-3% from 20–80%
- Pressure Range: 30,000Pa to 110,000Pa, relative accuracy of 12Pa, absolute accuracy of 100Pa and many more.
SparkFun (SparkX) Qwiic Pressure/Humidity/Temp (PHT) Sensor – MS8607 features:
- Temp Range: -40 to 85°C
- Humidity Range: 0 – 100%
- Pressure Range: 10 – 2000mbar
The Himax WE-I Plus EVB Board
The Himax WE-I Plus board was chosen for its Compact Size, Ultra-low Power Application, High Resolution HM0360 AoSᵀᴹ VGA Camera and Powerful AI-based object recognition capabilities. Himax WE-I Plus board available at: https://www.sparkfun.com/products/17256
The board also features a 3-axis accelerometer, 2x microphones (L/R), 2x user LEDs (RED/GREEN), An I2C master and 3x GPIOs expansion headers and many more.
Make the Hardware connections between the Himax WE-I Plus and the SparkFun Environmental Combo Board as shown in the image. Connections the will be same for the MS8607 sensor board.
|Red||3.3V||J3 Pin 1|
|Yellow||SCL||J3 Pin 5|
|Blue||SDA||J3 Pin 6|
|Black||GND||J3 Pin 7|
And between the Himax WE-I Plus and LoRa as
|Orange||3.3V||J3 Pin 1|
|Green||WEI TXD \ LoRa RXD||J3 Pin 2|
|Red||WEI RXD \ LoRa TXD||J3 Pin 3|
|Black||GND||J3 Pin 7|
LoRa models used here are REYAX RYLR896 [LoRa AT command guide]
Setting up the Prerequisites
First of all download/clone and extract the application GitHub Repository from: https://github.com/HimaxWiseEyePlus/WE_I_Plus_User_Examples/tree/main/SmartAgriculture-example
This will be your main work directory for this application.
You’ll notice that a ‘settings.h’ file exists in which we can set exactly which sensor board we are using i.e. either SparkFun Qwiic Environmental Combo Breakout Board – CCS811/BME280 or SparkFun (SparkX) Qwiic Pressure/Humidity/Temp (PHT) Sensor – MS8607.
Next, Docker is required to compile the custom made application model.
A flash tool is also required to burn the generated .img file to the board for which you can use:
- Serial Terminal Emulation Application – Burn application to flash by using xmodem send application binary. Choose the one that suits your OS.
The application output can also be viewed here by the HIMAX WE1 EVB Debug UART port.
- Using Edge-Impulse-CLI Himax flash tool – This tool comes with Edge-Impulse-CLI and just a firmware path needs to be mentioned. The Edge-Impulse-CLI also includes an Impulse runner for a studio built library and a Data forwarder for numeric output.
Note: To deploy the Already Compiled Application (for CCS811/BME280 sensor board) skip directly to the Flash Image section. However, to achieve greater accuracy, it is recommended to follow the complete procedure.
ML Model on Edge Impulse
Refer the Getting Started with Himax WE-I Plus EVB Endpoint AI Development Board article to set up Edge-Impulse and to connect the Himax WE-I Plus board.
Step 1.1: Data Acquisition
In the data acquisition step, either you can record new data using the board or use an existing database for the model. Here, we used an agriculture crop images dataset from https://www.kaggle.com/aman2000jaiswal/agriculture-crop-images?select=kag2
Step 1.2: Impulse design for Himax WE-I Plus EVB Board
This should be the impulse design
Input Image data
- Image width = 96
- Image height = 96
- Resize mode = Squash
- 3 (Maize, Sugarcane, Wheat)
Make sure you choose grayscale color depth in the impulse design image tab.
Complete generate features and transfer learning tabs
You can also perform live classification and check the model before deployment.
Step 1.3: Deploy the model
In the deployment section, Select the Quantized(int8) C++ library using EON™ Compiler. Click Build.
This will download a zip file. Extract and copy these files in the main work directory. Make sure you do not copy the CMakeLists.txt
The main work directory should now look like this:
Open a terminal window in the main work directory and run the following Docker commands.
|sudo docker build -t himax-build-gnu -f Dockerfile.gnu .|
|mkdir -p build-gnu
sudo docker run –rm -it -v $PWD:/app himax-build-gnu /bin/bash -c “cd build-gnu && cmake -DCMAKE_TOOLCHAIN_FILE=toolchain.gnu.cmake ..”
|sudo docker run –rm -it -v $PWD:/app:delegated himax-build-gnu /bin/bash -c “cd build-gnu && make -j && sh ../make-image.sh GNU”|
Please run these commands line by line.
This process may take some time for the first run.
The Generate Image Done message at the end marks the completion of the process.
Note: To built for another sensor board, make corresponding changes in ‘settings.h’ file and follow from this step again.
Flash Image to Himax WE-I Plus Board
The file in .img format that needs to be flashed to the board will be stored in image_gen_linux folder as out.img
The last step is to flash this .img file for which you can use any flash tool described in the prerequisites section.
Here, we used the himax-flash-tool on edge-impulse-cli as it was installed on the Windows OS.
Output of Application
The output as seen on TeraTerm software by listening to the serial port.
- L.H.S – Sender (Himax WE-I Plus Board)
- R.H.S – LoRa Receiver
- LoRa Sender module (connected to Himax WE-I Plus Board) has Address = 1
- LoRa Receiver module has Address = 2
With SparkFun Qwiic Environmental Combo Breakout Board – CCS811/BME280 :
The format of Receiver data is Co2 Value|Temperature|Humidity|Pressure
Here the [maize] crop is seen to be accurately detected.
With SparkFun (SparkX) Qwiic Pressure/Humidity/Temp (PHT) Sensor – MS8607 :
The format of Receiver data is Co2 Value(always 0000)|Temperature|Humidity|Pressure
The PHT data is obtained
Video demonstrating the application:
Thus, creating a Smart Agriculture Application using Himax WE-I Plus which obtains farm environment data from sensor boards for agricultural analysis. The ML model used in this application is for basic crop detection. The same can be extended to weed detection or to perform certain tasks or agricultural activities with combined input from Environmental sensors.
Check out some more interesting applications using Himax WE-I Plus EVB Endpoint AI Development Board here.
Jayesh Rajam is a tech enthusiast who loves to design and test various circuits. Amazed by the development and miniaturization in the IoT field, he wishes to bring efficacy to the design and development of tech projects. He has hands-on experience with various Simulation and Design Software. He also plays and learns Indian Classical music and do some Content creation in his free time.