Code Monkey home page Code Monkey logo

hamsterraps's Introduction

Install guide

Basic configuration

  • Install Raspberry Pi OS Lite (32-bit) with SSH enabled. With i.e. Raspi Card Imager for Android. Available in Play Store.

  • Edit password with passwd

  • Edit /etc/wpa_supplicant/wpa_supplicant.conf to enter WiFi network and password. Add the following to the end of the file:

    network={
          ssid="Wifi name"
          psk="Wifi password"
    }
  • Execute hostname -I to check assigned IP adress

  • Edit the hostname of the raspberry using sudo raspi-config. System options -> Hostname

  • Login to raspberry via SSH using ssh pi@hostname

Git(hub) using SSH

  • Install git
  • ssh-keygen -t ed25519 -C "[email protected]"
  • Enter a passphrase
  • eval "$(ssh-agent -s)" (?)
  • ssh-add ~/.ssh/id_ed25519 (?)
  • Add the ssh key to GitHub. Copy and paste the contents of ~/.ssh/id_ed25519.pub

NGINX

  • Guide from here.

  • sudo apt-get update
    sudo apt-get upgrade
  • sudo apt-get remove apache2 (in case apache is installed)

  • sudo apt-get install nginx

  • Confirm by browsing to http://your-hostname/

  • Create /etc/nginx/sites-available/url.conf

    server {
      listen 4000;
      server_name *url here, e.g. raps.hilkojj.nl*;
      location / {
        proxy_pass http://localhost:8000;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
      }
    }

    NOTE: The Upgrade and Connection headers are to support Websockets.

  • sudo ln -s /etc/nginx/sites-available/url.conf /etc/nginx/sites-enabled/url.conf

  • Confirm with sudo nginx -t

  • Reload NGINX sudo systemctl reload nginx

  • Read logs with

    sudo tail -f /var/log/nginx/access.log
    

    or

    sudo tail -f /var/log/nginx/error.log
    

Firewall

  • Install firewall sudo apt install ufw
  • sudo ufw limit 22 limited SSH access
  • sudo ufw allow 80 unlimited access to default NGINX http server (required for certbot)
  • sudo ufw allow 443 unlimited access to httpS server
  • Confirm with sudo ufw show added
  • Enable with sudo ufw enable
  • Check status anytime with sudo ufw status

Port forwarding

  • Give the raspberry a static local IP adress.
  • Using NAT forward port 443 from raspberry to port 443
  • Using NAT forward port 80 from raspberry to port 80
  • Now default NGINX server is visible on http://url. This is needed for certbot

Letsencrypt (Serve over httpS)

  • sudo apt install letsencrypt

  • Confirm renewal bot is running: sudo systemctl status certbot.timer

  • apt install python3-certbot-nginx

  • sudo certbot --nginx --agree-tos --preferred-challenges http -d raps.hilkojj.nl

    NOTE:

    certbot will try to retrieve a file for confirmation from the provided url, so make sure port 80 is also port forwarded.

  • Now everything that is hosted locally on port 8000 will be accessible through HTTPS (port 443): https://url

Python & booting stuff

  • Install Pip3 and other useful utilities:

    sudo apt-get install python3-dev python3-pip
    sudo python3 -m pip install --upgrade pip setuptools wheel
  • Install pipenv to keep track of installed packages for this project: pip3 install --user pipenv

  • Enter the environment with pipenv shell.

    Use sudo -E env PATH=$PATH python boot.py to run script with sudo

  • Run boot.py on each reboot: sudo nano /etc/crontab.

  • Add @reboot pi cd /home/pi/hamsterraps/ && sudo -E env PATH=$PATH /home/pi/.local/bin/pipenv run sh ./boot.sh to end of file.

    sudo is needed in order for ws2811_init() to succeed. (-5 return code otherwise).

    sudo -E env PATH=$PATH explained here.

Temperature sensor

  • sudo pip3 install Adafruit_DHT
  • DHT11 sensor pins are: Signal, 5V, Ground
  • Script uses GPIO pin 4, 4th pin on left column
  • import Adafruit_DHT
    import time
    
    DHT_SENSOR = Adafruit_DHT.DHT11
    DHT_PIN = 4
    
    while True:
        humidity, temperature = Adafruit_DHT.read(DHT_SENSOR, DHT_PIN)
        if humidity is not None and temperature is not None:
            print("Temp={0:0.1f}C Humidity={1:0.1f}%".format(temperature, humidity))
        else:
            print("Sensor failure. Check wiring.");
        time.sleep(3);
    copied from here

Waveshare display

  • Add this to the end of /boot/config.txt:
    max_usb_current=1
    hdmi_group=2
    hdmi_mode=87
    hdmi_cvt 800 480 60 6 0 0 0  
    hdmi_drive=1
    More info on waveshare display
  • Enable passwordless login to console with sudo raspi-config -> 1 -> S5
  • Follow this (or this) guide on starting up Chromium without a window manager.
  • Also don't forget to add this to ~/.bash_profile, otherwise ~/.bashrc and ~/.profile won't work anymore:
    if [ -n "$BASH_VERSION" ]; then
      # include .bashrc if it exists
      if [ -f "$HOME/.bashrc" ]; then
          . "$HOME/.bashrc"
      fi
      if [ -f "$HOME/.profile" ]; then
          . "$HOME/.profile"
      fi
    fi
  • Install an emoji font with sudo apt-get install fonts-noto-color-emoji

IR Camera

  • Enable camera with sudo raspi-config and reboot
  • Install ffmpeg sudo apt install ffmpeg

hamsterraps's People

Contributors

hilkojj avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.