Raspberry Pi

RPi Benchmark
Setting up Dynamic DNS using DDClient
  1. Install DDClient with ‘suso apt-get install ddclient’
  2. Add/Edit the file ddclient.config in /etc:
    • #Configuration file for ddclient generated by debconf
    • #Located at /etc/ddclient.conf
    • daemon=60
    • syslog=yes
    • protocol=dyndns2 \
    • pid=/var/run/ddclient.pid
    • ssl=yes
    • use=web, web=checkip.dynu.com/ web-skip=’IP Address’
    • server=api.dynu.com \
    • protocol=dyndns2
    • login=username \
    • password=’password’ \
    • a list of domains e.g g6ejd.dynu.com
Testing your DDClient configuration

4. Use a cron job to make the script run every 5 minutes.


5. Add to Crontab entries:

Camera Installation
https://elinux.org/RPi-Cam-Web-Interface
General Utilities

1. Check how much RAM is installed:
free -h
total used free shared buff/cache available
Mem: 3.8Gi 470Mi 1.7Gi 136Mi 1.6Gi 3.1Gi
Swap: 99Mi 0B 99Mi

2. Check Disk Free Space
DF -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 117G 7.4G 105G 7% /
devtmpfs 1.8G 0 1.8G 0% /dev
tmpfs 2.0G 24M 1.9G 2% /dev/shm
tmpfs 2.0G 8.6M 1.9G 1% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/mmcblk0p1 253M 53M 200M 21% /boot
tmpfs 391M 0 391M 0% /run/user/1000

MariaDB Notes

Editing the database schema:
1. First log on to MYSQL:
a. sudo mysql -u<username> -p
b. enter <password>
2. General utilities:
a. SHOW DATABASES; # lists all databases created
b. DESCRIBE <table>; # e.g. socdata in records
3. Select a database to work on:
a. USE <database>;
b. SELECT * FROM <tablename> # shows all rows
c. ALTER <tablename> ADD COLUMN <name> <type> #e.g. ALTER socdata ADD COLUMN kwh float
d. UPDATE <<databasename>.<tablename> SET <columnname>=�value� WHERE <columnname>=�value� && date=�2021-05-15 15:25:00″
4. Access database:
a. sudo mysql -uroot -p
5. Show databases:
a. show databases;
6. Connect to database:
a. use �database name�;
7. Show Tables:
a. show tables;
8. Show Columns:
a. show columns from �database name�;
9. Show Rows:
a. select * from �database name�;
10. Add a Column
a. ALTER TABLE battery_data ADD COLUMN batterycharge FLOAT;

Argon One M.2 Case – auto power on after power failure

1. Install i2c toolsRPi Benchmark

sudo curl https://raw.githubusercontent.com/TheRemote/PiBenchmarks/master/Storage.sh | sudo bash

Setting up Dynamic DNS using DDClient

# Configuration file for ddclient generated by debconf

#Edit the configuration file: sudo nano /etc/ddclient.conf

# /etc/ddclient.conf

protocol=dyndns2

use=web, web=checkip.dyndns.org/

server=api.dynu.com

login=<dynu username>

password='<dynu password>�

g6ejd.dynu.com

Testing your DDClient configuration

You can check if the pre-defined use values can detect your WAN IP by running this command:

sudo ddclient -query

If your server is connected with a wireless connection, the output should look something like this:

use=if, if=eth0 address is NOT FOUND

use=if, if=lo address is 127.0.0.1

use=if, if=wlan0 address is 192.168.0.103

use=web, web=dnspark address is NOT FOUND

use=web, web=dyndns address is 78.105.145.204

use=web, web=loopia address is 78.105.145.204

To test your ddclient configuration with really verbose output, printing all possible configuration parameters and their values, you can use this command:

sudo /usr/sbin/ddclient -daemon 30 -debug -verbose > temp

Forwarding RPi IP address to Dynudns

You can make a script in Raspberry Pi and setup a cron job to run every 5 minutes to keep your hostnames updated to the most current IP address.

1. You can make a directory to put the files in.

cd ~

mkdir dynudns

cd dynudns

vi dynu.sh

2. Move to dynu.sh and make the script. Copy and paste the following into the file and save it.

#!/bin/bash

echo url=�http://api.dynu.com/nic/update?hostname=<domain>.dynu.com&password=<password>� | curl -a -k -a -o /home/pi/dynudns/dynu.log -K �

echo >> /home/pi/dynudns/dynu.log

echo �Time: $(date)� >> /home/pi/dynudns/dynu.log

*/10 * * * * bash -l -c /home/pi/dynudns/dynu.sh >/dev/null 2>&1

3. Make dynu.sh executable.

chmod 700 dynu.sh

4. Use a cron job to make the script run every 5 minutes.

crontab -e

copy and paste the below to the bottom of the crontab:

*/10 * * * * bash -l -c /home/pi/dynudns/dynu.sh >/dev/null 2>&1

To verify that the command was added to the cronjob you can list the cron jobs to make sure it is there:

crontab -l

It should show

*/10 * * * * bash -l -c /home/pi/dynudns/dynu.sh >/dev/null 2>&1

You can adjust the update interval by modifying the */10 to */60 for every 60 minutes or whatever interval you need.

Adding Image Uploads to Weather Underground

1. Create a script to upload the images, create a new file called �wunder.sh� and enter the following in the file:

a. #!/bin/bashfilename=��http://localhost:8082/html/cam.jpg�

hostname=�webcam.wunderground.com�

username=�camerausername�

password=�password�

lftp ftp://$username:$password@$hostname -e �put $filename ; quit�

2. Save and exit

3. Make the script file executable:

a. sudo chmod +x wunder.sh

b. Copy the file to /home/pi with cp wunder.sh /home/pi/

4. Create a PYTHON script file:

a. sudo nano wunder.py

b. Add to the file the following:

i. #!/usr/bin/env pythonimport shutil

import os

os.system(�bash -c /home/pi/wunder.sh�)

5. Make the PYTHON script executable:

a. sudo chmod -x wunder.py

6. Add to the CRONTAB an updating call to the script:

1. sudo crontab -u pi -e (-u for User that is pi and -e for Edit)

2. Add the following for 15-min updates intervals:

*/15 * * * * python /home/pi/wunder.py >> /home/pi/script.log &

7. Finished

General Utilities

1. Check how much RAM is installed:

free -h

total used free shared buff/cache available

Mem: 3.8Gi 470Mi 1.7Gi 136Mi 1.6Gi 3.1Gi

Swap: 99Mi 0B 99Mi

2. Check Disk Free Space

DF -h

Filesystem Size Used Avail Use% Mounted on

/dev/root 117G 7.4G 105G 7% /

devtmpfs 1.8G 0 1.8G 0% /dev

tmpfs 2.0G 24M 1.9G 2% /dev/shm

tmpfs 2.0G 8.6M 1.9G 1% /run

tmpfs 5.0M 4.0K 5.0M 1% /run/lock

tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup

/dev/mmcblk0p1 253M 53M 200M 21% /boot

tmpfs 391M 0 391M 0% /run/user/1000

MariaDB Notes

Editing the database schema:

1. First log on to MYSQL:

a. sudo mysql -u<username> -p

b. enter <password>

2. General utilities:

a. SHOW DATABASES; # lists all databases created

b. DESCRIBE <table>; # e.g. socdata in records

3. Select a database to work on:

a. USE <database>;

b. SELECT * FROM <tablename> # shows all rows

c. ALTER <tablename> ADD COLUMN <name> <type> #e.g. ALTER socdata ADD COLUMN kwh float

d. UPDATE <<databasename>.<tablename> SET <columnname>=�value� WHERE <columnname>=�value� && date=�2021-05-15 15:25:00″

4. Access database:

a. sudo mysql -uroot -p

5. Show databases:

a. show databases;

6. Connect to database:

a. use �database name�;

7. Show Tables:

a. show tables;

8. Show Columns:

a. show columns from �database name�;

9. Show Rows:

a. select * from �database name�;

10. Add a Column

a. ALTER TABLE battery_data ADD COLUMN batterycharge FLOAT;

Argon One M.2 Case – auto power on after power failure

1. Install i2c tools

a. sudo apt-get install i2c-tools

2. Modify i2c settings for case by entering this at the command-line and you have an auto-power-up Pi:

a. i2cset -y 1 0x01a 0xfe


a. sudo apt-get install i2c-tools
2. Modify i2c settings for case by entering this at the command-line and you have an auto-power-up Pi:
a. i2cset -y 1 0x01a 0xfe