This README is for the osmiaCAM build instructions and GreenHouse Osmia Block build instructions.
- osmiaCAM
- Camera Structure Build
- Labelling Nest Blocks
- Install Raspberry Pi software
- Change device ID
- Pi Connect
- Connecting cameras
- Check mounting location of external hard drive
- Preview camera (to test focus, framing, etc)
- Take a single full resolution photo
- Setting up RTC
- Clone this repository
- Make mount directory
- Install libraries for environmental sensors
- Install openCV library
- Add lines to the crontab
- Lighting
- Turn on GPIO pins
- Attaching LED Lights
- Testing
- Deployment
- Check videos
- GreenHouse Osmia Block
- Install Raspberry Pi software
- Change device ID
- Pi Connect
- Connecting cameras
- Check mounting location of external hard drive
- Preview camera (to test focus, framing, etc)
- Take a single full resolution photo
- Setting up RTC
- Clone this repository
- Make mount directory
- Install openCV library
- Add lines to the crontab
- Testing
- Deployment
- Check videos
- Install openCV library
- Laser Cut all pieces for OsmiaCam Structure build. Per Unit, you should have:
- 2 Large triangle walls
- 2 long side walls
- 2 door pieces (that attach to the long side walls - these are cut from the side walls
- 1 Camera Platform
- 1 Y-Shaped Brace
- 1 Camera Mount
- 8 Internal Triangle Braces
- Using acrylic glue, connect one Large triangle wall to one long side wall
- Use the small bracing triangle and line the seam between the connecting points of the long wall and side walls
- Repeat steps (2) and (3) with the remaining triangle wall and long wall
- Allow for the triangle walls and their connected long walls to set (using something to brace the connection between the side walls and long wall to keep the connection at a right angle as much as possible)
- Once dry, take one combined piece and lay it down so that the triangle wall is flat on a table and the long wall is standing up
- Adding acrylic glue to one side of the camera platform, fit the in tabs into the cut rectangles in the middle of the triangle wall
- Adding acrylic glue to one side of the Y-braces fit these pieces in the smaller rectangle openings on the bottom of
- Line the remaining connected pieces (triangle wall and long wall) and the top camera platform tabs and top y-brace tabs with glue
- Fit the second connected piece on top of the flat combined piece, sliding the camera platform tabs into the rectangular openings and the y-brace tabs in the smaller rectangular openings at the bottom.
- Let glue set
- Depending on the need to remove cameras, either pop the top piece with camera mounts onto the top of the structure or affix with glue
- Set the structure upright, and using tape, attach the long wall doors so that the door can hinge open and closed and have a handle/tab that you can use to open it.
- Label the structure with the username of its corresponding Raspberry Pi Unit.
- Your structure is built!
To help monitor and track which cells are in view and being used by bees, you will need to label the nest block entrances in two places
(1) At the nest entrance (so that the forage camera can view the labels)
(2) At a location that will be inside the nest structure and visible by the internal nest camera
Suggested labeling is at minimum every five cells.
Format SD card using Raspberry Pi Imager
This guide uses a raspberry pi 5, and the 64-bit OS.
Go to Raspberry Pi COnfiguration and provide a unique username when prompted. *NB user names should be labeled in a repeatable way (e.g., 'osmia1', 'osmia2') to easily associated with physical units. The user name will be saved in output files.
Click this:
Input the hostname of the pi as the name of your device when prompted.
Choose 'Turn On Raspberry Pi Connect'. The browser will open. Sign in, using the username of the pi as the device name.
You will now be able to connect to the raspberry pi here: https://connect.raspberrypi.com/devices
The nest camera should be connected as camera 0 and the external camera should be camera 1. The positions are indicated by CAM/DISP 0 and CAM/DISP 1 on the board of the raspberry pi:

run the following in terminal:
sudo fdisk -lThis will list mounted drives, and look for /dev/sda1 in last line. Hard drives must be mounted at sda1. Do not connect other hard drives to pi.
rpicam-hello -t 0 --camera 0 #you should see the nestrpicam-hello -t 0 --camera 1 #you should see the outsiderpicam-jpeg -o test.jpeg- Note: Requires access with internet
- Connect RTC battery to slot labelled 'BAT'
- check that clock is working with sudo hwclock -r
- Run this:
sudo hwclock --systohc
- Edit configurations,
sudo -E rpi-eeprom-config --editmodifying the two lines (if these variables do not exist, add them):POWER_OFF_ON_HALT = 1 WAKE_ON_GPIO=0 - After adding the lines, ctl+s will save. Then use ctl+x to leave.
git clone https://github.com/Crall-Lab/osmiaCAM.gitMove all contents of this repositoty into home directory ('~'). You can do it in the GUI, or input this into the terminal:
cp -rf osmiaCAM/* ~sudo mkdir /mnt/OsmiaCamIf folder exists, it will refuse to make the directory. Ignore it and move on.
sudo pip3 install --break-system-packages adafruit-blinka
sudo pip3 install --break-system-packages adafruit-circuitpython-ms8607
sudo pip3 install --break-system-packages adafruit-circuitpython-ahtx0cd ~
python3 -m venv osmia_2025
source osmia_2025/bin/activate
pip3 install opencv-contrib-pythonNow it's good to reboot:
sudo reboot -h nowOpen up crontab with the following command:
crontab -eChoose 1.
Then add the following lines to the bottom of the crontab file if they're not there already (to get permissions and mount directory for external hard drive)
@reboot sudo systemctl daemon-reload
@reboot sudo mount /dev/sda1 /mnt/OsmiaCam -o umask=000
@reboot sudo chmod 777 /mnt/OsmiaCam
*/10 * * * * /usr/bin/python dayShift1.py
*/3 * * * * /usr/bin/python dayShift0.py
@reboot /usr/bin/python nightShift.py
0 20 * * * /usr/bin/python nightShift.py
* * * * * /usr/bin/python3 envSensing.py >> envLog.txt 2>&1After adding the lines, ctl+s will save. Then use ctl+x to leave.
*NB if you want to use the camera (e.g, for preview, check focus, or to troubleshoot record.py script), turn off autoamted recording by commenting out that last line
Restart computer after updating crontab. osmiaCAM should run automatically after this.
sudo reboot -h nowIn order to use the relay module to control the lights automatically, the raspberry pi, relay, and lights must be connected properly. The images below illustrate pin/wire locations on the raspberry pi and relay module. To insert wires to the relay, use a screwdriver.
- Note that only the black ends should be soldered together.
The two wires coming from the relay can then be plugged into the lights and battery. The configuration does not matter.
Click on the raspberry --> settings --> Raspberry PI Configuration --> Interfaces --> turn on SPI and I2C
- Attach LED light wires to Screw Connector [Red is positive(+) and Black is negative (-)] To attach the wired to the screw connector loosen both screws and slide the correct wires into its corresponding slot and then using a screw driver tighten the screws so the wires are secure
- Line the path/areas over which the lights will lay using black (or blue) masking tape To diffuse the portions of lights that will line the camera mount (top of structure) use separate pieces so that if needed the camera mount pieces can slide off if needed.
- With the screw connector end starting at the base of the structure line the lights across the tape with the LED facing down securing with strips of tape We want there to be slack in the connection between the lights and the Pi, so start lining the lights to that the actual lights are starting on the structure and the wires are off the edge of the structure. The lights should run vertically up one side of the long wall across the top of the camera mount and down the opposite side wall; the lights should curve at the base of the long wall and then work back up vertically up and down the other sides of the side walls.
- Once lights are lining the structure, using duct tape, secure and cover the light path The tape should cover the lights, securing the LED light down to the structure To cover the portion of lights lining the camera mount (top of structure) use separate pieces so that if needed, the camera mount pieces can slide off if needed.
- Cut off the excess light string where needed
Restart and come back after 2 hours to check if expected files are in expected locations on hard drive. OsmiaCam should be created, with nestCam and ExtCam within. Each day will have each own folder within that. osmiaCAM will create 9 min 45 s video every 10 min of outside, 10s video of nest every 3 minutes during the day and every hour at night.
While deploying, it is advisable to check the focus of the camera and adjust as needed, even if the unit has been built and tested in the lab. However, if the above steps have been executed successfully, the normal functioning of the unit will interfer with this. To avoid this, edit the crontab:
crontab -eNow comment out the lines that refer to dayShift and nightShift scripts. It should look like this:
@reboot sudo systemctl daemon-reload
@reboot sudo mount /dev/sda1 /mnt/OsmiaCam -o umask=000
@reboot sudo chmod 777 /mnt/OsmiaCam
#*/10 * * * * /usr/bin/python dayShift1.py
#*/3 * * * * /usr/bin/python dayShift0.py
#@reboot /usr/bin/python nightShift.py
#0 20 * * * /usr/bin/python nightShift.py
* * * * * /usr/bin/python3 envSensing.py >> envLog.txt 2>&1Remember to uncomment these lines before actually deploying the unit. Note also that nightShift runs at startup and will put the unit to sleep after 10 seconds. If a unit must be deployed at night, edit the crontab during the day ahead of time.
Videos are recorded as .h264s, which are great for file sizes but a bit cumbersome to convert and view. We have written some utility functions to help out with this. First, for the nest and outside videos, a single frame from each video is now output automatically to check framing, etc Second, you can first convert 'raw' h264 videos to mp4 on the pi with the 'converth264.py' function, and then view them with the 'play_mp4.py' script. Here's an example:
First if you haven't already, create a virtual environment and install openCV
cd ~
python3 -m venv osmia_2025
source osmia_2025/bin/activate
pip3 install opencv-contrib-pythonThen run this in terminal:
cd ~
source osmia_2025/bin/activate
python3 converth264.pyThis will prompt you for a filename. The easiest way to get this when communicating over Raspberry Pi Connect is by navigating to the h264 file you'd like to view, selecting 'copy path' under 'Edit' in the file browser, then click 'copy from remote'. Then in the window prompt, click 'paste to remote' back in the Terminal window
After a few moments (maybe a couple minutes for full sized videos), there should now be an mp4 video with the same filename. To view this file, now run:
python3 play_mp4.pyThis will again prompt you for a filename, which now you'll have to add as the 'mp4' file, as above
source osmia_2025/bin/activate
cd ~/osmiaCAM
python3 playback_stills.pyFormat SD card using Raspberry Pi Imager
This guide uses a raspberry pi 5, and the 64-bit OS.
Go to Raspberry Pi Configuration and provide a unique username when prompted. *NB user names should be labeled in a repeatable way (e.g., 'osmia1', 'osmia2') to easily associated with physical units. The user name will be saved in output files.
Click this:
Input the hostname of the pi as the name of your device when prompted.
Choose 'Turn On Raspberry Pi Connect'. The browser will open. Sign in, using the username of the pi as the device name.
You will now be able to connect to the raspberry pi here: https://connect.raspberrypi.com/devices
The external camera should be camera 1. The position is indicated by CAM/DISP 1 on the board of the raspberry pi:

run the following in terminal:
sudo fdisk -lThis will list mounted drives, and look for /dev/sda1 in last line. Hard drives must be mounted at sda1. Do not connect other hard drives to pi.
rpicam-hello -t 0 --camera 1 #you should see nest block facerpicam-jpeg -o test.jpeg --camera 1- Note: Requires access with internet
- Connect RTC battery to slot labelled 'BAT'
- check that clock is working with sudo hwclock -r
- Run this:
sudo hwclock --systohc
- Edit configurations,
modifying the two lines (if these variables do not exist, add them):
sudo -E rpi-eeprom-config --editPOWER_OFF_ON_HALT = 1 WAKE_ON_GPIO=0 - After adding the lines, ctl+s will save. Then use ctl+x to leave.
git clone https://github.com/Crall-Lab/osmiaCAM.gitMove all contents of this repositoty into home directory ('~'). You can do it in the GUI, or input this into the terminal:
cp -rf osmiaCAM/* ~sudo mkdir /mnt/OsmiaCamIf folder exists, it will refuse to make the directory. Ignore it and move on.
cd ~
python3 -m venv osmia_2025
source osmia_2025/bin/activate
pip3 install opencv-contrib-pythonNow it's good to reboot:
sudo reboot -h nowOpen up crontab with the following command:
crontab -eChoose 1.
Then add the following lines to the bottom of the crontab file if they're not there already (to get permissions and mount directory for external hard drive)
@reboot sudo systemctl daemon-reload
@reboot sudo mount /dev/sda1 /mnt/OsmiaCam -o umask=000
@reboot sudo chmod 777 /mnt/OsmiaCam
*/10 * * * * /usr/bin/python greenHouse.pyAfter adding the lines, ctl+s will save. Then use ctl+x to leave.
*NB if you want to use the camera (e.g, for preview, check focus, or to troubleshoot record.py script), turn off autoamted recording by commenting out that last line
Restart computer after updating crontab. osmiaCAM should run automatically after this.
sudo reboot -h nowRestart and come back after 2 hours to check if expected files are in expected locations on hard drive. OsmiaCam should be created, with nestCam and ExtCam within. Each day will have each own folder within that. osmiaCAM will create 9 min 45 s video every 10 min of outside, 10s video of nest every 3 minutes during the day and every hour at night.
While deploying, it is advisable to check the focus of the camera and adjust as needed, even if the unit has been built and tested in the lab. However, if the above steps have been executed successfully, the normal functioning of the unit will interfer with this. To avoid this, edit the crontab:
crontab -eNow comment out the lines that refer to dayShift scripts. It should look like this:
@reboot sudo systemctl daemon-reload
@reboot sudo mount /dev/sda1 /mnt/OsmiaCam -o umask=000
@reboot sudo chmod 777 /mnt/OsmiaCam
#*/10 * * * * /usr/bin/python greenHouse.pyRemember to uncomment these lines before actually deploying the unit.
Videos are recorded as .h264s, which are great for file sizes but a bit cumbersome to convert and view. We have written some utility functions to help out with this. First, for the nest and outside videos, a single frame from each video is now output automatically to check framing, etc Second, you can first convert 'raw' h264 videos to mp4 on the pi with the 'converth264.py' function, and then view them with the 'play_mp4.py' script. Here's an example:
First if you haven't already, create a virtual environment and install openCV
cd ~
python3 -m venv osmia_2025
source osmia_2025/bin/activate
pip3 install opencv-contrib-pythonThen run this in terminal:
cd ~
source osmia_2025/bin/activate
python3 converth264.pyThis will prompt you for a filename. The easiest way to get this when communicating over Raspberry Pi Connect is by navigating to the h264 file you'd like to view, selecting 'copy path' under 'Edit' in the file browser, then click 'copy from remote'. Then in the window prompt, click 'paste to remote' back in the Terminal window
After a few moments (maybe a couple minutes for full sized videos), there should now be an mp4 video with the same filename. To view this file, now run:
python3 play_mp4.pyThis will again prompt you for a filename, which now you'll have to add as the 'mp4' file, as above



