Alien Motion Tracker Build

Raspberry Pi Configuration

Raspberry Pi Configuration

Disclaimer

This guide is provided for informational and educational purposes only. While every effort has been made to ensure accuracy, the author accepts no responsibility for errors, omissions, or outcomes resulting from the use of this material. Building, soldering, programming, and operating electronic devices involve risks that include but are not limited to electric shock, burns, fire, or equipment damage. By following this guide, you assume full responsibility for your safety, your tools, your materials, and the final device. Always follow appropriate safety practices and proceed at your own risk.

NOTE: If you get a VERY SLOW FRAMERATE then you are being throttled. See power throttling

On this page you can find setup instructions on how to create a fresh Raspberry Pi disk image, add all the required components, and finally install the motion tracking software. It's fairly easy to do.
If you want a quick alternative, then you can download a pre-made image instead (unzip and write to 32G SD card). This image may need the motion tracker code updating to the latest version. To do this, delete the "alienmotiontracker" folder in the home directory, then repeat step 9.

NOTE: Before starting this, you will need to have soldered everything up first! Otherwise you won't be able to test it.

Installation Steps
  1. Download and Install the Raspberry Pi Imager
  2. Write a fresh Pi image to a 32G or larger SD Card.
    • Set HostName to raspberrypi
    • Set Username and Password to alien


  3. Insert card, and boot the pi.
  4. Connect the Pi to Wifi or Ethernet using the menu in the top right corner
  5. Install all updates and reboot

  6. Configure PI for IO: First via the Raspberery Pi Configuration utility, then in Interfaces, enable SSH, VNC, SPI and I2C.
    Next open a bash/command prompt and type:
    sudo raspi-config

    Then: Goto "Interface Options" and enable SSH, VNC, SPI and I2C again, just to be sure
    Goto "Advanced Options" and choose Expand Filesystem
    Exit and reboot.

  7. Open a bash/command prompt and enter the following commands in order. This will take some time:
    sudo usermod -a -G spi,gpio,i2c alien sudo apt-get update sudo apt-get install -y python3-numba sudo apt-get install -y python3-pyfftw sudo apt-get install -y python3 python3-pip python3-pil libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev libopenjp2-7 libtiff6 sudo apt-get install -y python3-smbus python3-rpi-lgpio python3-pyaudio i2c-tools sudo apt install

  8. Ensure you are at your home directory (will be unless you changed it) and enter the following:
    python3 -m venv ~/luma-env ~/luma-env/bin/python -m pip install --upgrade luma.lcd ~/luma-env/bin/python -m pip install --upgrade luma.emulator ~/luma-env/bin/python -m pip install RPi.GPIO ~/luma-env/bin/python -m pip install psutil ~/luma-env/bin/python -m pip install scipy ~/luma-env/bin/python -m pip install gpiozero ~/luma-env/bin/python -m pip install PortAudio ~/luma-env/bin/python -m pip install sounddevice ~/luma-env/bin/python -m pip install smbus ~/luma-env/bin/python -m pip install posix_ipx ~/luma-env/bin/python -m pip install numba ~/luma-env/bin/python -m pip install threadpoolctl ~/luma-env/bin/python -m pip install spidev ~/luma-env/bin/python -m pip install lgpio

  9. Again, ensure you are in your home directory and enter the following to download the tracker software (leave the bash/command window open):
    git clone https://github.com/RobSmithDev/alienmotiontracker.git cd alienmotiontracker chmod +x startup.sh

  10. Test 1: With the PCB hardware connected to the Pi, enter the following command:
    i2cdetect -y 1

    If the PCB is working correctly, then you should see the following output:
    alien@raspberrypi:~/alienmotiontracker $ i2cdetect -y 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- alien@raspberrypi:~/alienmotiontracker $

    If 48 and 68 are not present then you have a wiring problem and need to have another look at your PCB and cable connection. If they are there then the Pi can happily see the Accelerometer and Analog to Digital converter boards!

  11. Test 2: With the DreamRF+Radar hat connected, open a NEW bash/command prompt enter the following commands:
    cd alienmotiontracker sudo ~/luma-env/bin/python run_streaming_tracker.py

    If all is well you should see the following output:
    alien@raspberrypi:~/alienmotiontracker $ sudo ~/luma-env/bin/python run_streaming_tracker.py Real-time scheduling set: SCHED_FIFO, priority=40 CHIP_ID: 0xF4000303 This chip is BGT60TR13C Loading radar_config file: radar/config/<some filename>.txt num_samples_per_frame: 32768 num_samples_irq: 4096 num_samples_per_burst: 2048 Running...

    If the radar was detected correctly, it will have the above ID and the chip will be identified as BGT60TR13C. If not, please check it is connected correctly.
    For now, LEAVE THIS PROCESS RUNNING!

  12. Test 3: Open another bash/command prompt and type in the following:
    cd alienmotiontracker ~/luma-env/bin/python main.py

    And The tracker software should start.
    NOTE: While the splash screen is displayed, the accelerometer is being calebrated. DO NOT MOVE It while the splash screen is visible.

  13. Auto-Start Configuration. Kill off any of the bash/command prompts you have running and start a new one, and enter the following:
    cd alienmotiontracker sudo cp startup_scripts.service /etc/systemd/system/ sudo chmod 644 /etc/systemd/system/startup_scripts.service sudo chown root:root /etc/systemd/system/startup_scripts.service sudo systemctl daemon-reload sudo systemctl enable startup_scripts.service sudo nano /boot/firmware/config.txt

    At this point, NANO, a simple text editor will appear. Use the cursor keys and add the following line somewhere near the top.
    gpio=20=op,dl

    Press CTRL+O and then Enter to save it, then press CTRL+X to exit.

  14. USB Audio Configuration - With the USB Audio device plugged in, start a new bash/command prompt and type in:
    sudo raspi-config

    Then use the cursor keys to browse to: System Options >> Audio
    Select USB Audio
    Select OK and Exit.

    Tip: Disable starting the GUI for better performance
    Finally, reboot the Pi from the menu.



  15. After this is all done, your Pi, with the hardware connected should boot up and work. This will be the first time you get to play with the setup!

  16. Some useful commands:

    Start the Service (start the tracker):
    sudo systemctl start startup_scripts.service

    Stop the Service (stop the tracker):
    sudo systemctl stop startup_scripts.service

    List Running Python Processes:
    pgrep -a python3

    Stop a single Process:
    sudo kill <Process ID>

    Start the GUI (if you have disabled it)
    sudo init 5

  17. Power Throttling Troubleshooting: If the framerate is slow, you are probably being throttled due to poor power supply. You need to use thicker wires, double them up and shorten them! You can see this while the desktop is visible, or by using the following command:
    vcgencmd get_throttled

    You will get a response like:
    throttled=0x50005 or throttled=0x50000
    Then you have or are being throttled.

    Ideally it needs to look like throttled=0x0 which means everything is running ok. If you see any '1' or '4' then you also have an issue.

    If the problem still persists, as a LAST RESORT you can do this, but this might make the system unstable:
    sudo nano /boot/firmware/config.txt

    At this point, NANO, a simple text editor will appear. Use the cursor keys and add the following line somewhere.
    avoid_warnings=2

    Press CTRL+O and then Enter to save it, then press CTRL+X to exit.