MED4PEST aims to develop proven and effective Ecologically Based Rodent Management (EBRM) methods and products that can be readily integrated into local pest/invasive rodent management systems in Mediterranean countries. This initiative contributes to the shift from synthetic pest control to biological and ecological pest management, ultimately fostering eco-sustainable farming systems, enhancing crop production quality and quantity, and optimizing ecosystem health inputs. The MED4PEST objectives and goals will generate new knowledge through scientific research conducted in collaboration with consortium partners from two universities, two research institutes, and one company. MED4PEST
The device collects data on temperature, humidity, sound, low frame rate video, and weight.
- Raspberry Pi 4
- Raspberry Pi Night Vision Camera
- M500-384 USB Ultrasound Microphone (Pettersson)
- Ultrasonic Distance Sensor - HC-SR04 (5V)
- SHT30 Temperature and Humidity Sensor (Waterproof)
- RadarIQ-M1 VISION Sensor (Additional)
Step 1: Download the Raspberry Pi Imager.
Step 2: Prepare the microSD Card.
-
Insert the microSD card into your computer’s card slot or into a USB card reader.
-
Open the Raspberry Pi Imager.
-
Click on "CHOOSE OS" and select the version of Raspberry Pi OS you prefer (e.g., Raspberry Pi OS Full, Raspberry Pi OS Lite for a headless setup, etc.).
-
Click on "CHOOSE SD CARD" and select your microSD card from the list.
-
Click on "WRITE" and wait for the process to complete. This will erase everything on the microSD card.
Note: For standard practice, follow the instructions below:
- In the Hostname field, type 'spyce'.
- For the Username, enter your favorite spice (e.g., pepper, cumin, oregano, etc.).
- Enter a password.
- Enter the WiFi SSID and password (required for connecting to the Raspberry Pi in headless mode, i.e., via terminal).
-
With a Monitor: This is the simplest method and is recommended for beginners. Connect a monitor, keyboard, and mouse to work with the Raspberry Pi as a desktop setup.
-
Using a Capture Card.
-
Via SSH: This is the most efficient way to work with the Raspberry Pi. You can access the device without connecting any extra peripherals.
Syntax:
ssh [email protected] ssh [email protected] # Example ssh [email protected] # ExampleNote:
- For SSH connections to work, both devices need to be on the same network, typically due to network firewalls or security configurations. For remote access, consider using remote.it.
- Consider using VSCode to connect to the raspberry pi (using SSH extension) VSCode-SSH.
-
Edit Raspberry Pi COnfigurations.
sudo raspi-configIn configuration,
- Advance Option > Expand Filesystem (Ensures that all of the SD card is available)
- Interface Option > Legacy Camera > Enable
- Interface Option > SSH > Enable
- Interface Option > VNC > Enable
- Interface Option > I2C > Enable
- Interface Option > Serial Port > Enable
- Interface Option > Remote GPIO > Enable
-
Reboot the Rapberry Pi
-
Create a mount point : Create a folder where you want to mount your HDD.
sudo mkdir -p /path/to/create/new_folder Ex: sudo mkdir -p /home/pepper/data-storeThis will create a folder in the give path.
-
Identify the drive : Connect the HDD and run below command to the list block devices.
lsblkLook for your device, usually named something like /dev/sda1 for the first partition on the first detected USB HDD.
-
Get UUID of HDD partition.
blkidLook for UUID of your device.
-
Auto-mounting using fstab.
sudo nano /etc/fstab -
Add below line to fstab.
UUID=your-uuid-here /mnt/myhdd auto defaults,nofail 0 0 example: UUID=B696844C96840F55 /home/pepper/data-store auto defaults,nofail 0 0 -
Reboot RPi to mount or run sudo mount -a
List of Dependencies:
- Adafruit-sht31d
- Board
- Numpy
- PyAudio
- OpenCV
- Sounddevice
- Soundfile
- Simpleaudio
- Scipy
To install the dependencies, follow the steps below:
-
Clone the repository:
git clone https://github.com/superworld-cyens/MED4PEST.git Folder structure: /MED4PEST ├── spyce-code │ ├── calibarate │ └── config ├── spyce-resource ├── spyce-setup └── README.md -
Update and upgrade the Raspberry Pi:
sudo apt-get update sudo apt-get upgrade -
Install the virtual environment, create a Python virtual environment, and activate it:
sudo apt-get install python3-venv # Install Python virtual environment package python -m venv .spy # Create a virtual environment with any name source .spy/bin/activate # Activate the virtual environment -
Install dependency packages:
sudo apt-get install build-essential cmake git pkg-config libjpeg-dev libtiff5-dev libpng-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libfontconfig1-dev libcairo2-dev sudo apt-get install libhdf5-dev libhdf5-103 sudo apt-get install libopenblas-dev sudo apt-get install libgtk2.0-dev pkg-config sudo apt-get install -y i2c-tools sudo apt-get screenNote: Ensure that the above dependency packages are installed correctly without any errors.
-
Install requirements:
pip install -r spyce-setup/requirements.txt -
$chmod +x spyce-setup/setup.sh # Make the file executable ./spyce-setup/setup.sh # Execute the script -
Verifying Test Dependencies Installation:
After installing the packages listed in
requirements.txt, verify the installation by executing the following script:python spyce-setup/check_dependencies.pyThis script checks each package and reports any issues with the installation process.
-
Troubleshooting Installation Issues:
For troubleshooting advice and common solutions to installation issues, please refer to the FAQ section at the end of this document.
-
Navigate to code folder
$cd spyce-code -
Update configuration setting on config.json
"sensors": {"camera" : true, "audio" : true, "humtemp" : false, "weight" : false} "settings": {"mode": 0, "debug": true, "record_time": 5, "comment": "Mode 0 for PIR trigger, 1 for USS trigger, 2 for Camera trigger", "output": "/home/pepper/data-store/testdata"} "camera": {"fps":3, "imageWidth":512, "imageHeight":512} "audio": {"samplerate":384000, "channel":1, "comment": "Check if USB microphone is connected: arecord -l" }, "pir": {"Data":13} "usv": {"Trigger":7, "Echo":11} -
To run the code it is adviced to use terminal multiplexer.
Note: Multiplexer allows users to start a screen session and then open any number of virtual terminals (or "windows") inside that session. Processes that run in Screen will continue to run when their window is not visible and even after the user disconnects.
$screenRun the code
python main.py
-
Pip Installation Error:
- Error:
externally-managed-environment - Reason: Installation conflict between
aptandpippackages. - Solution: Install the packages inside a Python virtual environment.
- Error:
-
When activating the virtual environment:
- Error:
'bash:/path/bin/activate: permission denied'. - Reason: The 'activate' script is not executable.
- Solution: Make it executable.
- Error:
-
OpenCV not installed:
- Error: OpenCV cannot be installed using Pip due to compatibility issues.
- Solution: Install OpenCV from the source file.
-
While importing cv2, Numpy version error
-
Error: Please note and check the following:
- The Python version is: Python3.9 from "/usr/bin/ python"
- The NumPy version is: "1.26.4"
- from .cv2 import * ImportError: numpy.core.multiarray failed to import
-
Solution: pip3 install --upgrade pip, pip3 install --force-reinstall numpy
-
We would like to thank the following contributors for their help with this project:
- Chirag Padubidri
- Shrasti Dadhich
- Andreas Kamilaris
