|
| 1 | +--- |
| 2 | +title: Installation Guide |
| 3 | +weight: 3 |
| 4 | + |
| 5 | +### FIXED, DO NOT MODIFY |
| 6 | +layout: learningpathall |
| 7 | +--- |
| 8 | + |
| 9 | +# Installation Guide |
| 10 | + |
| 11 | +{{% notice Note %}} |
| 12 | +This guide assumes you have already set up your Raspberry Pi or NVIDIA Jetson board with an operating system and network connectivity.For board setup help, see: [Raspberry Pi Getting Started](https://www.raspberrypi.com/documentation/) or [Jetson Getting Started](https://developer.nvidia.com/embedded/learn/get-started-jetson-nano-devkit). |
| 13 | +{{% /notice %}} |
| 14 | + |
| 15 | +### Step 1: Connect to Your Board via SSH |
| 16 | + |
| 17 | +Before proceeding, make sure your SBC is connected to the same network as your host computer. Then, access your device remotely via SSH. You can use the terminal in Visual Studio Code on your host PC, the built-in terminal, Command Prompt, or any other preferred SSH client. |
| 18 | + |
| 19 | +Replace `<user>` with your device’s username , and `<board-ip>` with your device’s IP address. |
| 20 | + |
| 21 | +**General SSH Command:** |
| 22 | + |
| 23 | +```bash |
| 24 | +ssh <user>@<board-ip> |
| 25 | + |
| 26 | +``` |
| 27 | + |
| 28 | +Create a directory called smart-home in your home directory and navigate into it by running the following commands: |
| 29 | + |
| 30 | +```bash |
| 31 | +mkdir ~/smart-home |
| 32 | +cd ~/smart-home |
| 33 | +``` |
| 34 | + |
| 35 | +### Step 2: System Preparation |
| 36 | + |
| 37 | +Update your system and ensure Python 3 and pip are installed. |
| 38 | + |
| 39 | +```bash |
| 40 | +sudo apt update && sudo apt upgrade |
| 41 | +sudo apt install python3 python3-pip python3-venv git |
| 42 | +``` |
| 43 | + |
| 44 | +### Step 3: Requirements Installation |
| 45 | + |
| 46 | +Create and activate a Python virtual environment using the following commands. This is recommended, as it keeps your project dependencies isolated and prevents conflicts with system-wide packages: |
| 47 | + |
| 48 | +```bash |
| 49 | +python3 -m venv venv |
| 50 | +source venv/bin/activate |
| 51 | +``` |
| 52 | + |
| 53 | +This approach helps ensure that your system’s Python environment remains stable and avoids breaking other projects. |
| 54 | + |
| 55 | +Next, install all the required libraries and dependencies for the project by running the appropriate command for your board: |
| 56 | + |
| 57 | +{{< tabpane code=true >}} |
| 58 | +{{< tab header="Jetson (NVIDIA)" language="bash">}} |
| 59 | +pip install flask flask-cors requests schedule ollama adafruit-blinka adafruit-circuitpython-dht Jetson.GPIO |
| 60 | + |
| 61 | +{{< /tab >}} |
| 62 | +{{< tab header="Raspberry Pi" language="bash">}} |
| 63 | +pip install flask flask-cors requests schedule ollama adafruit-blinka adafruit-circuitpython-dht RPi.GPIO |
| 64 | +{{< /tab >}} |
| 65 | +{{< /tabpane >}} |
| 66 | + |
| 67 | +If you prefer, you can also run the above pip install commands directly, without creating a virtual environment. However, using a virtual environment is strongly recommended for most development workflows. |
| 68 | + |
| 69 | +### Step 4: Install Ollama |
| 70 | + |
| 71 | +Run the following command to install **Ollama** |
| 72 | + |
| 73 | +```bash |
| 74 | +curl -fsSL https://ollama.com/install.sh | sh |
| 75 | +``` |
| 76 | + |
| 77 | +On most recent Linux distributions (including Raspberry Pi OS and Ubuntu for Jetson), curl is usually pre-installed by default. However, in some minimal installations, it might not be present. If you get a **command not found** error for curl, you can easily install it with: |
| 78 | + |
| 79 | +```bash |
| 80 | +sudo apt update |
| 81 | +sudo apt install curl |
| 82 | +``` |
| 83 | + |
| 84 | +After installation, verify it by running the following command: |
| 85 | + |
| 86 | +```bash |
| 87 | +ollama --version |
| 88 | +``` |
| 89 | + |
| 90 | +### Step 5: Download and Test a Language Model |
| 91 | + |
| 92 | +Ollama supports a variety of models. This guide uses Deepseek-R1:7B as an example, but you can also use other models such as Mistral or Phi. To pull and run Deepseek-R1:7B: |
| 93 | + |
| 94 | +```bash |
| 95 | +ollama run deepseek-r1:7b |
| 96 | +``` |
| 97 | + |
| 98 | +Ollama will automatically download deepseek -r1:7b first before running it. You’ll see download progress in the terminal, followed by the interactive prompt once it’s ready. An example is shown in the image below: |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | +### Step 6: Verify GPIO Functionality |
| 103 | + |
| 104 | +To test the GPIO functionality, you’ll begin by connecting an LED to your board. For **Jetson Xavier AGX**, connect the anode (the long leg) of an LED, in series with a suitable resistor, to pin 12 . For **Raspberry Pi**, connect the anode of the LED (again, in series with a resistor) to GPIO 17 . In both cases, connect the cathode (the short leg) of the LED to a ground (GND) pin on your SBC. Once your wiring is complete, create a Python script named `testgpio.py` using your favorite editor. |
| 105 | + |
| 106 | +```bash |
| 107 | +vim testgpio.py |
| 108 | +``` |
| 109 | + |
| 110 | +Copy the appropriate code below into the testgpio.py file you just created, then save and close the file. |
| 111 | + |
| 112 | +{{< tabpane code=true >}} |
| 113 | +{{< tab header="Jetson" language="python" output_lines="8">}} |
| 114 | +import Jetson.GPIO as GPIO |
| 115 | +import time |
| 116 | + |
| 117 | +GPIO.setmode(GPIO.BOARD) |
| 118 | +GPIO.setup(12, GPIO.OUT) |
| 119 | +GPIO.output(12, GPIO.HIGH) |
| 120 | +time.sleep(2) |
| 121 | +GPIO.output(12, GPIO.LOW) |
| 122 | +GPIO.cleanup() |
| 123 | +{{< /tab >}} |
| 124 | +{{< tab header="Raspberry Pi" language="python" output_lines="8">}} |
| 125 | +import RPi.GPIO as GPIO |
| 126 | +import time |
| 127 | + |
| 128 | +GPIO.setmode(GPIO.BCM) |
| 129 | +GPIO.setup(17, GPIO.OUT) |
| 130 | +GPIO.output(17, GPIO.HIGH) |
| 131 | +time.sleep(2) |
| 132 | +GPIO.output(17, GPIO.LOW) |
| 133 | +GPIO.cleanup() |
| 134 | +{{< /tab >}} |
| 135 | +{{< /tabpane >}} |
| 136 | + |
| 137 | +Once you’ve saved your script, run the code using the following command in your terminal: |
| 138 | + |
| 139 | +```bash |
| 140 | +python testgpio.py |
| 141 | +``` |
| 142 | + |
| 143 | +The LED should blink according to the set timing in your script—turning on for two seconds and then off. If you see this behavior, your GPIO setup is working correctly. |
| 144 | + |
| 145 | + |
| 146 | +### Troubleshooting |
| 147 | + |
| 148 | +- Missing dependencies? |
| 149 | + |
| 150 | + Run the following command to resolve the issue: |
| 151 | + |
| 152 | + ```bash |
| 153 | + sudo apt-get install -f |
| 154 | + ``` |
| 155 | + |
| 156 | +- GPIO permission errors? |
| 157 | + |
| 158 | + - Run Python scripts with **sudo**. |
| 159 | + |
| 160 | +- Model download issues? |
| 161 | + |
| 162 | + - Confirm you have internet access and sufficient storage space on your device. |
| 163 | + |
| 164 | + - Check the model size before downloading to ensure your SBC has enough space to store and run it. |
| 165 | + - Try downloading a smaller model |
| 166 | + - If you encounter errors, clear up storage or try connecting to a more stable network |
| 167 | + |
| 168 | +- Hardware not responding? |
| 169 | + |
| 170 | + - Double-check wiring and pin numbers. |
0 commit comments