Frost's Battery Opperated Raspberry Pi
How to get the most out of your Rasberry Pi on a battery. (Rasbian Strech)
Using the following, I went from around 440mA to 225mA use.
Parts:
DC-DC Buck 5v Converter:
link
Rasberry Pi:
link
Rechargable Battery:
link
Disable Bluetooth:
link
This should save you about 15mA of power.
sudo nano /boot/config.txt
At the end put:
# Disable Bluetooth
dtoverlay=pi3-disable-bt
Raspberry Pi 3b+ Disable USB and Ethernet:
link
Disable:
sudo echo '1-1' |sudo tee /sys/bus/usb/drivers/usb/unbind
Enable:
sudo echo '1-1' |sudo tee /sys/bus/usb/drivers/usb/bind
This saves about 200mA
How to have this start automatically
sudo nano ~/chuck_usblan.sh
---- Add between the lines ----
#!/bin/sh
echo '1-1' |sudo tee /sys/bus/usb/drivers/usb/unbind
/usr/bin/tvservice -o
----
Note: tvservice is your HDMI, leave that line out if you want to keep it running. (5-10mA savings)
Note: change path to your directory, my file is in /home/chuck in this example
sudo nano /etc/systemd/system/chuck_usblan.service
---- Add between the lines ----
[Service]
WorkingDirectory=/home/chuck/
ExecStart=/home/chuck/chuck_usblan.sh
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=chuck_usblan
User=root
Group=root
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
----
Tell systemctl about the service:
sudo chmod 744 ~/chuck_usblan.sh
sudo chmod 644 /etc/systemd/system/chuck_usblan.service
sudo systemctl enable chuck_usblan.service
CPU/GPU Throttling:
link
Disable LEDs:
link
sudo nano /boot/config.txt
At the end put:
# If you run with a display
arm_freq=700
arm_freq_min=100
core_freq=250
core_freq_min=75
sdram_freq=400
over_voltage=0
avoid_safe_mode=1
gpu_mem=192
overscan=1
# If you run without a display:
arm_freq=700
arm_freq_min=100
core_freq=75
core_freq_min=75
sdram_freq=400
over_voltage=0
avoid_safe_mode=1
gpu_mem=16
overscan=1
# Uncomment to Disable LED for Pi Zeros
#dtparam=act_led_trigger=none
#dtparam=act_led_activelow=on
# Uncomment to Disable LED for Pi 2B B+ A
#dtparam=act_led_trigger=none
#dtparam=act_led_activelow=off
#dtparam=pwr_led_trigger=none
#dtparam=pwr_led_activelow=off
Change Default User Name
link
Set a root password (non-ssh):
sudo passwd root
logout
Change default name:
usermod -l newname pi
Set home directory:
usermod -m -d /home/newname newname
Change your password:
passwd
Check if sudo works:
sudo apt-get update
Disable Root:
sudo passwd -l root
sudo nano /etc/dhcpcd.conf
At bottom enter:
static ip_address=192.168.1.77
static routers=192.168.1.1
static domain_name_servers=8.8.8.8 8.8.4.4
sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade
sudo apt-get install nginx
sudo apt-get install php-fpm
sudo nano /etc/nginx/sites-enabled/default
Alter / Uncomment these lines:
index index.php;
location ~ \.php${
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php7-fpm.sock;
}
sudo systemctl restart nginx
sudo nano /var/www/html/index.php
Add lines:
<?php
echo phpinfo();
?>
sudo apt-get install samba samba-common-bin
mkdir ~/share
sudo nano /etc/samba/smb.conf
At bottom enter:
[PiShare]
comment=Raspberry Pi Share
path=/home/pi/share
browseable=Yes
writeable=Yes
only guest=no
create mask=0777
directory mask=0777
public=no
sudo raspi-config
raspistill -o image.jpg
sudo mkdir /ram
sudo mount -osize=50m tmpfs /ram -t tmpfs
sudo nano /etc/fstab
ramdrive /ram tmpfs nodev,nosuid,noexec,nodiratime,size=50M 0 0
ssh-keygen -f ~/tatu-key-ecdsa -t ecdsa -b 521
Copy the newly created public key to the servers .ssh/authroized_keys file
ssh-copy-id -i ~/.ssh/tatu-key-ecdsa user@host
You may need to create the servers ssh folder
mkdir ~/.ssh
chmod 700 ~/.ssh
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
chmod 600 ~/.ssh/tatu-key-ecdsa
chmod 600 ~/.ssh/tatu-key-ecdsa.pub
Your public key that you generated goes in the servers authroized_keys file to give you access to that server.
When you are ready to connect your line looks like this:
ssh -i tatu-key-ecdsa serverUserName@server.com
add -p for port if not 22
For SCP ( -P for port , capitol P)
scp -i ~/.ssh/id_rsa.ppk USER@SERVER:/home/USER/FILENAME FILENAME