6103

This project introduces a simple GPIO button-based boot selector that lets you choose between a timelapse camera and a Bluetooth shutter camera simply by holding a button during power-up. The launcher automatically starts the selected application, eliminating the need to modify .profile or other system files for every project change. It’s an elegant, low-cost solution that can be extended to launch many different Raspberry Pi applications from a single SD card.

                                                              Raspberry Pi zero to boot by choice

Introduction: A wide range of projects have been successfully developed using the Raspberry Pi Zero platform, including a ChatGPT terminal, camera booth, language assistant, mobile hotspot-based web streaming system on VPN, speech interface modules, YouTube jukebox, timelapse photography system, and a Bluetooth-based shutter camera. Traditionally, enabling these applications to run at boot requires manual modification of system startup files such as .profile, which can be inconvenient when switching between different functionalities.


To address this limitation, a simple yet effective hardware-based selection mechanism has been implemented for the timelapse photography and Bluetooth shutter camera projects. The timelapse setup already utilizes three push-to-on buttons connected to GPIO pins 17, 27, and 22 (physical pins 11, 13, and 15 respectively). Leveraging this existing configuration, a launcher.py script has been developed that monitors the state of GPIO pins 17 and 27 during system startup. By pressing and holding one of these buttons at boot time, the system can selectively launch either the timelapse photography program or the Bluetooth shutter camera program.


Once the launcher.py script is configured, the .profile file is modified to invoke this launcher instead of directly calling any specific application. This approach eliminates the need for repeated manual edits to startup files and provides a user-friendly method to choose the desired mode of operation at boot time through simple button input.

……. launcher.py

import RPi.GPIO as GPIO 
import time
import os

#GPIO setup
BTN1=17# timelapse
BTN2 = 27# bluetooth shutter 
BTN3=22#optional/futureuse

GPIO.setmode(GPIO.BCM)

GPIO.setup(BTN1,GPIO.IN,pull_up_down=GPIO.PUD_UP)
GPIO.setup(BTN2, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(BTN3,GPIO.IN,pull_up_down=GPIO.PUD_UP)

time.sleep(2)#allowstabilization # Read buttons (pressed = LOW)
ifGPIO.input(BTN1)==0:
os.system("python3 /home/bera/timelapse_camera.py") elif GPIO.input(BTN2) == 0:
os.system("python3/home/bera/bluetooth_shutter.py")

else:
os.system("python3 /home/bera/timelapse_camera.py") GPIO.cleanup()
# .profile file

# Auto start timelapse/shutter
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then echo "SSH session detected - skipping autostart"
else
sleep 5
#python3 /home/bera/timelapse_camera.py python /home/bera/launcher.py
fi

Bye bye S Bera