- Successful build and stable boot of Android Automotive 14 on Raspberry Pi 5.
- Developed a CCTV camera setup using Raspberry Pi 4.
- Built an app for Android Automotive 14 which streams live CCTV footage from anywhere when motion is detected.
- A 64-bit x86 system, preferably Ubuntu 18 and above. Multiple core CPU results in faster builds.
- At least 400 GB of free disk space to check out and build the code (250 GB to check out + 150 GB to build).
- Minimum 32GB RAM. Increase the swap size to 32GB on Ubuntu using this guide.
- Stable, unrestricted, and fast internet.
- Raspberry Pi 5 and SD card of minimum 16GB in size.
-
Establish Android build environment and install repo. Follow instructions here.
-
Install additional packages:
sudo apt-get install bc coreutils dosfstools e2fsprogs fdisk kpartx mtools ninja-build pkg-config python3-pip sudo pip3 install meson mako jinja2 ply pyyaml dataclasses
-
Initialize repo:
mkdir WORKING_DIRECTORY cd WORKING_DIRECTORY repo init -u https://android.googlesource.com/platform/manifest -b android-14.0.0_r22 curl -o .repo/local_manifests/manifest_brcm_rpi.xml -L https://raw.githubusercontent.com/raspberry-vanilla/android_local_manifest/android-14.0/manifest_brcm_rpi.xml --create-dirs
Chose
android-14.0.0_r22
because it was the most stable amongst the rest. -
Sync source code (i.e., download):
repo sync -j4
Uses 4 cores to download; adjust accordingly.
-
Setup Android build environment:
. build/envsetup.sh
-
Select the device:
lunch aosp_rpi5_car-ap2a-userdebug
-
Compile:
make bootimage systemimage vendorimage -j$(nproc)
By default, uses all cores. Adjust accordingly; more cores = faster build.
-
Make flashable image for the device:
./rpi5-mkimg.sh
This should create a bootable image file of size 7GB.
You can find my build image of the above here: ---
-
Download the Raspberry Pi imager and follow the instructions to flash the image onto the sdcard. Use the sd card to boot up the Pi5.
You can find full guide for other builds like android, android tv, android automotive for both rpi4 and rpi5 here
- UI provides a buttton to toggle between D(Drive) or P(Park) mode.
- The app receives the URL from the CCTV whenever its hosted and notifies about it.
- Driver can stream the url with a stream button if vehicle is in park mode.
- Whenever motion is detected on the CCTV, a notification is popped with 2 options, ignore and stream.
- To stream the URL the toggle needs to be in P mode otherwise D mode alert is given via notification.
- Android Studio with required SDKs installed.
- Pushy API account.
-
Use Android Studio and set it up for development, create a new project.
-
Setup API:
- Go to the Pushy API dashboard and create an app.
- Name it same as the project/app name in Android Studio.
- Enter the package name wherever prompted.
- Make a note of secret api key from the application section.
-
Setup API in the app and develop the app:
- All these steps are done and you can find the codes above.
- Copy all the files in your project directory accordingly.
- Change the package name to your app name wherever needed(thirdeyecar here).
- Follow Pushy docs to setup the client.(done above)
-
Connect the Raspberry Pi 5 with ADB wirelessly to deploy apps:
- Make sure your development machine/PC having Android Studio and Raspberry Pi 5 are on the same network.
- Open terminal and type
adb connect <ip_address_of_pi5>
- You can find ipaddress of pi5 from the WiFi settings in android settings of the device itself.
- Android Studio will automatically detect the device, and you are now ready to deploy apps.
-
Run the app.
- This will generate a device token. Take note of this since it is used for communication with the CCTV. It changes if you uninstall and reinstall the app. It does not change for every run in the studio.
- For the first run you will get a device token , take a note of this. This can also be found in the adb logcat in Android Studio.
This section outlines the steps to setup a CCTV system using a Raspberry Pi 4, allowing it to stream live footage, detect motion, and integrate with an Android Automotive 14 app.
- Streams live CCTV footage from Raspberry Pi 4.
- Detects motion and sends notifications to the Android Automotive app.
- Allows remote access and streaming via Ngrok.
- Integrates with the app using Pushy API for secure communication.
- Hardware:
- Raspberry Pi 4 with Raspbian OS installed.
- USB Webcam.
- MicroSD Card (at least 16GB) with Raspbian OS.
- Power Supply for Raspberry Pi 4.
- Stable internet connection.
- Monitor, Keyboard, Mouse.
- Software:
- Motion software for video streaming and motion detection.
- Ngrok for secure remote access.
- Pushy API for notificaton management.
Motion is the key software used for turning the Raspberry Pi into a surveillance camera.
-
Update and Upgrade Raspberry Pi:
sudo apt-get update sudo apt-get upgrade
-
Install Motion:
sudo apt-get install motion
-
Configure Motion:
- Open the Motion configuration file:
sudo nano /etc/motion/motion.conf
-Key configurations to update:
daemon on stream_localhost off stream_port 8081 videodevice /dev/video0 on_motion_detected curl -X POST "https://api.pushy.me/push?api_key=your_secret_api_key" -H "Content-Type: application/json" -d '{"to":"your_device_token","data":{"message":"Motion Detected!"}}'
Replace "your_secret_api_key" with your actual Pushy API secret key and "your_device_token" with the device token from your Android Automotive app. For further Motion config file setup refer here.
-
Start Motion Service:
sudo systemctl start motion
To check motion log
sudo systemctl status motion
Ngrok allows remote access to your CCTV stream from anywhere. -Should be done in a new terminal.
- Install Ngrok:
- Download and install:
wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm.zip unzip ngrok-stable-linux-arm.zip sudo mv ngrok /usr/local/bin/
- Authenticate Ngrok:
- Obtain your authentication token from Ngrok's website and run:
ngrok authtoken <your_auth_token>
- Start the Ngrok Tunnel:
ngrok http 8081
-This will provide a public URL for remote access.