This repository contains two main directories: multimedia_capture
and parameter_capture
.
multimedia_capture
is responsible for capturing audio, images, and videos, and transferring them to the server.parameter_capture
is responsible for capturing temperature, humidity, carbon dioxide, and weight parameters, and sending them to the server.
Before installing the necessary Python packages, ensure you have the correct operating system installed on your Raspberry Pi:
- For Raspberry Pi Zero 2W, use the 32-bit legacy (Bullseye) version of Raspberry Pi OS.
- For Raspberry Pi 4 models, use the 64-bit legacy (Bullseye) version of Raspberry Pi OS.
Whether you install the OS with the desktop environment enabled is up to you, depending on your project's requirements.
Follow these steps to set up the environment:
-
Install the necessary Python packages:
sudo pip3 install adafruit-circuitpython-dht paramiko sounddevice soundfile scipy sensirion_i2c_scd
-
Install the necessary system packages:
sudo apt install libgpiod2 portaudio19-dev gpac libopenblas-base
-
Update the configuration in
multimedia/config
with the correct values. -
Enable the Pi camera module:
sudo raspi-config
Navigate to
Interface Options > Legacy Camera
and enable it for Pi camera module v3. If you're using a lower version, disable it. Reboot your Raspberry Pi after this step. -
Activate the I2C Interface:
sudo raspi-config
Navigate to
Interface Options > I2C
and enable it. This step is crucial for projects that require communication with I2C devices. Reboot your Raspberry Pi to apply the changes. -
Set up the cron jobs:
crontab -e
Copy the cron jobs from
/support_files/cron.txt
and install them. Please note that these are just sample cronjobs and you have to chose the one most suitable for your current task. -
Insert the correct credentials in
measure_send_params.py
andsend_files_to_server.py
. -
Go to
config.py
and set the correct node ID. -
Setting up the Microphone (I2S MEMS Microphone Breakout - SPH0645LM4H):
Follow the tutorial at this link to set up the microphone.
-
Also add attribute pi_version and give it "2w", "0" depending on the version
-
Configure the weight sensor by following the tutorial at this link.
The Raspberry Pi will use the time from the RTC. Make sure the RTC has a battery to maintain the correct time. Follow the tutorial at this link incase even after running the commands below , the pi still wakes up and has incorrect time. This will be reflected in the timestamps of the data sent when the pi reboots and sends data.
- Update and upgrade your Raspberry Pi's package list and installed packages:
sudo apt-get update -y
sudo apt-get upgrade -y
- Install necessary packages for interfacing with the RTC module:
sudo apt-get install python3-smbus i2c-tools
- Edit the Raspberry Pi configuration to enable the RTC module. Open the configuration file:
sudo nano /boot/config.txt
Then add one of the following lines to the end of the file, depending on the RTC chip you are using:
dtoverlay=i2c-rtc,ds1307
or
dtoverlay=i2c-rtc,pcf8523
or
dtoverlay=i2c-rtc,ds3231
- Remove the
fake-hwclock
package and disable its service to prevent conflicts with the real RTC:
sudo apt-get -y remove fake-hwclock
sudo update-rc.d -f fake-hwclock remove
sudo systemctl disable fake-hwclock
- Edit the
hwclock-set
script to ensure the system clock is correctly synchronized with the RTC at boot. Open the file:
sudo nano /lib/udev/hwclock-set
When the file opens, delete all its contents and replace with the following script:
#!/bin/sh
# Reset the System Clock to UTC if the hardware clock from which it
# was copied by the kernel was in localtime.
HWCLOCKDEVICE="/dev/rtc0"
if [ -e /etc/default/hwclock ] ; then
. /etc/default/hwclock
fi
if [ yes = "$BADYEAR" ] ; then
/sbin/hwclock --rtc=$HWCLOCKDEVICE --systz --badyear
/sbin/hwclock --rtc=$HWCLOCKDEVICE --hctosys --badyear
else
/sbin/hwclock --rtc=$HWCLOCKDEVICE --systz
/sbin/hwclock --rtc=$HWCLOCKDEVICE --hctosys
fi
# Note 'touch' may not be available in initramfs
# /run/udev/hwclock-set
- Finally, write the current system time to the RTC to ensure it starts with the correct time:
sudo hwclock -w
```****