Skip to content

Instantly share code, notes, and snippets.

@crbyxwpzfl
Last active February 21, 2022 11:55
Show Gist options
  • Save crbyxwpzfl/a3091ad72f503de47969eba95e09ecaf to your computer and use it in GitHub Desktop.
Save crbyxwpzfl/a3091ad72f503de47969eba95e09ecaf to your computer and use it in GitHub Desktop.
legacy spinala pi in general stuff

sudo apt-get install screen

nano ~/.bash_profile	#launche screen on boot add
if  [ -z $STY ] && [ $TERM != "screen" ]; then
/usr/bin/screen -xRR;
else
/usr/bin/screen -X hardstatus alwayslastline '[%H] %Lw%=%u %d.%m.%y %c '
fi
screen -ls 	# list screens<br>
screen -d 	# detach from screen<br>
screen -r	# resume attache to screen<br>
exit 		# close screen window<br>
Strg a c	# new screen window<br>
Strg a ESC 	# enter scroll mode 'Strg u d' up down<br>
Strg a SPACE 	# cycle screen windows<br>
Strg a | 	# vertical split<br>
Strg a TAB 	# move between splits<br>
Strg a :remove 	# to remove split<br>
nano /etc/environment 		# append privates=/path/to/private/ with /paht/to/private/privates.py
sudo homebridge -D -U /path/to/ 	# with path/to/config.js to start hb manually

hb service configuration

nano /etc/default/homebridge 	# append privates=/path/to/private/ 
				# set HOMEBRIDGE_OPTS=-D -U "/path/to" and UIX_STORAGE_PATH="/path/to" with path/to/config.js

nano /etc/systemd/system/homebridge.service 	# change user to root to run hb as root
nano /etc/default/homebridge 			# HOMEBRIDGE_OPTS=-D -U "/path/to/config" --allow-root

to choose network intervace /var/lib/homerbidge/config.json

{
	"mdns": {"intervace": "ip-of-interface"},
	"bridge": {
		"name": "...",
		"username": "...",
		"port": ...,
		"pin": "..."

camera ffmpeg plugin

cp -f usr/bin/ffmpeg /usr/lib/node_modules/homebridge-camera-ffmpeg/node_modules/ffmpeg-for-homebridge/ffmpeg
	# replace ffmpeg bundled with plugin with ffmpeg bundled with rasbian full img
"_comment": "to capture desktop when booting to desktop use this in config",
"source": "-f x11grab -r 10 -video_size 1280x720 -i :0.0",
"stillImageSource": "-f x11grab -t 1 -video_size 1280x720 -i :0.0 -vframes 1",

"_comment": "to capture cli when booting to cli use this in config",
"source": "-f fbdev -framerate 15 -i /dev/fb0"
"stillimageSource": "-f fbdev -i /dev/fb0 -t 1 -vframes 1"

usefull others

pinout 		# prints rpis pinout __ACHTUNG__ diff between gpioNr. and board pinNr
ifconfig 	# list interfaces
vcgencmd measure_temp	# return fantemp

python to control fan

import RPi.GPIO as GPIO
fan = 8
GPIO.setmode(GPIO.BOARD)
GPIO.output(fan, 1)
GPIO.cleanup()

python to read mcp3008

mport os
import time
import busio
import digitalio
import board
import adafruit_mcp3xxx.mcp3008 as MCP
from adafruit_mcp3xxx.analog_in import AnalogIn

# create the spi bus
spi = busio.SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI)

# create the cs (chip select)
cs = digitalio.DigitalInOut(board.D22)

# create the mcp object
mcp = MCP.MCP3008(spi, cs)

# create an analog input channel on pin 0
chan0 = AnalogIn(mcp, MCP.P0)

print('Raw ADC Value: ', chan0.value)
print('ADC Voltage: ' + str(chan0.voltage) + 'V')

while True:
    print('Raw ADC Value: ', chan0.value)

    # hang out and do nothing for a half second
    time.sleep(0.2)

python to gert cpu temp

from gpiozero import CPUTemperature

cpu = CPUTemperature()
print(round(cpu.temperature))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment