فهرست منبع

* moving materials from https://og2k.com/pub/make/hardware/RPi/ to https://github.com/InstallAndUse/RPi /A

anton@lab5mbp1 2 سال پیش
والد
کامیت
99358ea23c

+ 3 - 0
README.md

@@ -1,2 +1,5 @@
 # RPi
+#
+# 2022 03 19  + published on https://github.com/InstallAndUse/RPi /A
+
 Raspberry computer related projects

+ 31 - 0
install_firstboot/README.md

@@ -0,0 +1,31 @@
+#
+# initial Raspberry Pi configuration
+#
+# 2020 06 12  + init of firstboot@rpi.md /A
+# 2022 03 19  + published on https://github.com/InstallAndUse/RPi /A
+#
+
+# set pi pass
+passwd
+
+# set root pass
+sudo su
+passwd
+
+# add yourself (for ssh keys, security. etc...)
+useradd (you)
+passwd (you)
+usermod -aG sudo (you)
+mkdir /home/(you)
+chown -R (you):(you) /home/(you)
+
+# update
+apt update && apt upgrade -y
+
+# initial config
+raspi-config
+2. N1, set hostname
+4. localisation, I2, set timezone
+5. interfacing, P2, enable ssh
+
+# reboot

+ 80 - 1
setup_NTP_server_using_GPS_receiver/README.md

@@ -1 +1,80 @@
-In this project we shall setup NTP-server on Raspberry using GPS-receiver connected to serial port.
+# In this project we shall setup NTP-server on Raspberry using GPS-receiver connected to serial port.
+#
+# 2020 05 26  + init chrony@rpi /A
+# 2022 03 19  + published on https://github.com/InstallAndUse/RPi /A
+#
+
+# getting time from gps
+apt install gpsd gpsd-clients python-gps
+nano /etc/default/gpsd
+    DEVICES="/dev/ttyAMA0"
+    GPSD_OPTIONS="-n"
+systemctl enable gpsd && systemctl restart gpsd
+systemctl status gpsd
+# add serial device (BT uses another one)
+nano /boot/config.txt
+    dtoverlay=pi3-miniuart-bt
+    core_freq=250
+shutdown -r now
+# test
+cgps -s
+gpsmon -n
+
+
+# setting up NTP server
+apt install chrony
+#? systemctl enable chronyd && systemctl restart chronyd
+systemctl status chronyd
+chronyc sources -v
+nano /etc/chrony/chrony.conf
+    # comment for setup, uncomment on finish (to keep for time comparison)
+    pool 2.fedora.pool.ntp.org iburst
+    pool 2.debian.pool.ntp.org iburst
+    # add NMEA source as time reference
+    refclock SHM 0 offset 0.5 delay 0.2 refid NMEA
+systemctl restart chronyd
+chronyc sources -v
+
+# test
+ntpshmmon
+
+
+# set up NTP server
+nano /etc/chrony/chrony.conf
+    allow 192.168.0.0/16
+systemctl restart chronyd
+# test
+chronyc
+    clients
+    serverstats
+
+
+# clean and remove ntpdate
+apt remove ntpdate
+
+
+
+
+
+
+
+
+
+# Remove ntp-servers from
+nano /etc/dhcp/dhclient.conf
+    # remove "request ntp-servers"
+    # remove "option ntp_servers"
+rm
+    /etc/dhcp/dhclient-exit-hooks.d/ntp
+    /lib/dhcpcd/dhcpcd-hooks/50-ntp.conf
+    /var/lib/ntp/ntp.conf.dhcp (might not exist)
+
+
+
+
+
+
+
+#
+# refs: https://gpsd.gitlab.io/gpsd/gpsd-time-service-howto.html#_feeding_chrony_from_gpsd
+#       http://www.unixwiz.net/techtips/raspberry-pi3-gps-time.html

+ 83 - 0
setup_real_time_clock_RTC/README.md

@@ -0,0 +1,83 @@
+#
+# 2020 05 27  + init RTC@rpi  /A
+# 2022 03 19  + published on https://github.com/InstallAndUse/RPi /A
+#
+
+# enable modules
+sudo
+nano /etc/modules
+    i2c-bcm2708
+    i2c-dev
+
+nano /etc/modprobe.d/raspi-blacklist.conf
+# comment
+# blacklist spi-bcm2708
+# blacklist i2c-bcm2708
+
+#
+# SPI (DS1302)
+#
+
+
+#
+# i2c (DS1307, PCF8523, DS3231)
+#
+apt install i2c-tools
+i2cdetect -y 1
+modprobe rtc-ds1307
+echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device
+
+# read RTC
+hwclock -r
+
+# write RTC
+hwclock -w
+
+
+# add to boot
+nano /etc/init.d/hwlock.sh
+# unset TZ at top add
+    do
+      echo ds1307 0x68 >> $bus/new_device;
+      if [ -e /dev/rtc0 ];
+      then
+        log_action_msg "RTC found on bus `cat $bus/name`";
+        break; # RTC found, bail out of the loop
+      else
+        echo 0x68 >> $bus/delete_device
+      fi
+    done
+    }
+# near case, chage
+    case "$1" in
+    	start)
+    	    # If the admin deleted the hwclock config, create a blank
+    	    # template with the defaults.
+    	    if [ -w /etc ] && [ ! -f /etc/adjtime ] && [ ! -e /etc/adjtime ]; then
+    	        printf "0.0 0 0.0\n0\nUTC" > /etc/adjtime
+    	    fi
+    		init_rtc_device
+
+                # Raspberry Pi doesn't have udev detectable RTC
+    	    #if [ -d /run/udev ] || [ -d /dev/.udev ]; then
+
+update-rc.d hwclock.sh enable
+update-rc.d fake-hwclock remove
+
+# remove fake hardware clock, used in RPi
+sudo su
+apt-get -y remove fake-hwclock
+update-rc.d -f fake-hwclock remove
+systemctl disable fake-hwclock
+
+
+
+
+
+
+
+
+
+
+# refs:
+# https://cdn-learn.adafruit.com/downloads/pdf/adding-a-real-time-clock-to-raspberry-pi.pdf

+ 2 - 1
setup_replication_of_historical_data_from_sensors_to_server_using_PostgreSQL/README.md

@@ -1 +1,2 @@
-In this project we shall setup replication between PostgreSQL DataBases (DBs) to move historical data of DS18x20 sensors from measurement units to server. 
+# In this project we shall setup replication between PostgreSQL DataBases (DBs) to move historical data of DS18x20 sensors from measurement units to server.
+# 2022 03 19  + published on https://github.com/InstallAndUse/RPi /A

+ 2 - 1
show_DS18x20_sensors_historical_data_from_PostgreSQL_using_Grafana/README.md

@@ -1 +1,2 @@
-In this project, we shall use Grafana frontend to show historical data of DS18x20 Dallas sensors, connecting to PostgreSQL.
+# In this project, we shall use Grafana frontend to show historical data of DS18x20 Dallas sensors, connecting to PostgreSQL.
+# 2022 03 19  + published on https://github.com/InstallAndUse/RPi /A

+ 23 - 0
show_egp30_sensors_data/read_sgp30.py

@@ -0,0 +1,23 @@
+#!/usr/bin/python3
+#
+# read sgp30 sensor
+#
+# 2020 05 19  * init  /A
+# 2022 03 19  + published on https://github.com/InstallAndUse/RPi /A
+#
+# TODO:
+#
+#
+
+import busio
+import adafruit_sgp30
+
+import board
+i2c_bus = busio.I2C(board.SCL, board.SDA, frequency=1000000)
+
+sgp30 = adafruit_sgp30.Adafruit_SGP30(i2c_bus)
+
+print("SGP30 serial #", [hex(i) for i in sgp30.serial])
+
+eCO2, TVOC = sgp30.iaq_measure()
+print("eCO2 = %d ppm \t TVOC = %d ppb" % (eCO2, TVOC))